KVIrc  4.9.2
DeveloperAPIs
KviActionManager.h
Go to the documentation of this file.
1 #ifndef _KVI_ACTIONMANAGER_H_
2 #define _KVI_ACTIONMANAGER_H_
3 //=============================================================================
4 //
5 // File : KviActionManager.h
6 // Creation date : Sun 21 Nov 2004 03:37:57 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC Client distribution
9 // Copyright (C) 2004-2010 Szymon Stefanek <pragma at kvirc dot net>
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "kvi_settings.h"
28 #include "KviAction.h"
29 #include "KviPointerHashTable.h"
30 
31 #include <QObject>
32 
33 class KviActionDrawer;
34 class KviCustomToolBar;
35 
36 class KVIRC_API KviActionManager : public QObject
37 {
38  friend class KviActionDrawer;
39  friend class CustomizeToolBarsDialog; // this resides in a module!
40  friend class KviCustomToolBar;
41  friend class KviMainWindow;
42  Q_OBJECT
43 public:
46 
47 protected:
52 
53  // action categories
61  // internal, current toolbar to be edited (only when customizing)
64 
65 public:
66  static void init();
67  static void done();
68  static KviActionManager * instance() { return m_pInstance; };
69  static void loadAllAvailableActions();
70  static bool customizingToolBars() { return m_bCustomizingToolBars; };
71  static KviActionCategory * categoryIrc() { return m_pCategoryIrc; };
72  static KviActionCategory * categoryGeneric() { return m_pCategoryGeneric; };
73  static KviActionCategory * categorySettings() { return m_pCategorySettings; };
74  static KviActionCategory * categoryScripting() { return m_pCategoryScripting; };
75  static KviActionCategory * categoryGUI() { return m_pCategoryGUI; };
76  static KviActionCategory * categoryChannel() { return m_pCategoryChannel; };
77  static KviActionCategory * categoryTools() { return m_pCategoryTools; };
78 
80  KviActionCategory * category(const QString & szName);
82 
83  void killAllKvsUserActions();
84 
85  static KviCustomToolBar * currentToolBar() { return m_pCurrentToolBar; };
86  KviAction * getAction(const QString & szName);
87  void listActionsByCategory(const QString & szCatName, KviPointerList<KviAction> * pBuffer);
88  QString nameForAutomaticAction(const QString & szTemplate);
89  bool coreActionExists(const QString & szName);
90 
91  void load(const QString & szFileName);
92  void save(const QString & szFileName);
93 
94  bool registerAction(KviAction * a);
95  bool unregisterAction(const QString & szName);
96 
97  void emitRemoveActionsHintRequest();
98 
99 protected:
100  void setCurrentToolBar(KviCustomToolBar * t);
101  KviAction * findAction(const QString & szName) { return m_pActions->find(szName); };
102  void customizeToolBarsDialogCreated();
103  void customizeToolBarsDialogDestroyed();
104  void tryFindCurrentToolBar();
105  void delayedRegisterAccelerators(); // this is called ONCE by KviMainWindow, at startup
106 protected slots:
107  void actionDestroyed();
108 signals:
109  void beginCustomizeToolBars();
110  void endCustomizeToolBars();
111  void currentToolBarChanged(); // emitted only when customizing!
112  void removeActionsHintRequest(); // connected by the KviCustomToolBarDialog to flash the trashcan
113  // when the user tries to remove an action from the toolbar
114  // and it fails to drag it on the trashcan
115 };
116 
117 #define ACTION_POPUP_ITEM(__name, __popup) \
118  { \
119  KviAction * a = KviActionManager::instance()->getAction(__name); \
120  if(a) \
121  a->addToPopupMenu(__popup); \
122  }
123 
124 #endif
bool m_bCoreActionsRegistered
Definition: KviActionManager.h:63
static bool m_bCustomizingToolBars
Definition: KviActionManager.h:51
static KviActionCategory * categoryIrc()
Definition: KviActionManager.h:71
Definition: KviMainWindow.h:60
Definition: KviCustomToolBar.h:37
#define KVIRC_API
Definition: kvi_settings.h:128
static KviCustomToolBar * m_pCurrentToolBar
Definition: KviActionManager.h:62
#define a
Definition: detector.cpp:91
static KviActionCategory * categoryTools()
Definition: KviActionManager.h:77
Holds the categories of an action.
Definition: KviAction.h:54
static KviActionCategory * categoryGUI()
Definition: KviActionManager.h:75
static KviActionCategory * categoryChannel()
Definition: KviActionManager.h:76
Defines an action inside KVIrc.
Definition: KviAction.h:100
static KviActionCategory * m_pCategoryIrc
Definition: KviActionManager.h:54
static KviActionManager * m_pInstance
Definition: KviActionManager.h:48
static KviActionCategory * categorySettings()
Definition: KviActionManager.h:73
Definition: KviActionManager.h:36
Pointer Hash Table.
Action drawer class.
Definition: KviActionDrawer.h:48
static QAction * getAction(int idx)
Definition: KvsObject_popupMenu.cpp:186
void done()
Definition: KviKvs.cpp:50
static KviActionManager * instance()
Definition: KviActionManager.h:68
static KviActionCategory * categoryGeneric()
Definition: KviActionManager.h:72
static KviActionCategory * m_pCategoryGeneric
Definition: KviActionManager.h:55
KviAction * findAction(const QString &szName)
Definition: KviActionManager.h:101
bool save(KviThemeInfo &options, bool bSaveIcons)
Definition: KviOptions.cpp:986
KviPointerHashTable< QString, KviActionCategory > * m_pCategories
Definition: KviActionManager.h:50
QHashIterator< int, QFile * > t(getDict)
A template double linked list of pointers.
Definition: KviPointerList.h:55
Definition: CustomizeToolBarsDialog.h:41
static KviActionCategory * m_pCategoryGUI
Definition: KviActionManager.h:58
static KviActionCategory * m_pCategoryTools
Definition: KviActionManager.h:60
static bool customizingToolBars()
Definition: KviActionManager.h:70
Actions handling.
static KviActionCategory * m_pCategorySettings
Definition: KviActionManager.h:56
int init()
Definition: winamp.cpp:118
static KviActionCategory * categoryScripting()
Definition: KviActionManager.h:74
KviPointerHashTable< QString, KviAction > * actions()
Definition: KviActionManager.h:79
This file contains compile time settings.
static KviActionCategory * m_pCategoryChannel
Definition: KviActionManager.h:59
KviPointerHashTable< QString, KviAction > * m_pActions
Definition: KviActionManager.h:49
KviPointerHashTable< QString, KviActionCategory > * categories()
Definition: KviActionManager.h:81
static KviCustomToolBar * currentToolBar()
Definition: KviActionManager.h:85
static KviActionCategory * m_pCategoryScripting
Definition: KviActionManager.h:57