|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
Singleton manager for all keyboard shortcuts. More...
#include <shortcut_manager.h>
Public Member Functions | |
| ShortcutManager (const ShortcutManager &)=delete | |
| QString | checkConflict (const QKeySequence &shortcut, const QString &excludeActionId=QString()) const |
| Check if a shortcut conflicts with existing ones. | |
| bool | exportToFile (const QString &filePath) const |
| Export shortcuts to JSON file. | |
| const ShortcutAction * | getAction (const QString &actionId) const |
| Get an action by ID. | |
| std::vector< ShortcutAction > | getActionsByCategory (const QString &category) const |
| Get actions by category. | |
| std::vector< ShortcutAction > | getAllActions () const |
| Get all registered actions. | |
| QStringList | getCategories () const |
| Get all categories. | |
| bool | hasAction (const QString &actionId) const |
| Check if an action is registered. | |
| int | importFromFile (const QString &filePath) |
| Import shortcuts from JSON file. | |
| void | initialize (QWidget *mainWidget) |
| Initialize manager with main widget for shortcut context. | |
| bool | isInitialized () const |
| Check if manager is initialized. | |
| void | loadCustomizations () |
| Load custom shortcuts from settings. | |
| ShortcutManager & | operator= (const ShortcutManager &)=delete |
| bool | registerAction (const ShortcutAction &action) |
| Register a new shortcut action. | |
| void | resetAllToDefaults () |
| Reset all shortcuts to defaults. | |
| void | resetToDefault (const QString &actionId) |
| Reset an action to its default shortcut. | |
| void | saveCustomizations () |
| Save custom shortcuts to settings. | |
| void | setActionEnabled (const QString &actionId, bool enabled) |
| Enable or disable an action. | |
| void | setAllEnabled (bool enabled) |
| Enable or disable all shortcuts (useful when dialogs are open). | |
| void | setCategoryEnabled (const QString &category, bool enabled) |
| Enable or disable all actions in a category. | |
| bool | setShortcut (const QString &actionId, const QKeySequence &shortcut) |
| Set a custom shortcut for an action. | |
| void | shortcutChanged (const QString &actionId, const QKeySequence &newShortcut) |
| Emitted when a shortcut is changed. | |
| void | shortcutsReloaded () |
| Emitted when shortcuts are reloaded. | |
| bool | triggerAction (const QString &actionId) |
| Trigger an action by ID. | |
| void | unregisterAction (const QString &actionId) |
| Unregister a shortcut action. | |
Static Public Member Functions | |
| static ShortcutManager & | instance () |
| Get singleton instance. | |
| static QString | keySequenceToString (const QKeySequence &seq) |
| Get display string for a key sequence. | |
Singleton manager for all keyboard shortcuts.
Features:
Definition at line 101 of file shortcut_manager.h.
|
delete |
References ShortcutManager().
Referenced by ShortcutManager(), instance(), and operator=().
| QString ShortcutManager::checkConflict | ( | const QKeySequence & | shortcut, |
| const QString & | excludeActionId = QString() ) const |
Check if a shortcut conflicts with existing ones.
| shortcut | Key sequence to check |
| excludeActionId | Optional action ID to exclude from check |
Definition at line 185 of file shortcut_manager.cpp.
Referenced by registerAction(), and setShortcut().
| bool ShortcutManager::exportToFile | ( | const QString & | filePath | ) | const |
Export shortcuts to JSON file.
| filePath | Output file path |
Definition at line 298 of file shortcut_manager.cpp.
| const ShortcutAction * ShortcutManager::getAction | ( | const QString & | actionId | ) | const |
Get an action by ID.
| actionId | Action ID |
Definition at line 95 of file shortcut_manager.cpp.
| std::vector< ShortcutAction > ShortcutManager::getActionsByCategory | ( | const QString & | category | ) | const |
Get actions by category.
| category | Category name |
Definition at line 114 of file shortcut_manager.cpp.
| std::vector< ShortcutAction > ShortcutManager::getAllActions | ( | ) | const |
Get all registered actions.
Definition at line 103 of file shortcut_manager.cpp.
| QStringList ShortcutManager::getCategories | ( | ) | const |
Get all categories.
Definition at line 125 of file shortcut_manager.cpp.
| bool ShortcutManager::hasAction | ( | const QString & | actionId | ) | const |
Check if an action is registered.
| actionId | Action ID to check |
Definition at line 90 of file shortcut_manager.cpp.
Referenced by importFromFile().
| int ShortcutManager::importFromFile | ( | const QString & | filePath | ) |
Import shortcuts from JSON file.
| filePath | Input file path |
Definition at line 326 of file shortcut_manager.cpp.
References hasAction(), setShortcut(), and shortcutsReloaded().
| void ShortcutManager::initialize | ( | QWidget * | mainWidget | ) |
Initialize manager with main widget for shortcut context.
| mainWidget | The main window widget |
Definition at line 34 of file shortcut_manager.cpp.
References loadCustomizations().
Referenced by ShortcutsController::setupKeyboardShortcuts().
|
static |
Get singleton instance.
Definition at line 21 of file shortcut_manager.cpp.
References ShortcutManager(), and instance().
Referenced by instance(), ShortcutCheatSheet::paintEvent(), and ShortcutsController::setupKeyboardShortcuts().
|
inline |
Check if manager is initialized.
Definition at line 120 of file shortcut_manager.h.
|
static |
Get display string for a key sequence.
Definition at line 372 of file shortcut_manager.cpp.
| void ShortcutManager::loadCustomizations | ( | ) |
Load custom shortcuts from settings.
Definition at line 277 of file shortcut_manager.cpp.
Referenced by initialize(), and ShortcutsController::setupKeyboardShortcuts().
|
delete |
References ShortcutManager().
| bool ShortcutManager::registerAction | ( | const ShortcutAction & | action | ) |
Register a new shortcut action.
| action | The action to register |
Definition at line 52 of file shortcut_manager.cpp.
References checkConflict(), ShortcutAction::currentShortcut, and ShortcutAction::id.
Referenced by ShortcutBuilder::registerWith().
| void ShortcutManager::resetAllToDefaults | ( | ) |
Reset all shortcuts to defaults.
Definition at line 174 of file shortcut_manager.cpp.
References shortcutsReloaded().
| void ShortcutManager::resetToDefault | ( | const QString & | actionId | ) |
Reset an action to its default shortcut.
| actionId | Action ID |
Definition at line 162 of file shortcut_manager.cpp.
References shortcutChanged().
| void ShortcutManager::saveCustomizations | ( | ) |
Save custom shortcuts to settings.
Definition at line 257 of file shortcut_manager.cpp.
| void ShortcutManager::setActionEnabled | ( | const QString & | actionId, |
| bool | enabled ) |
Enable or disable an action.
| actionId | Action ID |
| enabled | Whether to enable |
Definition at line 207 of file shortcut_manager.cpp.
| void ShortcutManager::setAllEnabled | ( | bool | enabled | ) |
Enable or disable all shortcuts (useful when dialogs are open).
| enabled | Whether to enable |
Definition at line 239 of file shortcut_manager.cpp.
| void ShortcutManager::setCategoryEnabled | ( | const QString & | category, |
| bool | enabled ) |
Enable or disable all actions in a category.
| category | Category name |
| enabled | Whether to enable |
Definition at line 222 of file shortcut_manager.cpp.
| bool ShortcutManager::setShortcut | ( | const QString & | actionId, |
| const QKeySequence & | shortcut ) |
Set a custom shortcut for an action.
| actionId | Action ID |
| shortcut | New key sequence |
Definition at line 141 of file shortcut_manager.cpp.
References checkConflict(), ShortcutAction::currentShortcut, and shortcutChanged().
Referenced by importFromFile().
| void ShortcutManager::shortcutChanged | ( | const QString & | actionId, |
| const QKeySequence & | newShortcut ) |
Emitted when a shortcut is changed.
Referenced by resetToDefault(), and setShortcut().
| void ShortcutManager::shortcutsReloaded | ( | ) |
Emitted when shortcuts are reloaded.
Referenced by importFromFile(), and resetAllToDefaults().
| bool ShortcutManager::triggerAction | ( | const QString & | actionId | ) |
Trigger an action by ID.
| actionId | Action ID to trigger |
Definition at line 380 of file shortcut_manager.cpp.
References ShortcutAction::action, ShortcutAction::canExecute, and ShortcutAction::isEnabled.
| void ShortcutManager::unregisterAction | ( | const QString & | actionId | ) |
Unregister a shortcut action.
| actionId | Action ID to remove |
Definition at line 84 of file shortcut_manager.cpp.