QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
Shortcuts manager is a class that contains a list of QActions and QShortcuts that have been registered and their shortcuts can be changed. More...
#include <qgsshortcutsmanager.h>
Public Member Functions | |
QgsShortcutsManager (QObject *parent=nullptr, const QString &settingsRoot="/shortcuts/") | |
Constructor for QgsShortcutsManager. | |
QAction * | actionByName (const QString &name) const |
Returns an action by its name, or nullptr if nothing found. | |
QAction * | actionForSequence (const QKeySequence &sequence) const |
Returns the action which is associated for a shortcut sequence, or nullptr if no action is associated. | |
QString | defaultKeySequence (QAction *action) const |
Returns the default sequence for an action. | |
QString | defaultKeySequence (QShortcut *shortcut) const |
Returns the default sequence for a shortcut. | |
QList< QAction * > | listActions () const |
Returns a list of all actions in the manager. | |
QList< QObject * > | listAll () const |
Returns a list of both actions and shortcuts in the manager. | |
QList< QShortcut * > | listShortcuts () const |
Returns a list of shortcuts in the manager. | |
QString | objectDefaultKeySequence (QObject *object) const |
Returns the default sequence for an object (either a QAction or QShortcut). | |
QObject * | objectForSequence (const QKeySequence &sequence) const |
Returns the object (QAction or QShortcut) matching the specified key sequence,. | |
QObject * | objectForSettingKey (const QString &name) const |
Returns the QShortcut or QAction matching the the full setting key Return nullptr if the key was not found. | |
QString | objectSettingKey (QObject *object) const |
Returns the full settings key matching the QShortcut or QAction Return an empty QString if the QObject is not registered. | |
bool | registerAction (QAction *action, const QString &defaultShortcut=QString(), const QString §ion=QString()) |
Registers an action with the manager so the shortcut can be configured in GUI. | |
void | registerAllChildActions (QObject *object, bool recursive=false, const QString §ion=QString()) |
Automatically registers all QActions which are children of the passed object. | |
void | registerAllChildren (QObject *object, bool recursive=false, const QString §ion=QString()) |
Automatically registers all QActions and QShortcuts which are children of the passed object. | |
void | registerAllChildShortcuts (QObject *object, bool recursive=false, const QString §ion=QString()) |
Automatically registers all QShortcuts which are children of the passed object. | |
bool | registerShortcut (QShortcut *shortcut, const QString &defaultSequence=QString(), const QString §ion=QString()) |
Registers a QShortcut with the manager so the shortcut can be configured in GUI. | |
bool | setKeySequence (const QString &name, const QString &sequence) |
Modifies an action or shortcut's key sequence. | |
bool | setKeySequence (QAction *action, const QString &sequence) |
Modifies an action's key sequence. | |
bool | setKeySequence (QShortcut *shortcut, const QString &sequence) |
Modifies a shortcuts's key sequence. | |
bool | setObjectKeySequence (QObject *object, const QString &sequence) |
Modifies an object's (either a QAction or a QShortcut) key sequence. | |
QString | settingsPath () const |
Returns the root settings path used to store shortcut customization. | |
QShortcut * | shortcutByName (const QString &name) const |
Returns a shortcut by its name, or nullptr if nothing found. | |
QShortcut * | shortcutForSequence (const QKeySequence &sequence) const |
Returns the shortcut which is associated for a key sequence, or nullptr if no shortcut is associated. | |
bool | unregisterAction (QAction *action) |
Removes an action from the manager. | |
bool | unregisterShortcut (QShortcut *shortcut) |
Removes a shortcut from the manager. | |
Shortcuts manager is a class that contains a list of QActions and QShortcuts that have been registered and their shortcuts can be changed.
QgsShortcutsManager is not usually directly created, but rather accessed through QgsGui::shortcutsManager().
Definition at line 36 of file qgsshortcutsmanager.h.
QgsShortcutsManager::QgsShortcutsManager | ( | QObject * | parent = nullptr , |
const QString & | settingsRoot = "/shortcuts/" |
||
) |
Constructor for QgsShortcutsManager.
parent | parent object |
settingsRoot | root QgsSettings path for storing settings, e.g., "/myplugin/shortcuts". Leave as the default value to store settings alongside built in QGIS shortcuts, but care must be taken to not register actions which conflict with the built in QGIS actions. |
Definition at line 25 of file qgsshortcutsmanager.cpp.
QAction * QgsShortcutsManager::actionByName | ( | const QString & | name | ) | const |
Returns an action by its name, or nullptr
if nothing found.
name | action name. Must match QAction's text. |
Definition at line 302 of file qgsshortcutsmanager.cpp.
QAction * QgsShortcutsManager::actionForSequence | ( | const QKeySequence & | sequence | ) | const |
Returns the action which is associated for a shortcut sequence, or nullptr
if no action is associated.
sequence | shortcut key sequence |
Definition at line 274 of file qgsshortcutsmanager.cpp.
QString QgsShortcutsManager::defaultKeySequence | ( | QAction * | action | ) | const |
Returns the default sequence for an action.
An empty return string indicates no default sequence.
action | action to return default key sequence for |
Definition at line 201 of file qgsshortcutsmanager.cpp.
QString QgsShortcutsManager::defaultKeySequence | ( | QShortcut * | shortcut | ) | const |
Returns the default sequence for a shortcut.
An empty return string indicates no default sequence.
shortcut | shortcut to return default key sequence for |
Definition at line 206 of file qgsshortcutsmanager.cpp.
QList< QAction * > QgsShortcutsManager::listActions | ( | ) | const |
Returns a list of all actions in the manager.
Definition at line 165 of file qgsshortcutsmanager.cpp.
QList< QObject * > QgsShortcutsManager::listAll | ( | ) | const |
Returns a list of both actions and shortcuts in the manager.
Definition at line 175 of file qgsshortcutsmanager.cpp.
QList< QShortcut * > QgsShortcutsManager::listShortcuts | ( | ) | const |
Returns a list of shortcuts in the manager.
Definition at line 170 of file qgsshortcutsmanager.cpp.
QString QgsShortcutsManager::objectDefaultKeySequence | ( | QObject * | object | ) | const |
Returns the default sequence for an object (either a QAction or QShortcut).
An empty return string indicates no shortcut.
object | QAction or QShortcut to return default key sequence for |
Definition at line 191 of file qgsshortcutsmanager.cpp.
QObject * QgsShortcutsManager::objectForSequence | ( | const QKeySequence & | sequence | ) | const |
Returns the object (QAction or QShortcut) matching the specified key sequence,.
sequence | key sequence to find |
nullptr
if not found Definition at line 264 of file qgsshortcutsmanager.cpp.
QObject * QgsShortcutsManager::objectForSettingKey | ( | const QString & | name | ) | const |
Returns the QShortcut or QAction matching the the full setting key Return nullptr if the key was not found.
Definition at line 349 of file qgsshortcutsmanager.cpp.
QString QgsShortcutsManager::objectSettingKey | ( | QObject * | object | ) | const |
Returns the full settings key matching the QShortcut or QAction Return an empty QString if the QObject is not registered.
Definition at line 336 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::registerAction | ( | QAction * | action, |
const QString & | defaultShortcut = QString() , |
||
const QString & | section = QString() |
||
) |
Registers an action with the manager so the shortcut can be configured in GUI.
action | action to register. The action must have a unique text string for identification. |
defaultShortcut | default key sequence for action |
section | Allows disambiguating shortcuts with the same objectName (since QGIS 3.32) |
true
if action was successfully registered Definition at line 71 of file qgsshortcutsmanager.cpp.
void QgsShortcutsManager::registerAllChildActions | ( | QObject * | object, |
bool | recursive = false , |
||
const QString & | section = QString() |
||
) |
Automatically registers all QActions which are children of the passed object.
object | parent object containing actions to register |
recursive | set to true to recursively add child actions |
section | Allows disambiguating shortcuts with the same objectName (since QGIS 3.32) |
Definition at line 37 of file qgsshortcutsmanager.cpp.
void QgsShortcutsManager::registerAllChildren | ( | QObject * | object, |
bool | recursive = false , |
||
const QString & | section = QString() |
||
) |
Automatically registers all QActions and QShortcuts which are children of the passed object.
object | parent object containing actions and shortcuts to register |
recursive | set to true to recursively add child actions and shortcuts |
section | Allows disambiguating shortcuts with the same objectName (since QGIS 3.32) |
Definition at line 31 of file qgsshortcutsmanager.cpp.
void QgsShortcutsManager::registerAllChildShortcuts | ( | QObject * | object, |
bool | recursive = false , |
||
const QString & | section = QString() |
||
) |
Automatically registers all QShortcuts which are children of the passed object.
object | parent object containing shortcuts to register |
recursive | set to true to recursively add child shortcuts |
section | Allows disambiguating shortcuts with the same objectName (since QGIS 3.32) |
Definition at line 54 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::registerShortcut | ( | QShortcut * | shortcut, |
const QString & | defaultSequence = QString() , |
||
const QString & | section = QString() |
||
) |
Registers a QShortcut with the manager so the shortcut can be configured in GUI.
shortcut | QShortcut to register. The shortcut must have a unique QObject::objectName() for identification. |
defaultSequence | default key sequence for shortcut |
section | Allows disambiguating shortcuts with the same objectName (since QGIS 3.32) |
true
if shortcut was successfully registered Definition at line 123 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::setKeySequence | ( | const QString & | name, |
const QString & | sequence | ||
) |
Modifies an action or shortcut's key sequence.
name | name of action or shortcut to modify. Must match the action's QAction::text() or the shortcut's QObject::objectName() |
sequence | new shortcut key sequence |
Definition at line 211 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::setKeySequence | ( | QAction * | action, |
const QString & | sequence | ||
) |
Modifies an action's key sequence.
action | action to modify |
sequence | new shortcut key sequence |
Definition at line 231 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::setKeySequence | ( | QShortcut * | shortcut, |
const QString & | sequence | ||
) |
Modifies a shortcuts's key sequence.
shortcut | QShortcut to modify |
sequence | new shortcut key sequence |
Definition at line 248 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::setObjectKeySequence | ( | QObject * | object, |
const QString & | sequence | ||
) |
Modifies an object's (either a QAction or a QShortcut) key sequence.
object | QAction or QShortcut to modify |
sequence | new shortcut key sequence |
Definition at line 221 of file qgsshortcutsmanager.cpp.
|
inline |
Returns the root settings path used to store shortcut customization.
Definition at line 247 of file qgsshortcutsmanager.h.
QShortcut * QgsShortcutsManager::shortcutByName | ( | const QString & | name | ) | const |
Returns a shortcut by its name, or nullptr
if nothing found.
name | shortcut name. Must match QShortcut's QObject::objectName() property. |
Definition at line 320 of file qgsshortcutsmanager.cpp.
QShortcut * QgsShortcutsManager::shortcutForSequence | ( | const QKeySequence & | sequence | ) | const |
Returns the shortcut which is associated for a key sequence, or nullptr
if no shortcut is associated.
sequence | shortcut key sequence |
Definition at line 288 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::unregisterAction | ( | QAction * | action | ) |
Removes an action from the manager.
action | action to remove |
true
if action was previously registered in manager and has been removed, or false
if action was not previously registered in manager Definition at line 147 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::unregisterShortcut | ( | QShortcut * | shortcut | ) |
Removes a shortcut from the manager.
shortcut | shortcut to remove |
true
if shortcut was previously registered in manager and has been removed, or false
if shortcut was not previously registered in manager Definition at line 156 of file qgsshortcutsmanager.cpp.