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
00072 KKeyChooser( QWidget* parent, ActionType type = Application, bool bAllowLetterShortcuts = true );
00077 KKeyChooser( KActionCollection* coll, QWidget* parent, bool bAllowLetterShortcuts = true );
00078 KKeyChooser( KAccel* actions, QWidget* parent, bool bAllowLetterShortcuts = true );
00079 KKeyChooser( KGlobalAccel* actions, QWidget* parent );
00080 KKeyChooser( KShortcutList*, QWidget* parent, ActionType type = Application, bool bAllowLetterShortcuts = true );
00081
00082 virtual ~KKeyChooser();
00083
00088 bool insert( KActionCollection* );
00095 bool insert( KActionCollection *, const QString &title);
00096
00097 void syncToConfig( const QString& sConfigGroup, KConfigBase* pConfig, bool bClearUnset );
00098
00103 void commitChanges();
00104
00111 void save();
00112
00126 static bool checkGlobalShortcutsConflict( const KShortcut& cut, bool warnUser, QWidget* parent );
00127
00141 static bool checkStandardShortcutsConflict( const KShortcut& cut, bool warnUser, QWidget* parent );
00142
00143 signals:
00147 void keyChange();
00148
00149 public slots:
00153 void allDefault();
00154
00160 void setPreferFourModifierKeys( bool preferFourModifierKeys );
00161
00162
00163 protected:
00164 enum { NoKey = 1, DefaultKey, CustomKey };
00165
00166 void initGUI( ActionType type, bool bAllowLetterShortcuts );
00167 bool insert( KAccel* );
00168 bool insert( KGlobalAccel* );
00169 bool insert( KShortcutList* );
00171 void buildListView( uint iList, const QString &title = QString::null );
00172
00173 void readGlobalKeys();
00174
00175 void updateButtons();
00176 void fontChange( const QFont& _font );
00177 void setShortcut( const KShortcut& cut );
00178 bool isKeyPresent( const KShortcut& cut, bool warnuser = true );
00179 bool isKeyPresentLocally( const KShortcut& cut, KKeyChooserItem* ignoreItem, const QString& warnText );
00180 void _warning( const KKeySequence& seq, QString sAction, QString sTitle );
00181
00182 protected slots:
00183 void slotNoKey();
00184 void slotDefaultKey();
00185 void slotCustomKey();
00186 void slotListItemSelected( QListViewItem *item );
00187 void capturedShortcut( const KShortcut& cut );
00188 void slotSettingsChanged( int );
00189 void slotListItemDoubleClicked ( QListViewItem * ipoQListViewItem, const QPoint & ipoQPoint, int c );
00190
00191 protected:
00192 ActionType m_type;
00193 bool m_bAllowLetterShortcuts;
00194 bool m_bAllowWinKey;
00195
00196
00197 bool m_bPreferFourModifierKeys;
00198
00199 QRadioButton* m_prbNone;
00200 QRadioButton* m_prbDef;
00201 QRadioButton* m_prbCustom;
00202
00203 private:
00204 bool isKeyPresentLocally( const KShortcut& cut, KKeyChooserItem* ignoreItem, bool bWarnUser );
00205 static bool promptForReassign( const KKeySequence& cut, const QString& sAction, ActionType action, QWidget* parent )
00206 ;
00207 static void removeStandardShortcut( const QString& name, KKeyChooser* chooser );
00208 static void removeGlobalShortcut( const QString& name, KKeyChooser* chooser );
00209 static void readGlobalKeys( QMap< QString, KShortcut >& map );
00210 static bool checkGlobalShortcutsConflict( const KShortcut& cut, bool bWarnUser, QWidget* parent,
00211 const QMap< QString, KShortcut >& map, const QString& ignoreAction );
00212 bool resetShortcut( const QString& name );
00213
00214 private slots:
00215 void captureCurrentItem();
00216
00217 #ifndef KDE_NO_COMPAT
00218 public:
00222 KKeyChooser( KAccel* actions, QWidget* parent,
00223 bool bCheckAgainstStdKeys,
00224 bool bAllowLetterShortcuts,
00225 bool bAllowWinKey = false );
00229 KKeyChooser( KGlobalAccel* actions, QWidget* parent,
00230 bool bCheckAgainstStdKeys,
00231 bool bAllowLetterShortcuts,
00232 bool bAllowWinKey = false );
00233
00234 public slots:
00239 void listSync();
00240
00241 #endif
00242 protected:
00243 virtual void virtual_hook( int id, void* data );
00244 private:
00245 class KKeyChooserPrivate *d;
00246 friend class KKeyDialog;
00247 };
00248 typedef KKeyChooser KKeyChooser;
00249
00266 class KKeyDialog : public KDialogBase
00267 {
00268 Q_OBJECT
00269
00270 public:
00276 KKeyDialog( bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00277
00281 virtual ~KKeyDialog();
00282
00291 bool insert( KActionCollection* );
00292
00305 bool insert(KActionCollection *, const QString &title);
00306
00307 bool configure( bool bSaveSettings = true );
00308
00314 void commitChanges();
00315
00323 static int configure( KActionCollection* coll, QWidget* parent = 0, bool bSaveSettings = true );
00324
00330 static int configure( KAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00331
00336 static int configure( KGlobalAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00337
00338
00350 static int configure( KActionCollection* coll, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00351
00356 static int configure( KAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00357
00362 static int configure( KGlobalAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00363
00368 static KDE_DEPRECATED int configureKeys( KAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00369 { return configure( keys, parent, save_settings ); }
00374 static KDE_DEPRECATED int configureKeys( KGlobalAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00375 { return configure( keys, parent, save_settings ); }
00380 static KDE_DEPRECATED int configureKeys( KActionCollection* coll, const QString& ,
00381 bool save_settings = true, QWidget* parent = 0 )
00382 { return configure( coll, parent, save_settings ); }
00383
00384 private:
00385 KKeyDialog( KKeyChooser::ActionType, bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00386
00387 protected:
00388 virtual void virtual_hook( int id, void* data );
00389
00390 private:
00391 class KKeyDialogPrivate* d;
00392 KKeyChooser* m_pKeyChooser;
00393 };
00394
00395 #endif // __KKEYDIALOG_H__