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 <tqdict.h>
00025 #include <kdialogbase.h>
00026 #include <tdelistview.h>
00027
00028 class TQButtonGroup;
00029 class TQCheckBox;
00030 class TQGroupBox;
00031 class TQLabel;
00032 class TQLineEdit;
00033 class TQRadioButton;
00034 class TDEAccel;
00035 class TDEAccelActions;
00036 class TDEActionCollection;
00037 class TDEConfigBase;
00038 class TDEGlobalAccel;
00039 class KKeySequence;
00040 class TDEShortcut;
00041 class TDEShortcutList;
00042 class KKeyChooserItem;
00043
00058 class TDEUI_EXPORT KKeyChooser : public TQWidget
00059 {
00060 Q_OBJECT
00061 public:
00062 enum ActionType { Application, ApplicationGlobal, Standard, Global };
00063
00072 KKeyChooser( TQWidget* parent, ActionType type = Application, bool bAllowLetterShortcuts = true );
00080 KKeyChooser( TDEActionCollection* coll, TQWidget* parent, bool bAllowLetterShortcuts = true );
00081
00082 KKeyChooser( TDEAccel* actions, TQWidget* parent, bool bAllowLetterShortcuts = true );
00083 KKeyChooser( TDEGlobalAccel* actions, TQWidget* parent );
00084 KKeyChooser( TDEShortcutList*, TQWidget* parent, ActionType type = Application, bool bAllowLetterShortcuts = true );
00085
00086 virtual ~KKeyChooser();
00087
00092 bool insert( TDEActionCollection* );
00099 bool insert( TDEActionCollection *, const TQString &title);
00100
00101 void syncToConfig( const TQString& sConfigGroup, TDEConfigBase* pConfig, bool bClearUnset );
00102
00107 void commitChanges();
00108
00115 void save();
00116
00130 static bool checkGlobalShortcutsConflict( const TDEShortcut& cut, bool warnUser, TQWidget* parent );
00131
00145 static bool checkStandardShortcutsConflict( const TDEShortcut& cut, bool warnUser, TQWidget* parent );
00146
00147 signals:
00151 void keyChange();
00152
00153 public slots:
00157 void allDefault();
00158
00164 void setPreferFourModifierKeys( bool preferFourModifierKeys );
00165
00166
00167 protected:
00168 enum { NoKey = 1, DefaultKey, CustomKey };
00169
00170 void initGUI( ActionType type, bool bAllowLetterShortcuts );
00171 bool insert( TDEAccel* );
00172 bool insert( TDEGlobalAccel* );
00173 bool insert( TDEShortcutList* );
00175 void buildListView( uint iList, const TQString &title = TQString::null );
00176
00177 void readGlobalKeys();
00178
00179 void updateButtons();
00180 void fontChange( const TQFont& _font );
00181 void setShortcut( const TDEShortcut& cut );
00182 bool isKeyPresent( const TDEShortcut& cut, bool warnuser = true );
00183 bool isKeyPresentLocally( const TDEShortcut& cut, KKeyChooserItem* ignoreItem, const TQString& warnText );
00184 void _warning( const KKeySequence& seq, TQString sAction, TQString sTitle );
00185
00186 protected slots:
00187 void slotNoKey();
00188 void slotDefaultKey();
00189 void slotCustomKey();
00190 void slotListItemSelected( TQListViewItem *item );
00191 void capturedShortcut( const TDEShortcut& cut );
00192 void slotSettingsChanged( int );
00193 void slotListItemDoubleClicked ( TQListViewItem * ipoQListViewItem, const TQPoint & ipoQPoint, int c );
00194
00195 protected:
00196 ActionType m_type;
00197 bool m_bAllowLetterShortcuts;
00198 bool m_bAllowWinKey;
00199
00200
00201 bool m_bPreferFourModifierKeys;
00202
00203 TQRadioButton* m_prbNone;
00204 TQRadioButton* m_prbDef;
00205 TQRadioButton* m_prbCustom;
00206
00207 private:
00208 bool isKeyPresentLocally( const TDEShortcut& cut, KKeyChooserItem* ignoreItem, bool bWarnUser );
00209 static bool promptForReassign( const KKeySequence& cut, const TQString& sAction, ActionType action, TQWidget* parent );
00210
00211
00212 static void removeStandardShortcut( const TQString& name, KKeyChooser* chooser, const TDEShortcut &origCut, const TDEShortcut &cut );
00213
00214
00215 static void removeGlobalShortcut( const TQString& name, KKeyChooser* chooser, const TDEShortcut &origCut, const TDEShortcut &cut );
00216 static void readGlobalKeys( TQMap< TQString, TDEShortcut >& map );
00217 static bool checkGlobalShortcutsConflict( const TDEShortcut& cut, bool bWarnUser, TQWidget* parent,
00218 const TQMap< TQString, TDEShortcut >& map, const TQString& ignoreAction );
00219
00220 bool removeShortcut( const TQString& name, const TDEShortcut &cut );
00221
00222 private slots:
00223 void captureCurrentItem();
00224
00225 #ifndef KDE_NO_COMPAT
00226 public:
00230 KKeyChooser( TDEAccel* actions, TQWidget* parent,
00231 bool bCheckAgainstStdKeys,
00232 bool bAllowLetterShortcuts,
00233 bool bAllowWinKey = false );
00237 KKeyChooser( TDEGlobalAccel* actions, TQWidget* parent,
00238 bool bCheckAgainstStdKeys,
00239 bool bAllowLetterShortcuts,
00240 bool bAllowWinKey = false );
00241
00242 public slots:
00247 void listSync();
00248
00249 #endif
00250 protected:
00251 virtual void virtual_hook( int id, void* data );
00252 private:
00253 class KKeyChooserPrivate *d;
00254 friend class KKeyDialog;
00255 };
00256 typedef KKeyChooser KKeyChooser;
00257
00274 class TDEUI_EXPORT KKeyDialog : public KDialogBase
00275 {
00276 Q_OBJECT
00277
00278 public:
00284 KKeyDialog( bool bAllowLetterShortcuts = true, TQWidget* parent = 0, const char* name = 0 );
00285
00289 virtual ~KKeyDialog();
00290
00299 bool insert( TDEActionCollection* );
00300
00313 bool insert(TDEActionCollection *, const TQString &title);
00314
00319 bool configure( bool bSaveSettings = true );
00320
00326 void commitChanges();
00327
00335 static int configure( TDEActionCollection* coll, TQWidget* parent = 0, bool bSaveSettings = true );
00336
00342 static int configure( TDEAccel* keys, TQWidget* parent = 0, bool bSaveSettings = true );
00343
00348 static int configure( TDEGlobalAccel* keys, TQWidget* parent = 0, bool bSaveSettings = true );
00349
00350
00362 static int configure( TDEActionCollection* coll, bool bAllowLetterShortcuts, TQWidget* parent = 0, bool bSaveSettings = true );
00363
00368 static int configure( TDEAccel* keys, bool bAllowLetterShortcuts, TQWidget* parent = 0, bool bSaveSettings = true );
00369
00374 static int configure( TDEGlobalAccel* keys, bool bAllowLetterShortcuts, TQWidget* parent = 0, bool bSaveSettings = true );
00375
00380 static KDE_DEPRECATED int configureKeys( TDEAccel* keys, bool save_settings = true, TQWidget* parent = 0 )
00381 { return configure( keys, parent, save_settings ); }
00386 static KDE_DEPRECATED int configureKeys( TDEGlobalAccel* keys, bool save_settings = true, TQWidget* parent = 0 )
00387 { return configure( keys, parent, save_settings ); }
00392 static KDE_DEPRECATED int configureKeys( TDEActionCollection* coll, const TQString& ,
00393 bool save_settings = true, TQWidget* parent = 0 )
00394 { return configure( coll, parent, save_settings ); }
00395
00396 private:
00397 KKeyDialog( KKeyChooser::ActionType, bool bAllowLetterShortcuts = true, TQWidget* parent = 0, const char* name = 0 );
00398
00399 protected:
00400 virtual void virtual_hook( int id, void* data );
00401
00402 private:
00403 class KKeyDialogPrivate* d;
00404 KKeyChooser* m_pKeyChooser;
00405 };
00406
00407 #endif // __KKEYDIALOG_H__