KDEUI
#include <kkeysequencewidget.h>
Public Types | |
enum | Validation { Validate = 0, NoValidate = 1 } |
Public Slots | |
void | applyStealShortcut () |
void | captureKeySequence () |
void | clearKeySequence () |
void | setKeySequence (const QKeySequence &seq, Validation val=NoValidate) |
Signals | |
void | keySequenceChanged (const QKeySequence &seq) |
void | stealShortcut (const QKeySequence &seq, KAction *action) |
Public Member Functions | |
KKeySequenceWidget (QWidget *parent=0) | |
virtual | ~KKeySequenceWidget () |
bool | isKeySequenceAvailable (const QKeySequence &seq) const |
QKeySequence | keySequence () const |
void | setCheckActionCollections (const QList< KActionCollection * > &actionCollections) |
void | setCheckActionList (const QList< QAction * > &checkList) |
void | setComponentName (const QString &componentName) |
Properties | |
ShortcutTypes | checkForConflictsAgainst |
bool | modifierlessAllowed |
bool | multiKeyShortcutsAllowed |
Configuration | |
enum | ShortcutType { None = 0x00, LocalShortcuts = 0x01, StandardShortcuts = 0x02, GlobalShortcuts = 0x03 } |
void | setCheckForConflictsAgainst (ShortcutTypes types) |
ShortcutTypes | checkForConflictsAgainst () const |
void | setMultiKeyShortcutsAllowed (bool) |
bool | multiKeyShortcutsAllowed () const |
void | setModifierlessAllowed (bool allow) |
bool | isModifierlessAllowed () |
void | setClearButtonShown (bool show) |
Detailed Description
A widget to input a QKeySequence.
This widget lets the user choose a QKeySequence, which is usually used as a shortcut key. The recording is initiated by calling captureKeySequence() or the user clicking into the widget.
The widgets provides support for conflict handling. See setCheckForConflictsAgainst() for more information.
Definition at line 51 of file kkeysequencewidget.h.
Member Enumeration Documentation
Enumerator | |
---|---|
None |
No checking for conflicts. |
LocalShortcuts |
Check with local shortcuts.
|
StandardShortcuts |
Check against standard shortcuts.
|
GlobalShortcuts |
Check against global shortcuts.
|
Definition at line 99 of file kkeysequencewidget.h.
An enum about validation when setting a key sequence.
- See also
- setKeySequence()
Enumerator | |
---|---|
Validate |
Validate key sequence. |
NoValidate |
Use key sequence without validation. |
Definition at line 75 of file kkeysequencewidget.h.
Constructor & Destructor Documentation
|
explicit |
Constructor.
Definition at line 251 of file kkeysequencewidget.cpp.
|
virtual |
Destructs the widget.
Definition at line 289 of file kkeysequencewidget.cpp.
Member Function Documentation
|
slot |
Actually remove the shortcut that the user wanted to steal, from the action that was using it.
This only applies to actions provided to us by setCheckActionCollections() and setCheckActionList().
Global and Standard Shortcuts have to be stolen immediately when the user gives his consent (technical reasons). That means those changes will be active even if you never call applyStealShortcut().
To be called before you apply your changes. No local shortcuts are stolen until this function is called.
Definition at line 398 of file kkeysequencewidget.cpp.
|
slot |
Capture a shortcut from the keyboard.
This call will only return once a key sequence has been captured or input was aborted. If a key sequence was input, keySequenceChanged() will be emitted.
- See also
- setModifierlessAllowed()
Definition at line 364 of file kkeysequencewidget.cpp.
ShortcutTypes KKeySequenceWidget::checkForConflictsAgainst | ( | ) | const |
|
slot |
Clear the key sequence.
Definition at line 392 of file kkeysequencewidget.cpp.
bool KKeySequenceWidget::isKeySequenceAvailable | ( | const QKeySequence & | seq | ) | const |
Checks whether the key sequence seq is available to grab.
The sequence is checked under the same rules as if it has been typed by the user. This method is useful if you get key sequences from another input source and want to check if it is save to set them.
- Since
- 4.2
Definition at line 329 of file kkeysequencewidget.cpp.
bool KKeySequenceWidget::isModifierlessAllowed | ( | ) |
- See also
- setModifierlessAllowed()
Definition at line 339 of file kkeysequencewidget.cpp.
QKeySequence KKeySequenceWidget::keySequence | ( | ) | const |
Return the currently selected key sequence.
Definition at line 370 of file kkeysequencewidget.cpp.
|
signal |
This signal is emitted when the current key sequence has changed, be it by user input or programmatically.
bool KKeySequenceWidget::multiKeyShortcutsAllowed | ( | ) | const |
void KKeySequenceWidget::setCheckActionCollections | ( | const QList< KActionCollection * > & | actionCollections | ) |
Set a list of action collections to check against for conflictuous shortcut.
- See also
- setCheckForConflictsAgainst()
If a KAction with a conflicting shortcut is found inside this list and its shortcut can be configured (KAction::isShortcutConfigurable() returns true) the user will be prompted whether to steal the shortcut from this action.
- Since
- 4.1
Definition at line 358 of file kkeysequencewidget.cpp.
- Deprecated:
- since 4.1 use setCheckActionCollections so that KKeySequenceWidget knows in which action collection to call the writeSettings method after stealing a shortcut from an action.
Definition at line 351 of file kkeysequencewidget.cpp.
void KKeySequenceWidget::setCheckForConflictsAgainst | ( | ShortcutTypes | types | ) |
Configure if the widget should check for conflicts with existing shortcuts.
When capturing a key sequence for local shortcuts you should check against GlobalShortcuts and your other local shortcuts. This is the default.
You have to provide the local actions to check against with setCheckActionCollections().
When capturing a key sequence for a global shortcut you should check against StandardShortcuts, GlobalShortcuts and your local shortcuts.
There are two ways to react to a user agreeing to steal a shortcut:
- Listen to the stealShortcut() signal and steal the shortcuts manually. It's your responsibility to save that change later when you think it is appropriate.
- Call applyStealShortcut and KKeySequenceWidget will steal the shortcut. This will save the actionCollections the shortcut is part of so make sure it doesn't inadvertly save some unwanted changes too. Read its documentation for some limitation when handling global shortcuts.
If you want to do the conflict checking yourself here are some code snippets for global ...
... and standard shortcuts
- Since
- 4.2
Definition at line 318 of file kkeysequencewidget.cpp.
void KKeySequenceWidget::setClearButtonShown | ( | bool | show | ) |
Set whether a small button to set an empty key sequence should be displayed next to the main input widget.
The default is to show the clear button.
Definition at line 345 of file kkeysequencewidget.cpp.
void KKeySequenceWidget::setComponentName | ( | const QString & | componentName | ) |
If the component using this widget supports shortcuts contexts, it has to set its component name so we can check conflicts correctly.
Definition at line 301 of file kkeysequencewidget.cpp.
|
slot |
Set the key sequence.
If val
== Validate, and the call is actually changing the key sequence, conflictuous shortcut will be checked.
Definition at line 377 of file kkeysequencewidget.cpp.
void KKeySequenceWidget::setModifierlessAllowed | ( | bool | allow | ) |
This only applies to user input, not to setShortcut().
Set whether to accept "plain" keys without modifiers (like Ctrl, Alt, Meta). Plain keys by our definition include letter and symbol keys and text editing keys (Return, Space, Tab, Backspace, Delete). "Special" keys like F1, Cursor keys, Insert, PageDown will always work.
Definition at line 323 of file kkeysequencewidget.cpp.
void KKeySequenceWidget::setMultiKeyShortcutsAllowed | ( | bool | allowed | ) |
Allow multikey shortcuts?
Definition at line 312 of file kkeysequencewidget.cpp.
|
signal |
This signal is emitted after the user agreed to steal a shortcut from an action.
This is only done for local shortcuts. So you can be sure action is one of the actions you provided with setCheckActionList() or setCheckActionCollections().
If you listen to that signal and don't call applyStealShortcut() you are supposed to steal the shortcut and save this change.
Property Documentation
|
readwrite |
Definition at line 65 of file kkeysequencewidget.h.
|
readwrite |
Definition at line 70 of file kkeysequencewidget.h.
|
readwrite |
Definition at line 60 of file kkeysequencewidget.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.