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 void slotListItemDoubleClicked ( QListViewItem * ipoQListViewItem, const QPoint & ipoQPoint, int c );
00154
00155 protected:
00156 ActionType m_type;
00157 bool m_bAllowLetterShortcuts;
00158 bool m_bAllowWinKey;
00159
00160
00161 bool m_bPreferFourModifierKeys;
00162
00163 QRadioButton* m_prbNone;
00164 QRadioButton* m_prbDef;
00165 QRadioButton* m_prbCustom;
00166
00167
00168 #ifndef KDE_NO_COMPAT
00169 public:
00173 KKeyChooser( KAccel* actions, QWidget* parent,
00174 bool bCheckAgainstStdKeys,
00175 bool bAllowLetterShortcuts,
00176 bool bAllowWinKey = false );
00180 KKeyChooser( KGlobalAccel* actions, QWidget* parent,
00181 bool bCheckAgainstStdKeys,
00182 bool bAllowLetterShortcuts,
00183 bool bAllowWinKey = false );
00184
00185 public slots:
00190 void listSync();
00191
00192 #endif
00193 protected:
00194 virtual void virtual_hook( int id, void* data );
00195 private:
00196 class KKeyChooserPrivate *d;
00197 friend class KKeyDialog;
00198 };
00199 typedef KKeyChooser KKeyChooser;
00200
00217 class KKeyDialog : public KDialogBase
00218 {
00219 Q_OBJECT
00220
00221 public:
00227 KKeyDialog( bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00228
00232 virtual ~KKeyDialog();
00233
00242 bool insert( KActionCollection* );
00243
00256 bool insert(KActionCollection *, const QString &title);
00257
00258 bool configure( bool bSaveSettings = true );
00259
00265 void commitChanges();
00266
00274 static int configure( KActionCollection* coll, QWidget* parent = 0, bool bSaveSettings = true );
00275
00281 static int configure( KAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00282
00287 static int configure( KGlobalAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00288
00289
00296 static int configure( KActionCollection* coll, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00297
00302 static int configure( KAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00303
00308 static int configure( KGlobalAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true );
00309
00314 static int configureKeys( KAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00315 { return configure( keys, parent, save_settings ); }
00320 static int configureKeys( KGlobalAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00321 { return configure( keys, parent, save_settings ); }
00326 static int configureKeys( KActionCollection* coll, const QString& ,
00327 bool save_settings = true, QWidget* parent = 0 )
00328 { return configure( coll, parent, save_settings ); }
00329
00330 private:
00331 KKeyDialog( KKeyChooser::ActionType, bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00332
00333 protected:
00334 virtual void virtual_hook( int id, void* data );
00335
00336 private:
00337 class KKeyDialogPrivate* d;
00338 KKeyChooser* m_pKeyChooser;
00339 };
00340
00341 #endif // __KKEYDIALOG_H__