QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
ShortcutManager Class Reference

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>

Collaboration diagram for ShortcutManager:
Collaboration graph

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< ShortcutInfoallShortcuts () 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 ShortcutManagerinstance ()

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, Entrym_entries
QStringList m_order

Detailed Description

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.

Constructor & Destructor Documentation

◆ ShortcutManager() [1/2]

ShortcutManager::ShortcutManager ( )
privatedefault
Here is the caller graph for this function:

◆ ShortcutManager() [2/2]

ShortcutManager::ShortcutManager ( const ShortcutManager & )
privatedelete
Here is the call graph for this function:

Member Function Documentation

◆ allShortcuts()

QList< ShortcutManager::ShortcutInfo > ShortcutManager::allShortcuts ( ) const
Returns
every registered shortcut, in registration order, along with its currently effective sequence – for display in the Shortcuts config page.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentSequence()

QKeySequence ShortcutManager::currentSequence ( const QString & id) const
Here is the call graph for this function:

◆ instance()

ShortcutManager & ShortcutManager::instance ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

void ShortcutManager::operator= ( const ShortcutManager & )
privatedelete
Here is the call graph for this function:

◆ registerAction()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetAllToDefaults()

void ShortcutManager::resetAllToDefaults ( )
Here is the call graph for this function:

◆ resetToDefault()

void ShortcutManager::resetToDefault ( const QString & id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ savedSequence()

QKeySequence ShortcutManager::savedSequence ( const QString & id,
const QKeySequence & default_sequence ) const
private

ShortcutManager::savedSequence.

Parameters
id
default_sequence
Returns
the user-overridden sequence stored for id, or default_sequence if the user never overrode it. A stored-but-empty sequence (the user cleared the shortcut) is returned as an empty QKeySequence, not the default.
Here is the caller graph for this function:

◆ setSequence()

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.

Here is the caller graph for this function:

Member Data Documentation

◆ m_entries

QHash<QString, Entry> ShortcutManager::m_entries
private

◆ m_order

QStringList ShortcutManager::m_order
private

The documentation for this class was generated from the following files: