mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-03 00:04:47 -04:00
Common actions allow for shortcuts to be registered for actions which do not yet exist, or which are not associated with a single global QAction object attached to at the application level. For example, code editor actions which will be created as children of individual code editor widgets, but which should have shortcuts available for user configuration via the shortcuts manager dialog.
363 lines
11 KiB
Plaintext
363 lines
11 KiB
Plaintext
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/gui/qgsshortcutsmanager.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.py again *
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
class QgsShortcutsManager : QObject
|
|
{
|
|
%Docstring(signature="appended")
|
|
Shortcuts manager is a class that contains a list of QActions and
|
|
QShortcuts that have been registered and their shortcuts can be changed.
|
|
|
|
:py:class:`QgsShortcutsManager` is not usually directly created, but
|
|
rather accessed through :py:func:`QgsGui.shortcutsManager()`.
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsshortcutsmanager.h"
|
|
%End
|
|
public:
|
|
enum class CommonAction
|
|
{
|
|
CodeToggleComment,
|
|
CodeReformat,
|
|
};
|
|
|
|
QgsShortcutsManager( QObject *parent /TransferThis/ = 0, const QString &settingsRoot = "/shortcuts/" );
|
|
%Docstring
|
|
Constructor for QgsShortcutsManager.
|
|
|
|
:param parent: parent object
|
|
:param settingsRoot: root :py:class:`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.
|
|
%End
|
|
|
|
~QgsShortcutsManager();
|
|
|
|
void registerAllChildren( QObject *object, bool recursive = false, const QString §ion = QString() );
|
|
%Docstring
|
|
Automatically registers all QActions and QShortcuts which are children
|
|
of the passed object.
|
|
|
|
:param object: parent object containing actions and shortcuts to
|
|
register
|
|
:param recursive: set to ``True`` to recursively add child actions and
|
|
shortcuts
|
|
:param section: Allows disambiguating shortcuts with the same objectName
|
|
(since QGIS 3.32)
|
|
|
|
.. seealso:: :py:func:`registerAllChildActions`
|
|
|
|
.. seealso:: :py:func:`registerAllChildShortcuts`
|
|
%End
|
|
|
|
void registerAllChildActions( QObject *object, bool recursive = false, const QString §ion = QString() );
|
|
%Docstring
|
|
Automatically registers all QActions which are children of the passed
|
|
object.
|
|
|
|
:param object: parent object containing actions to register
|
|
:param recursive: set to ``True`` to recursively add child actions
|
|
:param section: Allows disambiguating shortcuts with the same objectName
|
|
(since QGIS 3.32)
|
|
|
|
.. seealso:: :py:func:`registerAction`
|
|
|
|
.. seealso:: :py:func:`registerAllChildren`
|
|
|
|
.. seealso:: :py:func:`registerAllChildShortcuts`
|
|
%End
|
|
|
|
void registerAllChildShortcuts( QObject *object, bool recursive = false, const QString §ion = QString() );
|
|
%Docstring
|
|
Automatically registers all QShortcuts which are children of the passed
|
|
object.
|
|
|
|
:param object: parent object containing shortcuts to register
|
|
:param recursive: set to ``True`` to recursively add child shortcuts
|
|
:param section: Allows disambiguating shortcuts with the same objectName
|
|
(since QGIS 3.32)
|
|
|
|
.. seealso:: :py:func:`registerShortcut`
|
|
|
|
.. seealso:: :py:func:`registerAllChildren`
|
|
|
|
.. seealso:: :py:func:`registerAllChildActions`
|
|
%End
|
|
|
|
bool registerAction( QAction *action, const QString &defaultShortcut = QString(), const QString §ion = QString() );
|
|
%Docstring
|
|
Registers an action with the manager so the shortcut can be configured
|
|
in GUI.
|
|
|
|
:param action: action to register. The action must have a unique text
|
|
string for identification.
|
|
:param defaultShortcut: default key sequence for action
|
|
:param section: Allows disambiguating shortcuts with the same objectName
|
|
(since QGIS 3.32)
|
|
|
|
:return: ``True`` if action was successfully registered
|
|
|
|
.. seealso:: :py:func:`registerShortcut`
|
|
|
|
.. seealso:: :py:func:`unregisterAction`
|
|
|
|
.. seealso:: :py:func:`registerAllChildActions`
|
|
%End
|
|
|
|
void initializeCommonAction( QAction *action, CommonAction commonAction );
|
|
%Docstring
|
|
Initializes an ``action`` as a common action.
|
|
|
|
This automatically configures the ``action`` to use the properties for
|
|
the common action, such as setting the action's tooltip and shortcut.
|
|
|
|
.. versionadded:: 4.0
|
|
%End
|
|
|
|
bool registerShortcut( QShortcut *shortcut, const QString &defaultSequence = QString(), const QString §ion = QString() );
|
|
%Docstring
|
|
Registers a QShortcut with the manager so the shortcut can be configured
|
|
in GUI.
|
|
|
|
:param shortcut: QShortcut to register. The shortcut must have a unique
|
|
QObject.objectName() for identification.
|
|
:param defaultSequence: default key sequence for shortcut
|
|
:param section: Allows disambiguating shortcuts with the same objectName
|
|
(since QGIS 3.32)
|
|
|
|
:return: ``True`` if shortcut was successfully registered
|
|
|
|
.. seealso:: :py:func:`registerAction`
|
|
|
|
.. seealso:: :py:func:`registerAllChildShortcuts`
|
|
%End
|
|
|
|
bool unregisterAction( QAction *action );
|
|
%Docstring
|
|
Removes an action from the manager.
|
|
|
|
:param action: action to remove
|
|
|
|
:return: ``True`` if action was previously registered in manager and has
|
|
been removed, or ``False`` if action was not previously
|
|
registered in manager
|
|
|
|
.. seealso:: :py:func:`registerAction`
|
|
|
|
.. seealso:: :py:func:`unregisterShortcut`
|
|
%End
|
|
|
|
bool unregisterShortcut( QShortcut *shortcut );
|
|
%Docstring
|
|
Removes a shortcut from the manager.
|
|
|
|
:param shortcut: shortcut to remove
|
|
|
|
:return: ``True`` if shortcut was previously registered in manager and
|
|
has been removed, or ``False`` if shortcut was not previously
|
|
registered in manager
|
|
|
|
.. seealso:: :py:func:`registerShortcut`
|
|
|
|
.. seealso:: :py:func:`unregisterAction`
|
|
%End
|
|
|
|
QList<QAction *> listActions() const;
|
|
%Docstring
|
|
Returns a list of all actions in the manager.
|
|
|
|
.. seealso:: :py:func:`listShortcuts`
|
|
|
|
.. seealso:: :py:func:`listAll`
|
|
%End
|
|
|
|
QList<QShortcut *> listShortcuts() const;
|
|
%Docstring
|
|
Returns a list of shortcuts in the manager.
|
|
|
|
.. seealso:: :py:func:`listActions`
|
|
|
|
.. seealso:: :py:func:`listAll`
|
|
%End
|
|
|
|
QList<QObject *> listAll() const;
|
|
%Docstring
|
|
Returns a list of both actions and shortcuts in the manager.
|
|
|
|
.. seealso:: :py:func:`listActions`
|
|
|
|
.. seealso:: :py:func:`listShortcuts`
|
|
%End
|
|
|
|
QString objectDefaultKeySequence( QObject *object ) const;
|
|
%Docstring
|
|
Returns the default sequence for an object (either a QAction or
|
|
QShortcut). An empty return string indicates no shortcut.
|
|
|
|
:param object: QAction or QShortcut to return default key sequence for
|
|
|
|
.. seealso:: :py:func:`defaultKeySequence`
|
|
%End
|
|
|
|
QString defaultKeySequence( QAction *action ) const;
|
|
%Docstring
|
|
Returns the default sequence for an action. An empty return string
|
|
indicates no default sequence.
|
|
|
|
:param action: action to return default key sequence for
|
|
|
|
.. seealso:: :py:func:`objectDefaultKeySequence`
|
|
%End
|
|
|
|
QString defaultKeySequence( QShortcut *shortcut ) const;
|
|
%Docstring
|
|
Returns the default sequence for a shortcut. An empty return string
|
|
indicates no default sequence.
|
|
|
|
:param shortcut: shortcut to return default key sequence for
|
|
|
|
.. seealso:: :py:func:`objectDefaultKeySequence`
|
|
%End
|
|
|
|
bool setKeySequence( const QString &name, const QString &sequence );
|
|
%Docstring
|
|
Modifies an action or shortcut's key sequence.
|
|
|
|
:param name: name of action or shortcut to modify. Must match the
|
|
action's QAction.text() or the shortcut's
|
|
QObject.objectName()
|
|
:param sequence: new shortcut key sequence
|
|
|
|
.. seealso:: :py:func:`setObjectKeySequence`
|
|
%End
|
|
|
|
bool setObjectKeySequence( QObject *object, const QString &sequence );
|
|
%Docstring
|
|
Modifies an object's (either a QAction or a QShortcut) key sequence.
|
|
|
|
:param object: QAction or QShortcut to modify
|
|
:param sequence: new shortcut key sequence
|
|
|
|
.. seealso:: :py:func:`setKeySequence`
|
|
%End
|
|
|
|
bool setKeySequence( QAction *action, const QString &sequence );
|
|
%Docstring
|
|
Modifies an action's key sequence.
|
|
|
|
:param action: action to modify
|
|
:param sequence: new shortcut key sequence
|
|
|
|
.. seealso:: :py:func:`setObjectKeySequence`
|
|
%End
|
|
|
|
bool setKeySequence( QShortcut *shortcut, const QString &sequence );
|
|
%Docstring
|
|
Modifies a shortcuts's key sequence.
|
|
|
|
:param shortcut: QShortcut to modify
|
|
:param sequence: new shortcut key sequence
|
|
|
|
.. seealso:: :py:func:`setObjectKeySequence`
|
|
%End
|
|
|
|
QObject *objectForSequence( const QKeySequence &sequence ) const;
|
|
%Docstring
|
|
Returns the object (QAction or QShortcut) matching the specified key
|
|
sequence,
|
|
|
|
:param sequence: key sequence to find
|
|
|
|
:return: object with matching sequence, or ``None`` if not found
|
|
|
|
.. seealso:: :py:func:`actionForSequence`
|
|
|
|
.. seealso:: :py:func:`shortcutForSequence`
|
|
%End
|
|
|
|
QAction *actionForSequence( const QKeySequence &sequence ) const;
|
|
%Docstring
|
|
Returns the action which is associated for a shortcut sequence, or
|
|
``None`` if no action is associated.
|
|
|
|
:param sequence: shortcut key sequence
|
|
|
|
.. seealso:: :py:func:`objectForSequence`
|
|
|
|
.. seealso:: :py:func:`shortcutForSequence`
|
|
%End
|
|
|
|
QShortcut *shortcutForSequence( const QKeySequence &sequence ) const;
|
|
%Docstring
|
|
Returns the shortcut which is associated for a key sequence, or ``None``
|
|
if no shortcut is associated.
|
|
|
|
:param sequence: shortcut key sequence
|
|
|
|
.. seealso:: :py:func:`objectForSequence`
|
|
|
|
.. seealso:: :py:func:`actionForSequence`
|
|
%End
|
|
|
|
QAction *actionByName( const QString &name ) const;
|
|
%Docstring
|
|
Returns an action by its name, or ``None`` if nothing found.
|
|
|
|
:param name: action name. Must match QAction's text.
|
|
|
|
.. seealso:: :py:func:`shortcutByName`
|
|
%End
|
|
|
|
QShortcut *shortcutByName( const QString &name ) const;
|
|
%Docstring
|
|
Returns a shortcut by its name, or ``None`` if nothing found
|
|
|
|
:param name: shortcut name. Must match QShortcut's QObject.objectName()
|
|
property.
|
|
|
|
.. seealso:: :py:func:`actionByName`
|
|
%End
|
|
|
|
QString settingsPath() const;
|
|
%Docstring
|
|
Returns the root settings path used to store shortcut customization.
|
|
%End
|
|
|
|
QString objectSettingKey( QObject *object ) const;
|
|
%Docstring
|
|
Returns the full settings key matching the QShortcut or QAction Return
|
|
an empty string if the QObject is not registered
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
|
|
QObject *objectForSettingKey( const QString &name ) const;
|
|
%Docstring
|
|
Returns the QShortcut or QAction matching the the full setting key
|
|
Return None if the key was not found
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
|
|
};
|
|
|
|
|
|
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/gui/qgsshortcutsmanager.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.py again *
|
|
************************************************************************/
|