Manage an action and/or widget's responsivity to a shortcut.
More...
#include <ecvModalShortcut.h>
|
| | ecvModalShortcut (const QKeySequence &key, QAction *action=nullptr, QWidget *parent=nullptr) |
| |
Manage an action and/or widget's responsivity to a shortcut.
This object will add and remove a connection between a widget/action and a QShortcut as required by the ecvKeySequences manager to prevent any ambiguous activations.
Key features:
- Automatic enable/disable based on ecvKeySequences manager
- Context-aware: can be restricted to a specific widget
- Signal emission for visual feedback
Example:
QKeySequence(Qt::Key_S), myAction, myWidget);
modalShortcut->setEnabled(true);
ecvModalShortcut(const QKeySequence &key, QAction *action=nullptr, QWidget *parent=nullptr)
Definition at line 43 of file ecvModalShortcut.h.
◆ Superclass
◆ ~ecvModalShortcut()
| ecvModalShortcut::~ecvModalShortcut |
( |
| ) |
|
|
override |
◆ ecvModalShortcut()
| ecvModalShortcut::ecvModalShortcut |
( |
const QKeySequence & |
key, |
|
|
QAction * |
action = nullptr, |
|
|
QWidget * |
parent = nullptr |
|
) |
| |
|
protected |
◆ activated
| void ecvModalShortcut::activated |
( |
| ) |
|
|
signal |
Invoked when the key sequence is pressed.
◆ disabled
| void ecvModalShortcut::disabled |
( |
| ) |
|
|
signal |
Called from setEnabled() whenever it is passed false.
This may be used by widgets to update their visual state, indicating they are no longer accepting shortcuts.
◆ enabled
| void ecvModalShortcut::enabled |
( |
| ) |
|
|
signal |
Called from setEnabled() whenever it is passed true.
This is used by ecvKeySequences to disable any sibling shortcuts with the same keysequence.
This may also be used by widgets to update their visual state, indicating they are now accepting shortcuts.
◆ isEnabled()
| bool ecvModalShortcut::isEnabled |
( |
| ) |
const |
Check if the shortcut is currently enabled.
◆ keySequence()
| QKeySequence ecvModalShortcut::keySequence |
( |
| ) |
const |
Get the key sequence this shortcut responds to.
◆ setContextWidget()
| void ecvModalShortcut::setContextWidget |
( |
QWidget * |
contextWidget, |
|
|
Qt::ShortcutContext |
contextArea = Qt::WindowShortcut |
|
) |
| |
If the shortcut should be restricted to a particular widget (such as a view), use this method to set and update the widget during the life of the ecvModalShortcut.
- Parameters
-
| contextWidget | The widget to restrict the shortcut to |
| contextArea | The context scope (default: WindowShortcut) |
◆ setEnabled()
| void ecvModalShortcut::setEnabled |
( |
bool |
shouldEnable, |
|
|
bool |
changeFocus = true |
|
) |
| |
Enable or disable the shortcut.
- Parameters
-
| shouldEnable | True to enable, false to disable |
| changeFocus | If true and enabling, move focus to context widget |
◆ unregister
| void ecvModalShortcut::unregister |
( |
| ) |
|
|
signal |
Called from the destructor.
This is used by ecvKeySequences to clean its records.
◆ m_action
| QPointer<QAction> ecvModalShortcut::m_action |
|
protected |
◆ m_key
| QKeySequence ecvModalShortcut::m_key |
|
protected |
◆ m_shortcut
| QPointer<QShortcut> ecvModalShortcut::m_shortcut |
|
protected |
The documentation for this class was generated from the following file: