QCAD
Open Source 2D CAD
|
Abstract base class for GUI action classes. More...
#include <RGuiAction.h>
Public Types | |
typedef void(* | FactoryFunction) (RGuiAction *) |
Public Slots | |
bool | slotTrigger (const QString &command=QString::null) |
Called when the action is triggered (e.g. More... | |
Signals | |
void | postTriggered () |
Public Member Functions | |
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, ...). More... | |
virtual bool | isChecked () const |
bool | isGroupDefault () |
bool | isIconDisabled () const |
bool | isOverride () const |
bool | isToggleable () const |
void | removeShortcuts () |
RGuiAction (const QString &oriText, QObject *parent=0) | |
void | setAllowInterrupt () |
virtual void | setChecked (bool on) |
Checks or unchecks this action. More... | |
void | setCommands (const QStringList &cmds) |
Sets the command(s) that can trigger this action from a command line. More... | |
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. More... | |
virtual void | setEnabledOverride (bool on, int override) |
Enables or disables the action. More... | |
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). More... | |
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. More... | |
void | setNoState (bool checkable=false) |
void | setOverride () |
void | setRequiresDocument (bool on) |
If on is true, this action requires a document to be open. More... | |
void | setRequiresRedoableTransaction (bool on) |
void | setRequiresSelection (bool on) |
If on is true, this action requires a selection to operate on. More... | |
void | setRequiresUndoableTransaction (bool on) |
void | setScriptFile (const QString &sf, bool isSecondary=false) |
Sets the script file to be used for this action. More... | |
void | setShortcut (const QKeySequence &shortcut) |
Sets the shortcut(s) for this action. More... | |
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. More... | |
void | setText (const QString &oriText) |
void | setToggleable (bool on=true) |
If enabled, action terminates when activated and already running. More... | |
virtual void | setToolTip (const QString &tip) |
Sets the tooltip for this action. More... | |
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. More... | |
void | updateIcon () |
virtual void | updateSelectionListener (RDocumentInterface *documentInterface) |
Called by the document whenever the current selection changes. More... | |
virtual void | updateTransactionListener (RDocument *document, RTransaction *transaction=NULL) |
Called by the document whenever the current transaction stack changes. More... | |
virtual | ~RGuiAction () |
Public Member Functions inherited from RFocusListener | |
virtual | ~RFocusListener () |
Public Member Functions inherited from RTransactionListener | |
virtual | ~RTransactionListener () |
Public Member Functions inherited from RSelectionListener | |
virtual | ~RSelectionListener () |
Static Public Member Functions | |
static void | addSeparatorToWidget (QAction *a, QWidget *w) |
static void | addToWidget (QAction *a, QWidget *w) |
static void | clear () |
Cleans up all GUI action objects. More... | |
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 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. More... | |
static bool | triggerByScriptFile (const QString &scriptFile) |
Triggers the first action in the list of actions that is based on the given scriptFile . More... | |
static bool | triggerByShortcut (const QString &sc) |
static void | triggerGroupDefault (const QString &group) |
static void | triggerGroupDefaults () |
static void | updateIcons () |
Protected Attributes | |
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 |
bool | override |
bool | requiresDocument |
bool | requiresRedoableTransaction |
bool | requiresSelection |
bool | requiresUndoableTransaction |
QString | scriptFile |
QString | shortcutText |
bool | toggleable |
QString | toolTip |
QString | uniqueGroup |
Static Protected Attributes | |
static QList< RGuiAction * > | actions |
static QMap< QString, RGuiAction * > | actionsByCommand |
Copyright (c) 2011-2018 by Andrew Mustun. More... | |
static QMultiMap< QString, RGuiAction * > | actionsByGroup |
static QMap< QString, RGuiAction * > | actionsByPrimaryCommand |
static QMap< QString, RGuiAction * > | actionsByScriptFile |
static QMap< QString, RGuiAction * > | actionsByShortcut |
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, ...
typedef void(* RGuiAction::FactoryFunction) (RGuiAction *) |
RGuiAction::RGuiAction | ( | const QString & | oriText, |
QObject * | parent = 0 |
||
) |
|
virtual |
void RGuiAction::addArgument | ( | const QString & | arg | ) |
|
static |
void RGuiAction::addShortcut | ( | const QKeySequence & | shortcut | ) |
void RGuiAction::addToMenu | ( | QMenu * | menu | ) |
void RGuiAction::addToToolBar | ( | QToolBar * | tb | ) |
|
static |
|
static |
Cleans up all GUI action objects.
void RGuiAction::clearArguments | ( | ) |
void RGuiAction::disableIcon | ( | ) |
|
static |
|
static |
|
inlinestatic |
|
inline |
QStringList RGuiAction::getArguments | ( | ) |
|
static |
primaryOnly | True: only include primary commands (e.g. 'point') False: also include secondary commands (e.g. 'po') |
|
static |
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".
primaryOnly | True: only include primary commands (e.g. 'point') False: also include secondary commands (e.g. 'po') |
|
static |
|
static |
|
static |
scriptFile
.
|
inline |
|
inline |
QList< QKeySequence > RGuiAction::getDefaultShortcuts | ( | ) |
|
inline |
QString RGuiAction::getGroup | ( | ) |
int RGuiAction::getGroupSortOrder | ( | const QWidget * | w = NULL | ) | const |
|
static |
|
inline |
|
inline |
true | This action requires an open document to be started. |
false | This action does not require an open document to be started. |
|
inline |
|
inline |
true | This action requires an selection to be started. |
false | This action does not require a selection to be started. |
|
inline |
|
inline |
|
inline |
QList< QKeySequence > RGuiAction::getShortcuts | ( | ) | const |
QString RGuiAction::getShortcutsString | ( | const QString & | separator = "," , |
QKeySequence::SequenceFormat | format = QKeySequence::PortableText |
||
) | const |
QString RGuiAction::getShortcutText | ( | ) | const |
int RGuiAction::getSortOrder | ( | const QWidget * | w = NULL | ) | const |
|
static |
QString RGuiAction::getToolTip | ( | const QString & | oriText, |
const QString & | shortcut | ||
) |
|
inline |
QStringList RGuiAction::getWidgetNames | ( | ) | const |
|
static |
|
inline |
|
virtual |
|
virtual |
Initializes the GUI action texts (for menus, tooltips, ...).
This function is called whenever the text of the action changes.
|
virtual |
bool RGuiAction::isGroupDefault | ( | ) |
bool RGuiAction::isIconDisabled | ( | ) | const |
|
inline |
|
inline |
|
signal |
|
static |
void RGuiAction::removeShortcuts | ( | ) |
|
inline |
|
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.
cmd | Comma separated list of command(s) to set for this action. e.g. "mycommand", "mycommand,mycom,mc". |
void RGuiAction::setDefaultCommands | ( | const QStringList & | cmds | ) |
void RGuiAction::setDefaultShortcut | ( | const QKeySequence & | shortcut | ) |
void RGuiAction::setDefaultShortcuts | ( | const QList< QKeySequence > & | shortcuts | ) |
|
virtual |
Enables or disables the action.
|
virtual |
Enables or disables the action.
override | -1: don't set override (default), 1: true, 0: false |
void RGuiAction::setFactory | ( | FactoryFunction | f | ) |
|
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::setGroupDefault | ( | bool | on | ) |
void RGuiAction::setGroupSortOrder | ( | int | sortOrder | ) |
void RGuiAction::setGroupSortOrderOverride | ( | const QString & | widgetName, |
int | sortOrder | ||
) |
|
static |
|
static |
|
virtual |
Sets the action icon to the given icon file.
|
inline |
|
inline |
|
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.
|
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.
|
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.
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.
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 | ||
) |
|
static |
|
static |
|
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 | ) |
|
inline |
If enabled, action terminates when activated and already running.
|
virtual |
Sets the tooltip for this action.
Tooltips are shown when the mouse cursor hovers over a GUI element for some time.
|
inline |
void RGuiAction::setWidgetNames | ( | const QStringList & | widgetNames | ) |
|
static |
|
slot |
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).
|
static |
Triggers the first action in the list of actions that is registered to use the given command.
command | Command that was launched (e.g. "line" or "ln"). |
|
static |
Triggers the first action in the list of actions that is based on the given scriptFile
.
|
static |
|
static |
found &&
|
static |
|
virtual |
Called by the document whenever the focus changed from one MDI to another.
di | The document interface that has now the focus. |
Implements RFocusListener.
void RGuiAction::updateIcon | ( | ) |
|
static |
|
virtual |
Called by the document whenever the current selection changes.
Implements RSelectionListener.
|
virtual |
Called by the document whenever the current transaction stack changes.
Implements RTransactionListener.
|
staticprotected |
|
staticprotected |
Copyright (c) 2011-2018 by Andrew Mustun.
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.
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |