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 static void removeStandardShortcut( const QString& name, KKeyChooser* chooser );
00207 static void removeGlobalShortcut( const QString& name, KKeyChooser* chooser );
00208 static void readGlobalKeys( QMap< QString, KShortcut >& map );
00209 static bool checkGlobalShortcutsConflict( const KShortcut& cut, bool bWarnUser, QWidget* parent,
00210 const QMap< QString, KShortcut >& map, const QString& ignoreAction );
00211 bool resetShortcut( const QString& name );
00212
00213 private slots:
00214 void captureCurrentItem();
00215
00216 #ifndef KDE_NO_COMPAT
00217 public:
00221 KKeyChooser( KAccel* actions, QWidget* parent,
00222 bool bCheckAgainstStdKeys,
00223 bool bAllowLetterShortcuts,
00224 bool bAllowWinKey = false );
00228 KKeyChooser( KGlobalAccel* actions, QWidget* parent,
00229 bool bCheckAgainstStdKeys,
00230 bool bAllowLetterShortcuts,
00231 bool bAllowWinKey = false );
00232
00233 public slots:
00238 void listSync();
00239
00240 #endif
00241 protected:
00242 virtual void virtual_hook( int id, void* data );
00243 private:
00244 class KKeyChooserPrivate *d;
00245 friend class KKeyDialog;
00246 };
00247 typedef KKeyChooser KKeyChooser;
00248
00265 class KKeyDialog : public KDialogBase
00266 {
00267 Q_OBJECT
00268
00269 public:
00275 KKeyDialog( bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00276
00280 virtual ~KKeyDialog();
00281
00290 bool insert( KActionCollection* );
00291
00304 bool insert(KActionCollection *, const QString &title);
00305
00306 bool configure( bool bSaveSettings = true );
00307
00313 void commitChanges();
00314
00322 static int configure( KActionCollection* coll, QWidget* parent = 0, bool bSaveSettings = true );
00323
00329 static int configure( KAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00330
00335 static int configure( KGlobalAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00336
00337
00349 static int configure( KActionCollection* coll, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00350
00355 static int configure( KAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00356
00361 static int configure( KGlobalAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00362
00367 static KDE_DEPRECATED int configureKeys( KAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00368 { return configure( keys, parent, save_settings ); }
00373 static KDE_DEPRECATED int configureKeys( KGlobalAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00374 { return configure( keys, parent, save_settings ); }
00379 static KDE_DEPRECATED int configureKeys( KActionCollection* coll, const QString& ,
00380 bool save_settings = true, QWidget* parent = 0 )
00381 { return configure( coll, parent, save_settings ); }
00382
00383 private:
00384 KKeyDialog( KKeyChooser::ActionType, bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00385
00386 protected:
00387 virtual void virtual_hook( int id, void* data );
00388
00389 private:
00390 class KKeyDialogPrivate* d;
00391 KKeyChooser* m_pKeyChooser;
00392 };
00393
00394 #endif // __KKEYDIALOG_H__