00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _KACCEL_H
00021 #define _KACCEL_H
00022
00023 #include <qaccel.h>
00024 #include <kshortcut.h>
00025 #include <kstdaccel.h>
00026
00027 class QPopupMenu;
00028 class QWidget;
00029 class KAccelAction;
00030 class KAccelActions;
00031 class KConfigBase;
00032
00033 class KAccelPrivate;
00093 class KAccel : public QAccel
00094 {
00095 Q_OBJECT
00096 public:
00104 KAccel( QWidget* pParent, const char* psName = 0 );
00105
00113 KAccel( QWidget* watch, QObject* parent, const char* psName = 0 );
00114 virtual ~KAccel();
00115
00121 KAccelActions& actions();
00122
00128 const KAccelActions& actions() const;
00129
00134 bool isEnabled();
00135
00140 void setEnabled( bool bEnabled );
00141
00147 bool getAutoUpdate();
00148
00159 bool setAutoUpdate( bool bAuto );
00160
00182 KAccelAction* insert( const QString& sAction, const QString& sLabel, const QString& sWhatsThis,
00183 const KShortcut& cutDef,
00184 const QObject* pObjSlot, const char* psMethodSlot,
00185 bool bConfigurable = true, bool bEnabled = true );
00190 KAccelAction* insert( const QString& sAction, const QString& sLabel, const QString& sWhatsThis,
00191 const KShortcut& cutDef3, const KShortcut& cutDef4,
00192 const QObject* pObjSlot, const char* psMethodSlot,
00193 bool bConfigurable = true, bool bEnabled = true );
00207 KAccelAction* insert( const char* psAction, const KShortcut& cutDef,
00208 const QObject* pObjSlot, const char* psMethodSlot,
00209 bool bConfigurable = true, bool bEnabled = true );
00216 KAccelAction* insert( KStdAccel::StdAccel id,
00217 const QObject* pObjSlot, const char* psMethodSlot,
00218 bool bConfigurable = true, bool bEnabled = true );
00226 KAccelAction* insert( const QString& sName, const QString& sLabel );
00227
00234 bool remove( const QString& sAction );
00235
00244 bool updateConnections();
00245
00251 const KShortcut& shortcut( const QString& sAction ) const;
00252
00259 bool setShortcut( const QString& sAction, const KShortcut &shortcut );
00260
00269 bool setSlot( const QString& sAction, const QObject* pObjSlot, const char* psMethodSlot );
00276 bool setEnabled( const QString& sAction, bool bEnabled );
00277
00283 const QString& configGroup() const;
00284
00290 void setConfigGroup( const QString &name );
00291
00303 bool readSettings( KConfigBase* pConfig = 0 );
00312 bool writeSettings( KConfigBase* pConfig = 0 ) const;
00313
00317 void emitKeycodeChanged();
00318
00319 signals:
00323 void keycodeChanged();
00324
00325 #ifndef KDE_NO_COMPAT
00326 public:
00327
00331 bool insertItem( const QString& sLabel, const QString& sAction,
00332 const char* psKey,
00333 int nIDMenu = 0, QPopupMenu* pMenu = 0, bool bConfigurable = true );
00337 bool insertItem( const QString& sLabel, const QString& sAction,
00338 int key,
00339 int nIDMenu = 0, QPopupMenu* pMenu = 0, bool bConfigurable = true );
00343 bool insertStdItem( KStdAccel::StdAccel id, const QString& descr = QString::null );
00347 bool connectItem( const QString& sAction, const QObject* pObjSlot, const char* psMethodSlot, bool bActivate = true );
00351 bool connectItem( KStdAccel::StdAccel accel, const QObject* pObjSlot, const char* psMethodSlot )
00352 { return insert( accel, pObjSlot, psMethodSlot ); }
00356 bool removeItem( const QString& sAction );
00360 bool setItemEnabled( const QString& sAction, bool bEnable );
00364 void changeMenuAccel( QPopupMenu *menu, int id, const QString& action );
00368 void changeMenuAccel( QPopupMenu *menu, int id, KStdAccel::StdAccel accel );
00372 static int stringToKey( const QString& );
00373
00380 int currentKey( const QString& action ) const;
00381
00387 QString findKey( int key ) const;
00388 #endif // !KDE_NO_COMPAT
00389
00390 protected:
00392 virtual void virtual_hook( int id, void* data );
00393 private:
00394 class KAccelPrivate* d;
00395 friend class KAccelPrivate;
00396 };
00397
00398 #endif // _KACCEL_H