|
Krita Source Code Documentation
|
A widget to input a QKeySequence. More...
#include <kkeysequencewidget.h>
Inheritance diagram for KisKKeySequenceWidget:Public Types | |
| enum | Validation { Validate = 0 , NoValidate = 1 } |
Public Member Functions | |
| KisKKeySequenceWidget (QWidget *parent=0) | |
| ~KisKKeySequenceWidget () override | |
Properties | |
| ShortcutTypes | checkForConflictsAgainst |
| bool | modifierlessAllowed |
| bool | multiKeyShortcutsAllowed |
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 36 of file kkeysequencewidget.h.
| Enumerator | |
|---|---|
| None | No checking for conflicts. |
| LocalShortcuts | Check with local shortcuts.
|
| StandardShortcuts | Check against standard shortcuts.
|
| GlobalShortcuts | Check against global shortcuts.
|
Definition at line 84 of file kkeysequencewidget.h.
An enum about validation when setting a key sequence.
| Enumerator | |
|---|---|
| Validate | Validate key sequence. |
| NoValidate | Use key sequence without validation. |
Definition at line 60 of file kkeysequencewidget.h.
|
explicit |
Constructor.
Definition at line 203 of file kkeysequencewidget.cpp.
References captureKeySequence(), KisKKeySequenceWidgetPrivate::clearButton, clearKeySequence(), connect(), d, KisKKeySequenceWidgetPrivate::init(), KisKKeySequenceWidgetPrivate::keyButton, KisKKeySequenceWidgetPrivate::modifierlessTimeout, and KisKKeySequenceWidgetPrivate::updateShortcutDisplay().
|
override |
|
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 345 of file kkeysequencewidget.cpp.
References KisKActionCollection::actions(), KisKKeySequenceWidgetPrivate::checkActionCollections, d, KisKKeySequenceWidgetPrivate::stealActions, and KisKActionCollection::writeSettings().
|
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.
Definition at line 313 of file kkeysequencewidget.cpp.
References d, and KisKKeySequenceWidgetPrivate::startRecording().
| KisKKeySequenceWidget::ShortcutTypes KisKKeySequenceWidget::checkForConflictsAgainst | ( | ) | const |
The shortcut types we check for conflicts.
Definition at line 245 of file kkeysequencewidget.cpp.
References KisKKeySequenceWidgetPrivate::checkAgainstShortcutTypes, and d.
|
slot |
Clear the key sequence.
Definition at line 339 of file kkeysequencewidget.cpp.
References setKeySequence().
| bool KisKKeySequenceWidget::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.
Definition at line 275 of file kkeysequencewidget.cpp.
References KisKKeySequenceWidgetPrivate::conflictWithGlobalShortcuts(), KisKKeySequenceWidgetPrivate::conflictWithLocalShortcuts(), KisKKeySequenceWidgetPrivate::conflictWithStandardShortcuts(), d, and keySequence().
| bool KisKKeySequenceWidget::isModifierlessAllowed | ( | ) |
Definition at line 297 of file kkeysequencewidget.cpp.
References KisKKeySequenceWidgetPrivate::allowModifierless, and d.
| QKeySequence KisKKeySequenceWidget::keySequence | ( | ) | const |
Return the currently selected key sequence.
Definition at line 318 of file kkeysequencewidget.cpp.
References d, and KisKKeySequenceWidgetPrivate::keySequence.
|
signal |
This signal is emitted when the current key sequence has changed, be it by user input or programmatically.
| bool KisKKeySequenceWidget::multiKeyShortcutsAllowed | ( | ) | const |
Definition at line 255 of file kkeysequencewidget.cpp.
References d, and KisKKeySequenceWidgetPrivate::multiKeyShortcutsAllowed.
| void KisKKeySequenceWidget::setCheckActionCollections | ( | const QList< KisKActionCollection * > & | actionCollections | ) |
Set a list of action collections to check against for conflicting shortcut.
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.
Definition at line 307 of file kkeysequencewidget.cpp.
References KisKKeySequenceWidgetPrivate::checkActionCollections, and d.
| void KisKKeySequenceWidget::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:
If you want to do the conflict checking yourself here are some code snippets for global ...
... and standard shortcuts
Definition at line 265 of file kkeysequencewidget.cpp.
References KisKKeySequenceWidgetPrivate::checkAgainstShortcutTypes, and d.
| void KisKKeySequenceWidget::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 302 of file kkeysequencewidget.cpp.
References KisKKeySequenceWidgetPrivate::clearButton, and d.
| void KisKKeySequenceWidget::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 250 of file kkeysequencewidget.cpp.
References KisKKeySequenceWidgetPrivate::componentName, and d.
|
slot |
Set the key sequence.
If val == Validate, and the call is actually changing the key sequence, conflicting shortcut will be checked.
Definition at line 324 of file kkeysequencewidget.cpp.
References d, KisKKeySequenceWidgetPrivate::doneRecording(), KisKKeySequenceWidgetPrivate::isRecording, KisKKeySequenceWidgetPrivate::keySequence, KisKKeySequenceWidgetPrivate::oldKeySequence, and Validate.
| void KisKKeySequenceWidget::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 270 of file kkeysequencewidget.cpp.
References KisKKeySequenceWidgetPrivate::allowModifierless, and d.
| void KisKKeySequenceWidget::setMultiKeyShortcutsAllowed | ( | bool | allowed | ) |
Allow multikey shortcuts?
Definition at line 260 of file kkeysequencewidget.cpp.
References d, and KisKKeySequenceWidgetPrivate::multiKeyShortcutsAllowed.
|
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.
|
friend |
Definition at line 281 of file kkeysequencewidget.h.
|
private |
Definition at line 282 of file kkeysequencewidget.h.
|
readwrite |
Definition at line 47 of file kkeysequencewidget.h.
|
readwrite |
Definition at line 52 of file kkeysequencewidget.h.
|
readwrite |
Definition at line 42 of file kkeysequencewidget.h.