QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
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. More... | |
QAction * | actionByName (const QString &name) const |
Returns an action by its name, or nullptr if nothing found. More... | |
QAction * | actionForSequence (const QKeySequence &sequence) const |
Returns the action which is associated for a shortcut sequence, or nullptr if no action is associated. More... | |
QString | defaultKeySequence (QAction *action) const |
Returns the default sequence for an action. More... | |
QString | defaultKeySequence (QShortcut *shortcut) const |
Returns the default sequence for a shortcut. More... | |
QList< QAction * > | listActions () const |
Returns a list of all actions in the manager. More... | |
QList< QObject * > | listAll () const |
Returns a list of both actions and shortcuts in the manager. More... | |
QList< QShortcut * > | listShortcuts () const |
Returns a list of shortcuts in the manager. More... | |
QString | objectDefaultKeySequence (QObject *object) const |
Returns the default sequence for an object (either a QAction or QShortcut). More... | |
QObject * | objectForSequence (const QKeySequence &sequence) const |
Returns the object (QAction or QShortcut) matching the specified key sequence,. More... | |
bool | registerAction (QAction *action, const QString &defaultShortcut=QString()) |
Registers an action with the manager so the shortcut can be configured in GUI. More... | |
void | registerAllChildActions (QObject *object, bool recursive=false) |
Automatically registers all QActions which are children of the passed object. More... | |
void | registerAllChildren (QObject *object, bool recursive=false) |
Automatically registers all QActions and QShortcuts which are children of the passed object. More... | |
void | registerAllChildShortcuts (QObject *object, bool recursive=false) |
Automatically registers all QShortcuts which are children of the passed object. More... | |
bool | registerShortcut (QShortcut *shortcut, const QString &defaultSequence=QString()) |
Registers a QShortcut with the manager so the shortcut can be configured in GUI. More... | |
bool | setKeySequence (const QString &name, const QString &sequence) |
Modifies an action or shortcut's key sequence. More... | |
bool | setKeySequence (QAction *action, const QString &sequence) |
Modifies an action's key sequence. More... | |
bool | setKeySequence (QShortcut *shortcut, const QString &sequence) |
Modifies a shortcuts's key sequence. More... | |
bool | setObjectKeySequence (QObject *object, const QString &sequence) |
Modifies an object's (either a QAction or a QShortcut) key sequence. More... | |
QString | settingsPath () const |
Returns the root settings path used to store shortcut customisation. More... | |
QShortcut * | shortcutByName (const QString &name) const |
Returns a shortcut by its name, or nullptr if nothing found. More... | |
QShortcut * | shortcutForSequence (const QKeySequence &sequence) const |
Returns the shortcut which is associated for a key sequence, or nullptr if no shortcut is associated. More... | |
bool | unregisterAction (QAction *action) |
Removes an action from the manager. More... | |
bool | unregisterShortcut (QShortcut *shortcut) |
Removes a shortcut from the manager. More... | |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Static Public Member Functions | |
static QgsShortcutsManager * | instance () |
Return the singleton instance of the manager. More... | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Additional Inherited Members | |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Properties inherited from QObject | |
objectName | |
Shortcuts manager is a class that contains a list of QActions and QShortcuts that have been registered and their shortcuts can be changed.
Definition at line 31 of file qgsshortcutsmanager.h.
QgsShortcutsManager::QgsShortcutsManager | ( | QObject * | parent = nullptr , |
const QString & | settingsRoot = "/shortcuts/" |
||
) |
Constructor for QgsShortcutsManager.
parent | parent object |
settingsRoot | root QSettings path for storing settings, eg "/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 31 of file qgsshortcutsmanager.cpp.
Returns an action by its name, or nullptr if nothing found.
name | action name. Must match QAction's text. |
Definition at line 279 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 251 of file qgsshortcutsmanager.cpp.
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 186 of file qgsshortcutsmanager.cpp.
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 191 of file qgsshortcutsmanager.cpp.
|
static |
Return the singleton instance of the manager.
Definition at line 24 of file qgsshortcutsmanager.cpp.
Returns a list of all actions in the manager.
Definition at line 150 of file qgsshortcutsmanager.cpp.
Returns a list of both actions and shortcuts in the manager.
Definition at line 160 of file qgsshortcutsmanager.cpp.
Returns a list of shortcuts in the manager.
Definition at line 155 of file qgsshortcutsmanager.cpp.
Returns the default sequence for an object (either a QAction or QShortcut).
An empty return string indicates no shortcut.
Definition at line 176 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 |
Definition at line 241 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::registerAction | ( | QAction * | action, |
const QString & | defaultShortcut = 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 |
Definition at line 87 of file qgsshortcutsmanager.cpp.
void QgsShortcutsManager::registerAllChildActions | ( | QObject * | object, |
bool | recursive = false |
||
) |
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 |
Definition at line 43 of file qgsshortcutsmanager.cpp.
void QgsShortcutsManager::registerAllChildren | ( | QObject * | object, |
bool | recursive = false |
||
) |
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 |
Definition at line 37 of file qgsshortcutsmanager.cpp.
void QgsShortcutsManager::registerAllChildShortcuts | ( | QObject * | object, |
bool | recursive = false |
||
) |
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 |
Definition at line 65 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::registerShortcut | ( | QShortcut * | shortcut, |
const QString & | defaultSequence = 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 |
Definition at line 110 of file qgsshortcutsmanager.cpp.
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 196 of file qgsshortcutsmanager.cpp.
Modifies an action's key sequence.
action | action to modify |
sequence | new shortcut key sequence |
Definition at line 216 of file qgsshortcutsmanager.cpp.
Modifies a shortcuts's key sequence.
shortcut | QShortcut to modify |
sequence | new shortcut key sequence |
Definition at line 229 of file qgsshortcutsmanager.cpp.
Modifies an object's (either a QAction or a QShortcut) key sequence.
Definition at line 206 of file qgsshortcutsmanager.cpp.
|
inline |
Returns the root settings path used to store shortcut customisation.
Definition at line 217 of file qgsshortcutsmanager.h.
Returns a shortcut by its name, or nullptr if nothing found.
name | shortcut name. Must match QShortcut's QObject::objectName() property. |
Definition at line 290 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 265 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::unregisterAction | ( | QAction * | action | ) |
Removes an action from the manager.
action | action to remove |
Definition at line 132 of file qgsshortcutsmanager.cpp.
bool QgsShortcutsManager::unregisterShortcut | ( | QShortcut * | shortcut | ) |
Removes a shortcut from the manager.
shortcut | shortcut to remove |
Definition at line 141 of file qgsshortcutsmanager.cpp.