![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Manage an action and/or widget's responsivity to a shortcut. More...
#include <ecvModalShortcut.h>


Public Types | |
| using | Superclass = QObject |
Signals | |
| void | enabled () |
| void | disabled () |
| void | unregister () |
| void | activated () |
Public Member Functions | |
| ~ecvModalShortcut () override | |
| void | setContextWidget (QWidget *contextWidget, Qt::ShortcutContext contextArea=Qt::WindowShortcut) |
| bool | isEnabled () const |
| void | setEnabled (bool shouldEnable, bool changeFocus=true) |
| QKeySequence | keySequence () const |
Protected Member Functions | |
| ecvModalShortcut (const QKeySequence &key, QAction *action=nullptr, QWidget *parent=nullptr) | |
Protected Attributes | |
| QKeySequence | m_key |
| QPointer< QShortcut > | m_shortcut |
| QPointer< QAction > | m_action |
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:
Example:
Definition at line 43 of file ecvModalShortcut.h.
| using ecvModalShortcut::Superclass = QObject |
Definition at line 47 of file ecvModalShortcut.h.
|
override |
Definition at line 39 of file ecvModalShortcut.cpp.
References m_shortcut, and unregister().
|
protected |
Constructor (protected - use ecvKeySequences::addModalShortcut()).
Definition at line 18 of file ecvModalShortcut.cpp.
References activated(), m_action, and m_shortcut.
|
signal |
Invoked when the key sequence is pressed.
Referenced by cvPointPickingHelper::cvPointPickingHelper(), ecvModalShortcut(), and setContextWidget().
|
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.
Referenced by ecvShortcutDecorator::addShortcut(), and setEnabled().
|
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.
Referenced by ecvKeySequences::addModalShortcut(), ecvShortcutDecorator::addShortcut(), setContextWidget(), and setEnabled().
| bool ecvModalShortcut::isEnabled | ( | ) | const |
Check if the shortcut is currently enabled.
Definition at line 106 of file ecvModalShortcut.cpp.
References m_shortcut.
Referenced by ecvKeySequences::reorder(), and setContextWidget().
| QKeySequence ecvModalShortcut::keySequence | ( | ) | const |
Get the key sequence this shortcut responds to.
Definition at line 144 of file ecvModalShortcut.cpp.
References m_key.
Referenced by ecvShortcutDecorator::addShortcut(), and ecvKeySequences::reorder().
| 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.
| contextWidget | The widget to restrict the shortcut to |
| contextArea | The context scope (default: WindowShortcut) |
Definition at line 45 of file ecvModalShortcut.cpp.
References activated(), enabled(), isEnabled(), m_action, m_key, and m_shortcut.
| void ecvModalShortcut::setEnabled | ( | bool | shouldEnable, |
| bool | changeFocus = true |
||
| ) |
Enable or disable the shortcut.
| shouldEnable | True to enable, false to disable |
| changeFocus | If true and enabling, move focus to context widget |
Definition at line 111 of file ecvModalShortcut.cpp.
References disabled(), enabled(), and m_shortcut.
|
signal |
Called from the destructor.
This is used by ecvKeySequences to clean its records.
Referenced by ecvKeySequences::addModalShortcut(), and ~ecvModalShortcut().
|
protected |
Definition at line 123 of file ecvModalShortcut.h.
Referenced by ecvModalShortcut(), and setContextWidget().
|
protected |
Definition at line 121 of file ecvModalShortcut.h.
Referenced by keySequence(), and setContextWidget().
|
protected |
Definition at line 122 of file ecvModalShortcut.h.
Referenced by ecvModalShortcut(), isEnabled(), setContextWidget(), setEnabled(), and ~ecvModalShortcut().