1
#ifndef _KVI_ACTIONMANAGER_H_
2
#define _KVI_ACTIONMANAGER_H_
3
//=============================================================================
5
// File : KviActionManager.h
6
// Creation date : Sun 21 Nov 2004 03:37:57 by Szymon Stefanek
8
// This file is part of the KVIrc IRC Client distribution
9
// Copyright (C) 2004-2010 Szymon Stefanek <pragma at kvirc dot net>
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 opinion) any later version.
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.
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.
25
//=============================================================================
27
#include "kvi_settings.h"
28
#include "KviAction.h"
29
#include "KviPointerHashTable.h"
33
class KviActionDrawer;
34
class KviCustomToolBar;
36
class KVIRC_API KviActionManager : public QObject
38
friend class KviActionDrawer;
39
friend class CustomizeToolBarsDialog; // this resides in a module!
40
friend class KviCustomToolBar;
41
friend class KviMainWindow;
47
static KviActionManager * m_pInstance;
48
KviPointerHashTable<QString,KviAction> * m_pActions;
49
KviPointerHashTable<QString,KviActionCategory> * m_pCategories;
50
static bool m_bCustomizingToolBars;
53
static KviActionCategory * m_pCategoryIrc;
54
static KviActionCategory * m_pCategoryGeneric;
55
static KviActionCategory * m_pCategorySettings;
56
static KviActionCategory * m_pCategoryScripting;
57
static KviActionCategory * m_pCategoryGUI;
58
static KviActionCategory * m_pCategoryChannel;
59
static KviActionCategory * m_pCategoryTools;
60
// internal, current toolbar to be edited (only when customizing)
61
static KviCustomToolBar * m_pCurrentToolBar;
62
bool m_bCoreActionsRegistered;
66
static KviActionManager * instance(){ return m_pInstance; };
67
static void loadAllAvailableActions();
68
static bool customizingToolBars(){ return m_bCustomizingToolBars; };
69
static KviActionCategory * categoryIrc(){ return m_pCategoryIrc; };
70
static KviActionCategory * categoryGeneric(){ return m_pCategoryGeneric; };
71
static KviActionCategory * categorySettings(){ return m_pCategorySettings; };
72
static KviActionCategory * categoryScripting(){ return m_pCategoryScripting; };
73
static KviActionCategory * categoryGUI(){ return m_pCategoryGUI; };
74
static KviActionCategory * categoryChannel(){ return m_pCategoryChannel; };
75
static KviActionCategory * categoryTools(){ return m_pCategoryTools; };
77
KviPointerHashTable<QString,KviAction> * actions(){ return m_pActions; };
78
KviActionCategory * category(const QString &szName);
79
KviPointerHashTable<QString,KviActionCategory> * categories(){ return m_pCategories; };
81
void killAllKvsUserActions();
83
static KviCustomToolBar * currentToolBar(){ return m_pCurrentToolBar; };
84
KviAction * getAction(const QString &szName);
85
void listActionsByCategory(const QString &szCatName,KviPointerList<KviAction> * pBuffer);
86
QString nameForAutomaticAction(const QString &szTemplate);
87
bool coreActionExists(const QString &szName);
89
void load(const QString &szFileName);
90
void save(const QString &szFileName);
92
bool registerAction(KviAction * a);
93
bool unregisterAction(const QString &szName);
95
void emitRemoveActionsHintRequest();
97
void setCurrentToolBar(KviCustomToolBar * t);
98
KviAction * findAction(const QString &szName){ return m_pActions->find(szName); };
99
void customizeToolBarsDialogCreated();
100
void customizeToolBarsDialogDestroyed();
101
void tryFindCurrentToolBar();
102
void delayedRegisterAccelerators(); // this is called ONCE by KviMainWindow, at startup
104
void actionDestroyed();
106
void beginCustomizeToolBars();
107
void endCustomizeToolBars();
108
void currentToolBarChanged(); // emitted only when customizing!
109
void removeActionsHintRequest(); // connected by the KviCustomToolBarDialog to flash the trashcan
110
// when the user tries to remove an action from the toolbar
111
// and it fails to drag it on the trashcan
114
#define ACTION_POPUP_ITEM(__name,__popup) \
115
{ KviAction * a = KviActionManager::instance()->getAction(__name); if(a)a->addToPopupMenu(__popup); }
118
#endif //!_KVI_ACTIONMANAGER_H_