kaccelbase.h00001
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:
00125 enum Init { QT_KEYS = 0x00, NATIVE_KEYS = 0x01 };
00126
00128 enum Signal { KEYCODE_CHANGED };
00129
00133 KAccelBase( int fInitCode );
00134 virtual ~KAccelBase();
00135
00137 uint actionCount() const;
00139 KAccelActions& actions();
00141 bool isEnabled() const;
00142
00144 KAccelAction* actionPtr( const QString& sAction );
00146 const KAccelAction* actionPtr( const QString& sAction ) const;
00154 KAccelAction* actionPtr( const KKey& key );
00158 KAccelAction* actionPtr( const KKeyServer::Key& key );
00159
00163 const QString& configGroup() const { return m_sConfigGroup; }
00167 void setConfigGroup( const QString& group );
00168 void setConfigGlobal( bool global );
00169 virtual void setEnabled( bool bEnabled ) = 0;
00171 bool getAutoUpdate() { return m_bAutoUpdate; }
00175 bool setAutoUpdate( bool bAuto );
00176
00177
00178
00179
00180 KAccelAction* insert( const QString& sName, const QString& sDesc );
00181 KAccelAction* insert(
00182 const QString& sAction, const QString& sDesc, const QString& sHelp,
00183 const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4,
00184 const QObject* pObjSlot, const char* psMethodSlot,
00185 bool bConfigurable = true, bool bEnabled = true );
00186 bool remove( const QString& sAction );
00187 bool setActionSlot( const QString& sAction, const QObject* pObjSlot, const char* psMethodSlot );
00188
00189 bool updateConnections();
00190
00191 bool setShortcut( const QString& sAction, const KShortcut& cut );
00192
00193
00194 bool setActionEnabled( const QString& sAction, bool bEnable );
00195
00204 void readSettings( KConfigBase* pConfig = 0 );
00205
00211 void writeSettings( KConfigBase* pConfig = 0 ) const;
00212
00213 QPopupMenu* createPopupMenu( QWidget* pParent, const KKeySequence& );
00214
00215
00216 protected:
00217 void slotRemoveAction( KAccelAction* );
00218
00219 struct X;
00220 void createKeyList( QValueVector<struct X>& rgKeys );
00221 bool insertConnection( KAccelAction* );
00222 bool removeConnection( KAccelAction* );
00223
00224 virtual bool emitSignal( Signal ) = 0;
00225 virtual bool connectKey( KAccelAction&, const KKeyServer::Key& ) = 0;
00226 virtual bool connectKey( const KKeyServer::Key& ) = 0;
00227 virtual bool disconnectKey( KAccelAction&, const KKeyServer::Key& ) = 0;
00228 virtual bool disconnectKey( const KKeyServer::Key& ) = 0;
00229
00230 protected:
00231 virtual bool isEnabledInternal() const;
00232 struct ActionInfo
00233 {
00234 KAccelAction* pAction;
00235 uint iSeq, iVariation;
00236
00237
00238 ActionInfo() { pAction = 0; iSeq = 0xffff; iVariation = 0xffff; }
00239 ActionInfo( KAccelAction* _pAction, uint _iSeq, uint _iVariation )
00240 { pAction = _pAction; iSeq = _iSeq; iVariation = _iVariation; }
00241 };
00242 typedef QMap<KKeyServer::Key, ActionInfo> KKeyToActionMap;
00243
00244 KAccelActions m_rgActions;
00245 KKeyToActionMap m_mapKeyToAction;
00246 QValueList<KAccelAction*> m_rgActionsNonUnique;
00247 bool m_bNativeKeys;
00248 bool m_bEnabled;
00249 bool m_bConfigIsGlobal;
00250 QString m_sConfigGroup;
00251 bool m_bAutoUpdate;
00252 KAccelAction* mtemp_pActionRemoving;
00253
00254 private:
00255 KAccelBase& operator =( const KAccelBase& );
00256
00257 friend class KAccelActions;
00258 };
00259
00260 #endif // _KACCELBASE_H
|