Skip to content

RGuiAction

Class in Core Module
Header: #include <src/core/RGuiAction.h>
Inherits: QAction, RFocusListener, RTransactionListener, RSelectionListener

Abstract base class for GUI action classes.

Such classes represent a GUI action that can be used to start a tool. One GUI action class may be assigned to multiple GUI elements, for example a menu, a toolbutton and a context menu.

Each GUI action can have multiple commands assigned to it. These commands can be used to trigger the action from a command line.

Each GUI action can have multiple shortcuts assigned to it. Shortcuts are ‘traditional’ key combinations that can be used to trigger the action. e.g. Ctrl + Z, Ctrl + N, …

Scriptable: This class is available in script environments.

typedef void(*) FactoryFunction
RGuiAction(const QString &oriText, QObject *parent=0)
virtual ~RGuiAction()
void addArgument(const QString &arg)
void addShortcut(const QKeySequence &shortcut)
void addToMenu(QMenu *menu)
void addToToolBar(QToolBar *tb)
void clearArguments()
void disableIcon()
bool getAllowInterrupt() const
QStringList getArguments()
QStringList getCommands() const
QStringList getDefaultCommands()
QList< QKeySequence > getDefaultShortcuts()
bool getForceGlobal() const
QString getGroup()
int getGroupSortOrder(const QWidget *w=NULL) const
QString getMainCommand() const
bool getRequiresDocument() const
bool getRequiresRedoableTransaction() const
bool getRequiresSelection() const
bool getRequiresUndoableTransaction() const
QString getScriptClass() const
QString getScriptFile() const
QList< QKeySequence > getShortcuts() const
QString getShortcutsString(const QString &separator=“,”, QKeySequence::SequenceFormat format=QKeySequence::PortableText) const
QString getShortcutText() const
int getSortOrder(const QWidget *w=NULL) const
QString getToolTip(const QString &oriText, const QString &shortcut)
QString getUniqueGroup() const
QStringList getWidgetNames() const
bool hasNoState() const
virtual void init()
virtual void initTexts()
Initializes the GUI action texts (for menus, tooltips, …).
virtual bool isChecked() const
bool isGroupDefault()
bool isIconDisabled() const
bool isOverride() const
bool isToggleable() const
void removeShortcuts()
void setAllowInterrupt()
virtual void setChecked(bool on)
Checks or unchecks this action.
void setCommands(const QStringList &cmds)
Sets the command(s) that can trigger this action from a command line.
virtual void setCurrentBlock(RDocument *document)
void setDefaultCommands(const QStringList &cmds)
void setDefaultShortcut(const QKeySequence &shortcut)
void setDefaultShortcuts(const QList< QKeySequence > &shortcuts)
virtual void setEnabled(bool on)
Enables or disables the action.
virtual void setEnabledOverride(bool on, int override)
Enables or disables the action.
void setFactory(FactoryFunction f)
void setForceGlobal(bool on)
If on is true, this action runs in the global script context (default for actions that don’t require a document).
virtual void setGroup(const QString &title)
void setGroupDefault(bool on)
void setGroupSortOrder(int sortOrder)
void setGroupSortOrderOverride(const QString &widgetName, int sortOrder)
virtual void setIcon(const QString &iconFile)
Sets the action icon to the given icon file.
void setNoState(bool checkable=false)
void setOverride()
void setRequiresDocument(bool on)
If on is true, this action requires a document to be open.
void setRequiresRedoableTransaction(bool on)
void setRequiresSelection(bool on)
If on is true, this action requires a selection to operate on.
void setRequiresUndoableTransaction(bool on)
void setScriptFile(const QString &sf, bool isSecondary=false)
Sets the script file to be used for this action.
void setShortcut(const QKeySequence &shortcut)
Sets the shortcut(s) for this action.
void setShortcuts(const QList< QKeySequence > &shortcuts)
void setShortcutsFromStrings(const QStringList &shortcuts)
void setShortcutText(const QString &oriText)
void setSortOrder(int sortOrder)
void setSortOrderOverride(const QString &widgetName, int sortOrder)
virtual void setStatusTip(const QString &tip)
Sets the status tip of this action.
void setText(const QString &oriText)
void setToggleable(bool on=true)
If enabled, action terminates when activated and already running.
virtual void setToolTip(const QString &tip)
Sets the tooltip for this action.
void setUniqueGroup(const QString &ug)
void setWidgetNames(const QStringList &widgetNames)
virtual void updateFocus(RDocumentInterface *documentInterface)
Called by the document whenever the focus changed from one MDI to another.
void updateIcon()
virtual void updateSelectionListener(RDocumentInterface *documentInterface)
Called by the document whenever the current selection changes.
virtual void updateTransactionListener(RDocument *document, RTransaction *transaction=NULL)
Called by the document whenever the current transaction stack changes.
static void addSeparatorToWidget(QAction *a, QWidget *w)
static void addToWidget(QAction *a, QWidget *w)
static void clear()
Cleans up all GUI action objects.
static void fixSeparators(const QWidget *w)
static QString formatToolTip(const QString &oriText, const QString &shortcut)
static QList< RGuiAction * > getActions()
static QStringList getAvailableCommands(bool primaryOnly=false)
static QStringList getAvailableCommands(const QString &start, bool primaryOnly=false)
static RGuiAction * getByClassName(const QString &className)
static RGuiAction * getByCommand(const QString &command)
static RGuiAction * getByScriptFile(const QString &scriptFile)
static int getGroupSortOrderStatic(const QAction *a, const QWidget *w=NULL)
static QString getIconPath(const QString &iconFile, bool inverse=false)
static int getSortOrderStatic(const QAction *a, const QWidget *w=NULL)
static QStringList getWidgetNamesStatic(const QAction *a)
static void removeFromWidget(QAction *a, QWidget *w)
static void setGroupSortOrderOverrideStatic(QAction *a, const QString &widgetName, int sortOrder)
static void setGroupSortOrderStatic(QAction *a, int sortOrder)
static void setSortOrderOverrideStatic(QAction *a, const QString &widgetName, int sortOrder)
static void setSortOrderStatic(QAction *a, int sortOrder)
static void setWidgetNamesStatic(QAction *a, const QStringList &widgetNames)
static bool triggerByCommand(const QString &cmd)
Triggers the first action in the list of actions that is registered to use the given command.
static bool triggerByScriptFile(const QString &scriptFile)
Triggers the first action in the list of actions that is based on the given scriptFile.
static bool triggerByShortcut(const QString &sc)
static void triggerGroupDefault(const QString &group)
static void triggerGroupDefaults()
static void updateIcons()
static void updateToolTips()
bool slotTrigger(const QString &command=QString())
Called when the action is triggered (e.g.
bool allowInterrupt
QStringList arguments
QStringList commandList
QStringList defaultCommandList
QList< QKeySequence > defaultShortcuts
int enabledOverride
FactoryFunction factory
bool forceGlobal
QString group
bool groupDefault
bool iconDisabled
QString iconFile
QString mainCommand
QList< QKeySequence > multiKeyShortcuts
bool noState
QString oriText
QString oriToolTip
bool override
bool requiresDocument
bool requiresRedoableTransaction
bool requiresSelection
bool requiresUndoableTransaction
QString scriptFile
QString shortcutText
bool toggleable
QString uniqueGroup
static QList< RGuiAction * > actions
static QMap< QString, RGuiAction * > actionsByCommand
static QMultiMap< QString, RGuiAction * > actionsByGroup
static QMap< QString, RGuiAction * > actionsByPrimaryCommand
static QMap< QString, RGuiAction * > actionsByScriptFile
static QMap< QString, RGuiAction * > actionsByShortcut
void postTriggered()

typedef void(*) RGuiAction::FactoryFunction(RGuiAction *)(RGuiAction *)

RGuiAction::RGuiAction(const QString &oriText, QObject *parent=0)

virtual RGuiAction::~RGuiAction()

virtual

void RGuiAction::addArgument(const QString &arg)

void RGuiAction::addShortcut(const QKeySequence &shortcut)

void RGuiAction::addToMenu(QMenu *menu)

void RGuiAction::addToToolBar(QToolBar *tb)

void RGuiAction::clearArguments()

void RGuiAction::disableIcon()

bool RGuiAction::getAllowInterrupt() const

inline const

QStringList RGuiAction::getArguments()

QStringList RGuiAction::getCommands() const

inline const

Returns: Complete list of commands that may be used to trigger this action.

QStringList RGuiAction::getDefaultCommands()

inline

QList< QKeySequence > RGuiAction::getDefaultShortcuts()

bool RGuiAction::getForceGlobal() const

inline const

QString RGuiAction::getGroup()

int RGuiAction::getGroupSortOrder(const QWidget *w=NULL) const

const

QString RGuiAction::getMainCommand() const

inline const

Returns: The main command used to trigger this action. This is typically the full command (e.g. “line”) rather than one of the abbreviated commands such as “ln”.

bool RGuiAction::getRequiresDocument() const

inline const

Return values:

  • true: This action requires an open document to be started.
  • false: This action does not require an open document to be started.

bool RGuiAction::getRequiresRedoableTransaction() const

inline const

bool RGuiAction::getRequiresSelection() const

inline const

Return values:

  • true: This action requires an selection to be started.
  • false: This action does not require a selection to be started.

bool RGuiAction::getRequiresUndoableTransaction() const

inline const

QString RGuiAction::getScriptClass() const

const

QString RGuiAction::getScriptFile() const

inline const

Returns: Script file on which this action is based on.

QList< QKeySequence > RGuiAction::getShortcuts() const

const

QString RGuiAction::getShortcutsString(const QString &separator=",", QKeySequence::SequenceFormat format=QKeySequence::PortableText) const

const

QString RGuiAction::getShortcutText() const

const

int RGuiAction::getSortOrder(const QWidget *w=NULL) const

const

QString RGuiAction::getToolTip(const QString &oriText, const QString &shortcut)

QString RGuiAction::getUniqueGroup() const

inline const

QStringList RGuiAction::getWidgetNames() const

const

bool RGuiAction::hasNoState() const

inline const

virtual void RGuiAction::init()

virtual

virtual void RGuiAction::initTexts()

virtual

Initializes the GUI action texts (for menus, tooltips, …).

This function is called whenever the text of the action changes.

virtual bool RGuiAction::isChecked() const

virtual const

Returns: True if this action is checked.

bool RGuiAction::isGroupDefault()

bool RGuiAction::isIconDisabled() const

const

bool RGuiAction::isOverride() const

inline const

bool RGuiAction::isToggleable() const

inline const

void RGuiAction::removeShortcuts()

void RGuiAction::setAllowInterrupt()

inline

virtual void RGuiAction::setChecked(bool on)

virtual

Checks or unchecks this action.

void RGuiAction::setCommands(const QStringList &cmds)

Sets the command(s) that can trigger this action from a command line.

Parameters:

  • cmd: Comma separated list of command(s) to set for this action.
    e.g. “mycommand”, “mycommand,mycom,mc”.

virtual void RGuiAction::setCurrentBlock(RDocument *document)

virtual inline

Reimplemented from setCurrentBlock.

void RGuiAction::setDefaultCommands(const QStringList &cmds)

void RGuiAction::setDefaultShortcut(const QKeySequence &shortcut)

void RGuiAction::setDefaultShortcuts(const QList< QKeySequence > &shortcuts)

virtual void RGuiAction::setEnabled(bool on)

virtual

Enables or disables the action.

virtual void RGuiAction::setEnabledOverride(bool on, int override)

virtual

Enables or disables the action.

Parameters:

  • override: -1: don’t set override (default), 1: true, 0: false

void RGuiAction::setFactory(FactoryFunction f)

Non-Scriptable: This function is not available in script environments.

void RGuiAction::setForceGlobal(bool on)

inline

If on is true, this action runs in the global script context (default for actions that don’t require a document).

virtual void RGuiAction::setGroup(const QString &title)

virtual

void RGuiAction::setGroupDefault(bool on)

void RGuiAction::setGroupSortOrder(int sortOrder)

void RGuiAction::setGroupSortOrderOverride(const QString &widgetName, int sortOrder)

virtual void RGuiAction::setIcon(const QString &iconFile)

virtual

Sets the action icon to the given icon file.

void RGuiAction::setNoState(bool checkable=false)

inline

void RGuiAction::setOverride()

inline

void RGuiAction::setRequiresDocument(bool on)

inline

If on is true, this action requires a document to be open.

The GUI element(s) can for example be grayed out if no document is open.

void RGuiAction::setRequiresRedoableTransaction(bool on)

inline

void RGuiAction::setRequiresSelection(bool on)

If on is true, this action requires a selection to operate on.

The GUI element(s) can for example be grayed out if no selection is present.

void RGuiAction::setRequiresUndoableTransaction(bool on)

inline

void RGuiAction::setScriptFile(const QString &sf, bool isSecondary=false)

Sets the script file to be used for this action.

This is only used for script based actions.

Parameters:

  • isSecondary: true to avoid this action to be identified by the given script file when calling getByScriptFile. Used for example for recent file menu entries which all refer to the script OpenFile.js.

void RGuiAction::setShortcut(const QKeySequence &shortcut)

Sets the shortcut(s) for this action.

Parameters:

  • shortcut: Comma separated list of shortcuts (e.g. “Ctrl-Shift-Z,Ctrl-Y”).

void RGuiAction::setShortcuts(const QList< QKeySequence > &shortcuts)

void RGuiAction::setShortcutsFromStrings(const QStringList &shortcuts)

void RGuiAction::setShortcutText(const QString &oriText)

void RGuiAction::setSortOrder(int sortOrder)

void RGuiAction::setSortOrderOverride(const QString &widgetName, int sortOrder)

virtual void RGuiAction::setStatusTip(const QString &tip)

virtual

Sets the status tip of this action.

The status tip is shown in the status bar of the application when the mouse cursor hovers of a menu entry.

void RGuiAction::setText(const QString &oriText)

void RGuiAction::setToggleable(bool on=true)

inline

If enabled, action terminates when activated and already running.

virtual void RGuiAction::setToolTip(const QString &tip)

virtual

Sets the tooltip for this action.

Tooltips are shown when the mouse cursor hovers over a GUI element for some time.

void RGuiAction::setUniqueGroup(const QString &ug)

inline

void RGuiAction::setWidgetNames(const QStringList &widgetNames)

virtual void RGuiAction::updateFocus(RDocumentInterface *documentInterface)

virtual

Called by the document whenever the focus changed from one MDI to another.

Parameters:

  • di: The document interface that has now the focus.

Reimplemented from updateFocus.

void RGuiAction::updateIcon()

virtual void RGuiAction::updateSelectionListener(RDocumentInterface *documentInterface)

virtual

Called by the document whenever the current selection changes.

Reimplemented from updateSelectionListener.

virtual void RGuiAction::updateTransactionListener(RDocument *document, RTransaction *transaction=NULL)

virtual

Called by the document whenever the current transaction stack changes.

Reimplemented from updateTransactionListener.

static void RGuiAction::addSeparatorToWidget(QAction *a, QWidget *w)

static

static void RGuiAction::addToWidget(QAction *a, QWidget *w)

static

static void RGuiAction::clear()

static

Cleans up all GUI action objects.

static void RGuiAction::fixSeparators(const QWidget *w)

static

static QString RGuiAction::formatToolTip(const QString &oriText, const QString &shortcut)

static

static QList< RGuiAction * > RGuiAction::getActions()

static inline

Returns: List of all instantiated actions.

static QStringList RGuiAction::getAvailableCommands(bool primaryOnly=false)

static

Returns: A list of available top level commands. These are commands that can be used to trigger actions.

Parameters:

  • primaryOnly: True: only include primary commands (e.g. ‘point’) False: also include secondary commands (e.g. ‘po’)

static QStringList RGuiAction::getAvailableCommands(const QString &start, bool primaryOnly=false)

static

Returns: List of available commands for triggering actions that start with start.

This is typically used when the user presses the Tab key in a command line to complete a started command. For example entering “li<tab>” will result in the command to be completed to “line”.

Parameters:

  • primaryOnly: True: only include primary commands (e.g. ‘point’) False: also include secondary commands (e.g. ‘po’)

static RGuiAction * RGuiAction::getByClassName(const QString &className)

static

Returns: The first action in the list of actions that defines a class with the given name. Test is based on file name only.

static RGuiAction * RGuiAction::getByCommand(const QString &command)

static

static RGuiAction * RGuiAction::getByScriptFile(const QString &scriptFile)

static

Returns: The first action in the list of actions that is based on the given scriptFile.

static int RGuiAction::getGroupSortOrderStatic(const QAction *a, const QWidget *w=NULL)

static

static QString RGuiAction::getIconPath(const QString &iconFile, bool inverse=false)

static

static int RGuiAction::getSortOrderStatic(const QAction *a, const QWidget *w=NULL)

static

static QStringList RGuiAction::getWidgetNamesStatic(const QAction *a)

static

static void RGuiAction::removeFromWidget(QAction *a, QWidget *w)

static

static void RGuiAction::setGroupSortOrderOverrideStatic(QAction *a, const QString &widgetName, int sortOrder)

static

static void RGuiAction::setGroupSortOrderStatic(QAction *a, int sortOrder)

static

static void RGuiAction::setSortOrderOverrideStatic(QAction *a, const QString &widgetName, int sortOrder)

static

static void RGuiAction::setSortOrderStatic(QAction *a, int sortOrder)

static

static void RGuiAction::setWidgetNamesStatic(QAction *a, const QStringList &widgetNames)

static

static bool RGuiAction::triggerByCommand(const QString &cmd)

static

Triggers the first action in the list of actions that is registered to use the given command.

Parameters:

  • command: Command that was launched (e.g. “line” or “ln”).

static bool RGuiAction::triggerByScriptFile(const QString &scriptFile)

static

Triggers the first action in the list of actions that is based on the given scriptFile.

static bool RGuiAction::triggerByShortcut(const QString &sc)

static

static void RGuiAction::triggerGroupDefault(const QString &group)

static

found &&

static void RGuiAction::triggerGroupDefaults()

static

static void RGuiAction::updateIcons()

static

static void RGuiAction::updateToolTips()

static

bool RGuiAction::slotTrigger(const QString &command=QString())

Called when the action is triggered (e.g.

This should be called when the action is triggered, i.e.

a button is pressed or a menu chosen).

a GUI element is activated (button pressed, menu selected, etc).

bool RGuiAction::allowInterrupt

protected

QStringList RGuiAction::arguments

protected

QStringList RGuiAction::commandList

protected

QStringList RGuiAction::defaultCommandList

protected

QList<QKeySequence> RGuiAction::defaultShortcuts

protected

int RGuiAction::enabledOverride

protected

FactoryFunction RGuiAction::factory

protected

bool RGuiAction::forceGlobal

protected

QString RGuiAction::group

protected

bool RGuiAction::groupDefault

protected

bool RGuiAction::iconDisabled

protected

QString RGuiAction::iconFile

protected

QString RGuiAction::mainCommand

protected

QList<QKeySequence> RGuiAction::multiKeyShortcuts

protected

bool RGuiAction::noState

protected

QString RGuiAction::oriText

protected

QString RGuiAction::oriToolTip

protected

bool RGuiAction::override

protected

bool RGuiAction::requiresDocument

protected

bool RGuiAction::requiresRedoableTransaction

protected

bool RGuiAction::requiresSelection

protected

bool RGuiAction::requiresUndoableTransaction

protected

QString RGuiAction::scriptFile

protected

QString RGuiAction::shortcutText

protected

bool RGuiAction::toggleable

protected

QString RGuiAction::uniqueGroup

protected

static QList< RGuiAction * > RGuiAction::actions

static protected

static QMap< QString, RGuiAction * > RGuiAction::actionsByCommand

static protected

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

static QMultiMap< QString, RGuiAction * > RGuiAction::actionsByGroup

static protected

static QMap< QString, RGuiAction * > RGuiAction::actionsByPrimaryCommand

static protected

static QMap< QString, RGuiAction * > RGuiAction::actionsByScriptFile

static protected

static QMap< QString, RGuiAction * > RGuiAction::actionsByShortcut

static protected

void RGuiAction::postTriggered()