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 KDEUI_EXPORT 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 );
00080 KKeyChooser(
KActionCollection* coll,
QWidget* parent,
bool bAllowLetterShortcuts =
true );
00081
00082 KKeyChooser(
KAccel* actions,
QWidget* parent,
bool bAllowLetterShortcuts =
true );
00083 KKeyChooser(
KGlobalAccel* actions,
QWidget* parent );
00084 KKeyChooser(
KShortcutList*,
QWidget* parent, ActionType type = Application,
bool bAllowLetterShortcuts =
true );
00085
00086
virtual ~KKeyChooser();
00087
00092
bool insert(
KActionCollection* );
00099
bool insert(
KActionCollection *,
const QString &title);
00100
00101
void syncToConfig(
const QString& sConfigGroup,
KConfigBase* pConfig,
bool bClearUnset );
00102
00107
void commitChanges();
00108
00115
void save();
00116
00130
static bool checkGlobalShortcutsConflict(
const KShortcut& cut,
bool warnUser,
QWidget* parent );
00131
00145
static bool checkStandardShortcutsConflict(
const KShortcut& cut,
bool warnUser,
QWidget* 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(
KAccel* );
00172
bool insert(
KGlobalAccel* );
00173
bool insert(
KShortcutList* );
00175
void buildListView( uint iList,
const QString &title = QString::null );
00176
00177
void readGlobalKeys();
00178
00179
void updateButtons();
00180
void fontChange(
const QFont& _font );
00181
void setShortcut(
const KShortcut& cut );
00182
bool isKeyPresent(
const KShortcut& cut,
bool warnuser =
true );
00183
bool isKeyPresentLocally(
const KShortcut& cut, KKeyChooserItem* ignoreItem,
const QString& warnText );
00184
void _warning(
const KKeySequence& seq,
QString sAction,
QString sTitle );
00185
00186
protected slots:
00187
void slotNoKey();
00188
void slotDefaultKey();
00189
void slotCustomKey();
00190
void slotListItemSelected(
QListViewItem *item );
00191
void capturedShortcut(
const KShortcut& cut );
00192
void slotSettingsChanged(
int );
00193
void slotListItemDoubleClicked (
QListViewItem * ipoQListViewItem,
const QPoint & 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
QRadioButton* m_prbNone;
00204
QRadioButton* m_prbDef;
00205
QRadioButton* m_prbCustom;
00206
00207
private:
00208
bool isKeyPresentLocally(
const KShortcut& cut, KKeyChooserItem* ignoreItem,
bool bWarnUser );
00209
static bool promptForReassign(
const KKeySequence& cut,
const QString& sAction, ActionType action,
QWidget* parent );
00210
00211
00212
static void removeStandardShortcut(
const QString& name, KKeyChooser* chooser,
const KShortcut &origCut,
const KShortcut &cut );
00213
00214
00215
static void removeGlobalShortcut(
const QString& name, KKeyChooser* chooser,
const KShortcut &origCut,
const KShortcut &cut );
00216
static void readGlobalKeys(
QMap< QString, KShortcut >& map );
00217
static bool checkGlobalShortcutsConflict(
const KShortcut& cut,
bool bWarnUser,
QWidget* parent,
00218
const QMap< QString, KShortcut >& map,
const QString& ignoreAction );
00219
00220
bool removeShortcut(
const QString& name,
const KShortcut &cut );
00221
00222
private slots:
00223
void captureCurrentItem();
00224
00225
#ifndef KDE_NO_COMPAT
00226
public:
00230 KKeyChooser(
KAccel* actions,
QWidget* parent,
00231
bool bCheckAgainstStdKeys,
00232
bool bAllowLetterShortcuts,
00233
bool bAllowWinKey =
false );
00237 KKeyChooser(
KGlobalAccel* actions,
QWidget* 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 KDEUI_EXPORT KKeyDialog :
public KDialogBase
00275 {
00276 Q_OBJECT
00277
00278
public:
00284 KKeyDialog(
bool bAllowLetterShortcuts =
true,
QWidget* parent = 0,
const char* name = 0 );
00285
00289
virtual ~KKeyDialog();
00290
00299
bool insert(
KActionCollection* );
00300
00313
bool insert(
KActionCollection *,
const QString &title);
00314
00315
bool configure(
bool bSaveSettings =
true );
00316
00322
void commitChanges();
00323
00331
static int configure(
KActionCollection* coll,
QWidget* parent = 0,
bool bSaveSettings =
true );
00332
00338
static int configure(
KAccel* keys,
QWidget* parent = 0,
bool bSaveSettings =
true );
00339
00344
static int configure(
KGlobalAccel* keys,
QWidget* parent = 0,
bool bSaveSettings =
true );
00345
00346
00358
static int configure(
KActionCollection* coll,
bool bAllowLetterShortcuts,
QWidget* parent = 0,
bool bSaveSettings =
true );
00359
00364
static int configure(
KAccel* keys,
bool bAllowLetterShortcuts,
QWidget* parent = 0,
bool bSaveSettings =
true );
00365
00370
static int configure(
KGlobalAccel* keys,
bool bAllowLetterShortcuts,
QWidget* parent = 0,
bool bSaveSettings =
true );
00371
00376 static KDE_DEPRECATED
int configureKeys(
KAccel* keys,
bool save_settings =
true,
QWidget* parent = 0 )
00377 {
return configure( keys, parent, save_settings ); }
00382 static KDE_DEPRECATED
int configureKeys(
KGlobalAccel* keys,
bool save_settings =
true,
QWidget* parent = 0 )
00383 {
return configure( keys, parent, save_settings ); }
00388 static KDE_DEPRECATED
int configureKeys(
KActionCollection* coll,
const QString& ,
00389
bool save_settings =
true,
QWidget* parent = 0 )
00390 {
return configure( coll, parent, save_settings ); }
00391
00392
private:
00393 KKeyDialog( KKeyChooser::ActionType,
bool bAllowLetterShortcuts =
true,
QWidget* parent = 0,
const char* name = 0 );
00394
00395
protected:
00396
virtual void virtual_hook(
int id,
void* data );
00397
00398
private:
00399
class KKeyDialogPrivate* d;
00400 KKeyChooser* m_pKeyChooser;
00401 };
00402
00403
#endif // __KKEYDIALOG_H__