00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _KACCELACTION_H
00024 #define _KACCELACTION_H
00025
00026 #include <tqmap.h>
00027 #include <tqptrvector.h>
00028 #include <tqstring.h>
00029 #include <tqvaluevector.h>
00030
00031 #include <kshortcut.h>
00032
00033 class KAccelBase;
00034
00035 class TQObject;
00036 class KConfig;
00037 class KConfigBase;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 class KAccelAction
00070 {
00071 public:
00072 KAccelAction();
00073 KAccelAction( const KAccelAction& );
00074 KAccelAction( const TQString& sName, const TQString& sLabel, const TQString& sWhatsThis,
00075 const KShortcut& cutDef3, const KShortcut& cutDef4,
00076 const TQObject* pObjSlot, const char* psMethodSlot,
00077 bool bConfigurable, bool bEnabled );
00078 ~KAccelAction();
00079
00080 void clear();
00081 bool init( const TQString& sName, const TQString& sLabel, const TQString& sWhatsThis,
00082 const KShortcut& cutDef3, const KShortcut& cutDef4,
00083 const TQObject* pObjSlot, const char* psMethodSlot,
00084 bool bConfigurable, bool bEnabled );
00085
00086 KAccelAction& operator=( const KAccelAction& );
00087
00088 const TQString& name() const { return m_sName; }
00089 const TQString& label() const { return m_sLabel; }
00090 const TQString& whatsThis() const { return m_sWhatsThis; }
00091 const KShortcut& shortcut() const { return m_cut; }
00092 const KShortcut& shortcutDefault() const;
00093 const KShortcut& shortcutDefault3() const { return m_cutDefault3; }
00094 const KShortcut& shortcutDefault4() const { return m_cutDefault4; }
00095 const TQObject* objSlotPtr() const { return m_pObjSlot; }
00096 const char* methodSlotPtr() const { return m_psMethodSlot; }
00097 bool isConfigurable() const { return m_bConfigurable; }
00098 bool isEnabled() const { return m_bEnabled; }
00099
00100 void setName( const TQString& );
00101 void setLabel( const TQString& );
00102 void setWhatsThis( const TQString& );
00103 bool setShortcut( const KShortcut& rgCuts );
00104 void setSlot( const TQObject* pObjSlot, const char* psMethodSlot );
00105 void setConfigurable( bool );
00106 void setEnabled( bool );
00107
00108 int getID() const { return m_nIDAccel; }
00109 void setID( int n ) { m_nIDAccel = n; }
00110 bool isConnected() const;
00111
00112 bool setKeySequence( uint i, const KKeySequence& );
00113 void clearShortcut();
00114 bool contains( const KKeySequence& );
00115
00116 TQString toString() const;
00117 TQString toStringInternal() const;
00118
00119 static bool useFourModifierKeys();
00120 static void useFourModifierKeys( bool );
00121
00122 protected:
00123 TQString m_sName,
00124 m_sLabel,
00125 m_sWhatsThis;
00126 KShortcut m_cut;
00127 KShortcut m_cutDefault3, m_cutDefault4;
00128 const TQObject* m_pObjSlot;
00129 const char* m_psMethodSlot;
00130 bool m_bConfigurable,
00131 m_bEnabled;
00132 int m_nIDAccel;
00133 uint m_nConnections;
00134
00135 void incConnections();
00136 void decConnections();
00137
00138 private:
00139 static int g_bUseFourModifierKeys;
00140 class KAccelActionPrivate* d;
00141
00142 friend class KAccelActions;
00143 friend class KAccelBase;
00144 };
00145
00146
00147
00148
00149
00150 class KAccelActions
00151 {
00152 public:
00153 KAccelActions();
00154 KAccelActions( const KAccelActions& );
00155 virtual ~KAccelActions();
00156
00157 void clear();
00158 bool init( const KAccelActions& );
00159 bool init( KConfigBase& config, const TQString& sGroup );
00160
00161 void updateShortcuts( KAccelActions& );
00162
00163 int actionIndex( const TQString& sAction ) const;
00164 KAccelAction* actionPtr( uint );
00165 const KAccelAction* actionPtr( uint ) const;
00166 KAccelAction* actionPtr( const TQString& sAction );
00167 const KAccelAction* actionPtr( const TQString& sAction ) const;
00168 KAccelAction* actionPtr( KKeySequence cut );
00169 KAccelAction& operator []( uint );
00170 const KAccelAction& operator []( uint ) const;
00171
00172 KAccelAction* insert( const TQString& sAction, const TQString& sLabel, const TQString& sWhatsThis,
00173 const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4,
00174 const TQObject* pObjSlot = 0, const char* psMethodSlot = 0,
00175 bool bConfigurable = true, bool bEnabled = true );
00176 KAccelAction* insert( const TQString& sName, const TQString& sLabel );
00177 bool remove( const TQString& sAction );
00178
00179 bool readActions( const TQString& sConfigGroup = "Shortcuts", KConfigBase* pConfig = 0 );
00180 bool writeActions( const TQString& sConfigGroup = "Shortcuts", KConfigBase* pConfig = 0,
00181 bool bWriteAll = false, bool bGlobal = false ) const;
00182
00183 void emitKeycodeChanged();
00184
00185 uint count() const;
00186
00187 protected:
00188 KAccelBase* m_pKAccelBase;
00189 KAccelAction** m_prgActions;
00190 uint m_nSizeAllocated, m_nSize;
00191
00192 void resize( uint );
00193 void insertPtr( KAccelAction* );
00194
00195 private:
00196 class KAccelActionsPrivate* d;
00197
00198 KAccelActions( KAccelBase* );
00199 void initPrivate( KAccelBase* );
00200 KAccelActions& operator =( KAccelActions& );
00201
00202 friend class KAccelBase;
00203 };
00204
00205 #endif // _KACCELACTION_H