kaccelbase.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _KACCELBASE_H
00021 #define _KACCELBASE_H
00022
00023 #include <qmap.h>
00024 #include <qptrvector.h>
00025 #include <qstring.h>
00026 #include <qvaluevector.h>
00027 #include <qvaluelist.h>
00028
00029 #include "kaccelaction.h"
00030 #include "kkeyserver.h"
00031
00032 class QPopupMenu;
00033 class QWidget;
00034
00035
00036
00121 class KDECORE_EXPORT KAccelBase
00122 {
00123 public:
00124 enum Init { QT_KEYS = 0x00, NATIVE_KEYS = 0x01 };
00125 enum Signal { KEYCODE_CHANGED };
00126
00127 KAccelBase( int fInitCode );
00128 virtual ~KAccelBase();
00129
00130 uint actionCount() const;
00131 KAccelActions& actions();
00132 bool isEnabled() const;
00133
00134 KAccelAction* actionPtr( const QString& sAction );
00135 const KAccelAction* actionPtr( const QString& sAction ) const;
00136 KAccelAction* actionPtr( const KKey& key );
00137 KAccelAction* actionPtr( const KKeyServer::Key& key );
00138
00139 const QString& configGroup() const { return m_sConfigGroup; }
00140 void setConfigGroup( const QString& group );
00141 void setConfigGlobal( bool global );
00142 virtual void setEnabled( bool bEnabled ) = 0;
00143 bool getAutoUpdate() { return m_bAutoUpdate; }
00144
00145 bool setAutoUpdate( bool bAuto );
00146
00147
00148
00149
00150 KAccelAction* insert( const QString& sName, const QString& sDesc );
00151 KAccelAction* insert(
00152 const QString& sAction, const QString& sDesc, const QString& sHelp,
00153 const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4,
00154 const QObject* pObjSlot, const char* psMethodSlot,
00155 bool bConfigurable = true, bool bEnabled = true );
00156 bool remove( const QString& sAction );
00157 bool setActionSlot( const QString& sAction, const QObject* pObjSlot, const char* psMethodSlot );
00158
00159 bool updateConnections();
00160
00161 bool setShortcut( const QString& sAction, const KShortcut& cut );
00162
00163
00164 bool setActionEnabled( const QString& sAction, bool bEnable );
00165
00174 void readSettings( KConfigBase* pConfig = 0 );
00175
00181 void writeSettings( KConfigBase* pConfig = 0 ) const;
00182
00183 QPopupMenu* createPopupMenu( QWidget* pParent, const KKeySequence& );
00184
00185
00186 protected:
00187 void slotRemoveAction( KAccelAction* );
00188
00189 struct X;
00190 void createKeyList( QValueVector<struct X>& rgKeys );
00191 bool insertConnection( KAccelAction* );
00192 bool removeConnection( KAccelAction* );
00193
00194 virtual bool emitSignal( Signal ) = 0;
00195 virtual bool connectKey( KAccelAction&, const KKeyServer::Key& ) = 0;
00196 virtual bool connectKey( const KKeyServer::Key& ) = 0;
00197 virtual bool disconnectKey( KAccelAction&, const KKeyServer::Key& ) = 0;
00198 virtual bool disconnectKey( const KKeyServer::Key& ) = 0;
00199
00200 protected:
00201 struct ActionInfo
00202 {
00203 KAccelAction* pAction;
00204 uint iSeq, iVariation;
00205
00206
00207 ActionInfo() { pAction = 0; iSeq = 0xffff; iVariation = 0xffff; }
00208 ActionInfo( KAccelAction* _pAction, uint _iSeq, uint _iVariation )
00209 { pAction = _pAction; iSeq = _iSeq; iVariation = _iVariation; }
00210 };
00211 typedef QMap<KKeyServer::Key, ActionInfo> KKeyToActionMap;
00212
00213 KAccelActions m_rgActions;
00214 KKeyToActionMap m_mapKeyToAction;
00215 QValueList<KAccelAction*> m_rgActionsNonUnique;
00216 bool m_bNativeKeys;
00217 bool m_bEnabled;
00218 bool m_bConfigIsGlobal;
00219 QString m_sConfigGroup;
00220 bool m_bAutoUpdate;
00221 KAccelAction* mtemp_pActionRemoving;
00222
00223 private:
00224 KAccelBase& operator =( const KAccelBase& );
00225
00226 friend class KAccelActions;
00227 };
00228
00229 #endif // _KACCELBASE_H
This file is part of the documentation for kdecore Library Version 3.4.1.