00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __KKEYDIALOG_H__
00022 #define __KKEYDIALOG_H__
00023
00024 #include <qdict.h>
00025 #include <kdialogbase.h>
00026 #include <klistview.h>
00027
00028 class QButtonGroup;
00029 class QCheckBox;
00030 class QGroupBox;
00031 class QLabel;
00032 class QLineEdit;
00033 class QRadioButton;
00034 class KAccel;
00035 class KAccelActions;
00036 class KActionCollection;
00037 class KConfigBase;
00038 class KGlobalAccel;
00039 class KKeySequence;
00040 class KShortcut;
00041 class KShortcutList;
00042 class KKeyChooserItem;
00043
00058 class KKeyChooser : public QWidget
00059 {
00060 Q_OBJECT
00061 public:
00062 enum ActionType { Application, ApplicationGlobal, Standard, Global };
00063
00070 KKeyChooser( QWidget* parent, ActionType type = Application, bool bAllowLetterShortcuts = true );
00071 KKeyChooser( KActionCollection* coll, QWidget* parent, bool bAllowLetterShortcuts = true );
00072 KKeyChooser( KAccel* actions, QWidget* parent, bool bAllowLetterShortcuts = true );
00073 KKeyChooser( KGlobalAccel* actions, QWidget* parent );
00074 KKeyChooser( KShortcutList*, QWidget* parent, ActionType type = Application, bool bAllowLetterShortcuts = true );
00075
00076 virtual ~KKeyChooser();
00077
00082 bool insert( KActionCollection* );
00089 bool insert( KActionCollection *, const QString &title);
00090
00091 void syncToConfig( const QString& sConfigGroup, KConfigBase* pConfig, bool bClearUnset );
00092
00097 void commitChanges();
00098
00105 void save();
00106
00107 signals:
00111 void keyChange();
00112
00113 public slots:
00117 void allDefault();
00118
00124 void setPreferFourModifierKeys( bool preferFourModifierKeys );
00125
00126
00127 protected:
00128 enum { NoKey = 1, DefaultKey, CustomKey };
00129
00130 void initGUI( ActionType type, bool bAllowLetterShortcuts );
00131 bool insert( KAccel* );
00132 bool insert( KGlobalAccel* );
00133 bool insert( KShortcutList* );
00135 void buildListView( uint iList, const QString &title = QString::null );
00136
00137 void readGlobalKeys();
00138
00139 void updateButtons();
00140 void fontChange( const QFont& _font );
00141 void setShortcut( const KShortcut& cut );
00142 bool isKeyPresent( const KShortcut& cut, bool warnuser = true );
00143 bool isKeyPresentLocally( const KShortcut& cut, KKeyChooserItem* ignoreItem, const QString& warnText );
00144 void _warning( const KKeySequence& seq, QString sAction, QString sTitle );
00145
00146 protected slots:
00147 void slotNoKey();
00148 void slotDefaultKey();
00149 void slotCustomKey();
00150 void slotListItemSelected( QListViewItem *item );
00151 void capturedShortcut( const KShortcut& cut );
00152 void slotSettingsChanged( int );
00153
00154 protected:
00155 ActionType m_type;
00156 bool m_bAllowLetterShortcuts;
00157 bool m_bAllowWinKey;
00158
00159
00160 bool m_bPreferFourModifierKeys;
00161
00162 QRadioButton* m_prbNone;
00163 QRadioButton* m_prbDef;
00164 QRadioButton* m_prbCustom;
00165
00166
00167 #ifndef KDE_NO_COMPAT
00168 public:
00172 KKeyChooser( KAccel* actions, QWidget* parent,
00173 bool bCheckAgainstStdKeys,
00174 bool bAllowLetterShortcuts,
00175 bool bAllowWinKey = false );
00179 KKeyChooser( KGlobalAccel* actions, QWidget* parent,
00180 bool bCheckAgainstStdKeys,
00181 bool bAllowLetterShortcuts,
00182 bool bAllowWinKey = false );
00183
00184 public slots:
00189 void listSync();
00190
00191 #endif
00192 protected:
00193 virtual void virtual_hook( int id, void* data );
00194 private:
00195 class KKeyChooserPrivate *d;
00196 friend class KKeyDialog;
00197 };
00198 typedef KKeyChooser KKeyChooser;
00199
00216 class KKeyDialog : public KDialogBase
00217 {
00218 Q_OBJECT
00219
00220 public:
00226 KKeyDialog( bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00227
00231 virtual ~KKeyDialog();
00232
00241 bool insert( KActionCollection* );
00242
00255 bool insert(KActionCollection *, const QString &title);
00256
00257 bool configure( bool bSaveSettings = true );
00258
00264 void commitChanges();
00265
00273 static int configure( KActionCollection* coll, QWidget* parent = 0, bool bSaveSettings = true );
00274
00280 static int configure( KAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00281
00286 static int configure( KGlobalAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00287
00288
00295 static int configure( KActionCollection* coll, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00296
00301 static int configure( KAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00302
00307 static int configure( KGlobalAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00308
00313 static int configureKeys( KAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00314 { return configure( keys, parent, save_settings ); }
00319 static int configureKeys( KGlobalAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00320 { return configure( keys, parent, save_settings ); }
00325 static int configureKeys( KActionCollection* coll, const QString& ,
00326 bool save_settings = true, QWidget* parent = 0 )
00327 { return configure( coll, parent, save_settings ); }
00328
00329 private:
00330 KKeyDialog( KKeyChooser::ActionType, bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00331
00332 protected:
00333 virtual void virtual_hook( int id, void* data );
00334
00335 private:
00336 class KKeyDialogPrivate* d;
00337 KKeyChooser* m_pKeyChooser;
00338 };
00339
00340 #endif // __KKEYDIALOG_H__