KVIrc 5.2.6
Developer APIs
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
33class KviActionDrawer;
35
36class 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
43public:
46
47protected:
52
53 // action categories
61 // internal, current toolbar to be edited (only when customizing)
63 bool m_bCoreActionsRegistered = false;
64
65public:
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
99protected:
100 void setCurrentToolBar(KviCustomToolBar * t);
101 KviAction * findAction(const QString & szName) { return m_pActions->find(szName); }
102 void customizeToolBarsDialogCreated();
103 void customizeToolBarsDialogDestroyed();
105 void delayedRegisterAccelerators(); // this is called ONCE by KviMainWindow, at startup
106protected slots:
107 void actionDestroyed();
108signals:
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
Actions handling.
Pointer Hash Table.
static QAction * getAction(int idx)
Definition KvsObject_popupMenu.cpp:186
Definition CustomizeToolBarsDialog.h:42
Holds the categories of an action.
Definition KviAction.h:59
Action drawer class.
Definition KviActionDrawer.h:49
Definition KviActionManager.h:37
static KviActionCategory * categoryGUI()
Definition KviActionManager.h:75
static KviCustomToolBar * m_pCurrentToolBar
Definition KviActionManager.h:62
static KviActionCategory * categorySettings()
Definition KviActionManager.h:73
void currentToolBarChanged()
KviPointerHashTable< QString, KviAction > * actions()
Definition KviActionManager.h:79
static KviActionCategory * m_pCategoryTools
Definition KviActionManager.h:60
void removeActionsHintRequest()
KviAction * findAction(const QString &szName)
Definition KviActionManager.h:101
static KviActionCategory * categoryChannel()
Definition KviActionManager.h:76
static KviActionCategory * m_pCategoryGeneric
Definition KviActionManager.h:55
static bool m_bCustomizingToolBars
Definition KviActionManager.h:51
static KviActionCategory * m_pCategoryIrc
Definition KviActionManager.h:54
static KviActionCategory * m_pCategoryScripting
Definition KviActionManager.h:57
void beginCustomizeToolBars()
static KviActionCategory * m_pCategoryChannel
Definition KviActionManager.h:59
KviPointerHashTable< QString, KviActionCategory > * categories()
Definition KviActionManager.h:81
static KviActionCategory * categoryGeneric()
Definition KviActionManager.h:72
static bool customizingToolBars()
Definition KviActionManager.h:70
static KviActionCategory * m_pCategorySettings
Definition KviActionManager.h:56
static KviActionCategory * categoryIrc()
Definition KviActionManager.h:71
void endCustomizeToolBars()
static KviActionCategory * categoryScripting()
Definition KviActionManager.h:74
static KviActionManager * instance()
Definition KviActionManager.h:68
static KviActionCategory * categoryTools()
Definition KviActionManager.h:77
void tryFindCurrentToolBar()
static KviCustomToolBar * currentToolBar()
Definition KviActionManager.h:85
static KviActionManager * m_pInstance
Definition KviActionManager.h:48
static KviActionCategory * m_pCategoryGUI
Definition KviActionManager.h:58
Defines an action inside KVIrc.
Definition KviAction.h:105
Definition KviCustomToolBar.h:38
Definition KviMainWindow.h:58
A fast pointer hash table implementation.
Definition KviPointerHashTable.h:450
T * find(const Key &hKey)
Returns the item associated to the key.
Definition KviPointerHashTable.h:471
A template double linked list of pointers.
Definition KviPointerList.h:371
#define t
Definition detector.cpp:85
#define a
Definition detector.cpp:92
This file contains compile time settings.
#define KVIRC_API
Definition kvi_settings.h:127
int init()
Definition winamp.cpp:118