![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/KeyboardShortcutManager.h>
Singleton class to manage global keyboard shortcuts. More...
Inheritance diagram for KeyboardShortcutManager:Singleton class to manage global keyboard shortcuts.
Before this class can be used you must register the QMainWindow of the application using setParent() so that KeyboardShortcutManager can hook into its event loop to listen for keyboard user input.
Shortcut actions are identified using a unique ID. Register shortcuts using action() which returns an Action struct containing both an ImFusion signal and a QShortcut. You can connect to either of it in order to get notified when the shortcut has been triggered.
Example for registering an action an installing a handler for it:
Classes | |
| struct | Action |
| Small structure encapsulating a shortcut action. More... | |
Public Member Functions | |
| void | setParent (QMainWindow *mainWindow) |
| Register the window for which keyboard events are received. | |
| void | setParent (QMainWindow &mainWindow) |
| const Action & | action (const std::string &uniqueId, const std::string &description, QKeySequence defaultSequence) |
| Register a shortcut action and return the corresponding Action struct. | |
| bool | removeAction (const std::string &uniqueId) |
| Remove a registered shortcut action with the given uniqueId. Returns false if no such action was registered. | |
| void | setKeySequence (const std::string &id, const QKeySequence &key) |
| Sets an already registered action, identified by id string, to a Key sequence. | |
| void | saveMapping () |
| Saves the Action Shortcut mapping using QString. | |
| const std::map< std::string, std::unique_ptr< Action > > & | registeredActions () const |
| Return a const reference of the map list. | |
| void | clearActions () |
| Clears all registered actions. | |
Static Public Member Functions | |
| static KeyboardShortcutManager & | instance () |
| const Action & action | ( | const std::string & | uniqueId, |
| const std::string & | description, | ||
| QKeySequence | defaultSequence ) |
Register a shortcut action and return the corresponding Action struct.
If a shortcut with the same unique ID is already registered, this function will return the old shortcut Action and not update description and/or default sequence.
| uniqueId | Unique identifier for the shortcut |
| description | Human readable description of the shortcut to show in the settings UI. |
| defaultSequence | Default keyboard sequence to trigger the shortcut. |