1 /*****************************************************************************
2  * Copyright (C) 2000 Shie Erlich <krusader@users.sourceforge.net>           *
3  * Copyright (C) 2000 Rafi Yanai <krusader@users.sourceforge.net>            *
4  * Copyright (C) 2004-2019 Krusader Krew [https://krusader.org]              *
5  *                                                                           *
6  * This file is part of Krusader [https://krusader.org].                     *
7  *                                                                           *
8  * Krusader is free software: you can redistribute it and/or modify          *
9  * it under the terms of the GNU General Public License as published by      *
10  * the Free Software Foundation, either version 2 of the License, or         *
11  * (at your option) any later version.                                       *
12  *                                                                           *
13  * Krusader is distributed in the hope that it will be useful,               *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
16  * GNU General Public License for more details.                              *
17  *                                                                           *
18  * You should have received a copy of the GNU General Public License         *
19  * along with Krusader.  If not, see [http://www.gnu.org/licenses/].         *
20  *****************************************************************************/
21 
22 #ifndef KRGLOBAL_H
23 #define KRGLOBAL_H
24 
25 // QtGui
26 #include <QKeySequence>
27 
28 #include <KConfigCore/KConfigGroup>
29 
30 class KConfig;
31 class KMountMan;
32 class KrBookmarkHandler;
33 class KRslots;
34 class KrusaderView;
35 class UserAction;
36 class JobMan;
37 class QWidget;
38 class KrPanel;
39 
40 // global references to frequently used objects
41 
42 class KrGlobal
43 {
44 public:
45     static KConfig *config;    // allow everyone to access the config
46     static KMountMan *mountMan;  // krusader's Mount Manager
47     static KrBookmarkHandler *bookman;
48     static KRslots *slot;
49     static KrusaderView *mainView;  // The GUI
50     static QWidget *mainWindow;
51     static UserAction *userAction;
52     static JobMan *jobMan;
53 //     static ListPanel  *activePanel;
54     static KrPanel *activePanel();
55 
56     //HACK - used by [ListerTextArea|KrSearchDialog|LocateDlg]:keyPressEvent()
57     static QKeySequence copyShortcut;
58 
59 //     static void enableAction(const char *name, bool enable);
60 //     static QAction *getAction(const char *name);
61 
62     /** Version of saved configuration. Use this to detect configuration updates. */
63     static const int sConfigVersion = 1;
64     static int sCurrentConfigVersion;
65 };
66 
67 #define krConfig     KrGlobal::config
68 #define krMtMan      (*(KrGlobal::mountMan))
69 #define krBookMan    KrGlobal::bookman
70 #define SLOTS        KrGlobal::slot
71 #define MAIN_VIEW    KrGlobal::mainView
72 #define krMainWindow KrGlobal::mainWindow
73 #define krUserAction KrGlobal::userAction
74 #define krJobMan     KrGlobal::jobMan
75 
76 #define ACTIVE_PANEL (KrGlobal::activePanel())
77 
78 #define ACTIVE_MNG   (MAIN_VIEW->activeManager())
79 #define ACTIVE_FUNC  (ACTIVE_PANEL->func)
80 #define OTHER_MNG  (MAIN_VIEW->inactiveManager())
81 #define OTHER_PANEL (ACTIVE_PANEL->otherPanel())
82 #define OTHER_FUNC (OTHER_PANEL->func)
83 #define LEFT_PANEL (MAIN_VIEW->leftPanel())
84 #define LEFT_FUNC  (LEFT_PANEL->func)
85 #define LEFT_MNG  (MAIN_VIEW->leftManager())
86 #define RIGHT_PANEL  (MAIN_VIEW->rightPanel())
87 #define RIGHT_FUNC (RIGHT_PANEL->func)
88 #define RIGHT_MNG  (MAIN_VIEW->rightManager())
89 
90 // #define krEnableAction(name, enable) (KrGlobal::enableAction(#name, (enable)))
91 // #define krGetAction(name) (KrGlobal::getAction(#name))
92 
93 #endif
94