![]() |
QElectroTech 0.200.1-dev
|
The ShortcutManager class App-wide registry of every rebindable shortcut, carried by either a QAction or a QAbstractButton – both declare an identical "shortcut" Q_PROPERTY of type QKeySequence, which this class targets generically via QObject so it doesn't need a separate code path for the handful of QAbstractButton-based shortcuts (e.g. a QPushButton acting as a shortcut- only trigger). More...
#include <shortcutmanager.h>

Classes | |
| struct | ShortcutInfo |
| struct | Entry |
Public Member Functions | |
| void | registerAction (QObject *target, const QString &id, const QString &category, const QKeySequence &default_sequence) |
| ShortcutManager::registerAction Register target under id, applying the user's saved override (if any) or default_sequence otherwise. target must be a QAction or a QAbstractButton – both declare a "shortcut" QKeySequence property, which is what's actually read/written here, so this works for either without a separate code path. Safe to call once per instance that shares this id (e.g. once per open window of the same kind) – the first call to reach a given id fixes its category, description (taken from the target's current "text" property) and default sequence for the lifetime of the application; later calls just register another live target to update. | |
| QList< ShortcutInfo > | allShortcuts () const |
| QKeySequence | currentSequence (const QString &id) const |
| void | setSequence (const QString &id, const QKeySequence &sequence) |
| ShortcutManager::setSequence Persist sequence as the binding for id and apply it immediately to every currently live QAction registered under that id. Persisted as "no
override" when sequence matches the id's default, so a future QET version raising that default takes effect for users who never customized it. | |
| void | resetToDefault (const QString &id) |
| void | resetAllToDefaults () |
Static Public Member Functions | |
| static ShortcutManager & | instance () |
Private Member Functions | |
| ShortcutManager ()=default | |
| ShortcutManager (const ShortcutManager &)=delete | |
| void | operator= (const ShortcutManager &)=delete |
| QKeySequence | savedSequence (const QString &id, const QKeySequence &default_sequence) const |
| ShortcutManager::savedSequence. | |
Private Attributes | |
| QHash< QString, Entry > | m_entries |
| QStringList | m_order |
The ShortcutManager class App-wide registry of every rebindable shortcut, carried by either a QAction or a QAbstractButton – both declare an identical "shortcut" Q_PROPERTY of type QKeySequence, which this class targets generically via QObject so it doesn't need a separate code path for the handful of QAbstractButton-based shortcuts (e.g. a QPushButton acting as a shortcut- only trigger).
Every place in the code that used to call setShortcut() directly now calls registerAction() instead, giving each shortcut a stable string id, a category (for grouping in the UI) and a hardcoded default sequence. registerAction() applies the user's saved override for that id (if any), falling back to the default, and remembers the target so the Shortcuts configuration page can list, edit and persist it.
Several targets can share the same id at once, since QET allows several windows of the same kind (diagram editor, element editor...) to be open simultaneously, each with its own QAction. setSequence() updates every live target for a given id in one call.
|
privatedefault |

|
privatedelete |

| QList< ShortcutManager::ShortcutInfo > ShortcutManager::allShortcuts | ( | ) | const |


| QKeySequence ShortcutManager::currentSequence | ( | const QString & | id | ) | const |

|
static |


|
privatedelete |

| void ShortcutManager::registerAction | ( | QObject * | target, |
| const QString & | id, | ||
| const QString & | category, | ||
| const QKeySequence & | default_sequence ) |
ShortcutManager::registerAction Register target under id, applying the user's saved override (if any) or default_sequence otherwise. target must be a QAction or a QAbstractButton – both declare a "shortcut" QKeySequence property, which is what's actually read/written here, so this works for either without a separate code path. Safe to call once per instance that shares this id (e.g. once per open window of the same kind) – the first call to reach a given id fixes its category, description (taken from the target's current "text" property) and default sequence for the lifetime of the application; later calls just register another live target to update.


| void ShortcutManager::resetAllToDefaults | ( | ) |

| void ShortcutManager::resetToDefault | ( | const QString & | id | ) |


|
private |
ShortcutManager::savedSequence.
| id | |
| default_sequence |

| void ShortcutManager::setSequence | ( | const QString & | id, |
| const QKeySequence & | sequence ) |
ShortcutManager::setSequence Persist sequence as the binding for id and apply it immediately to every currently live QAction registered under that id. Persisted as "no override" when sequence matches the id's default, so a future QET version raising that default takes effect for users who never customized it.

|
private |
|
private |