dRonin
adbada4
dRonin GCS
|
The class Command represents an action like a menu item, tool button, or shortcut. You don't create Command objects directly, instead use {ActionManager::registerAction()} to register an action and retrieve a Command. The Command object represents the user visible action and its properties. If multiple actions are registered with the same ID (but different contexts) the returned Command is the shared one between these actions. More...
#include <command.h>
Public Types | |
enum | CommandAttribute { CA_Hide = 0x0100, CA_UpdateText = 0x0200, CA_UpdateIcon = 0x0400, CA_NonConfigureable = 0x8000, CA_Mask = 0xFF00 } |
Signals | |
void | keySequenceChanged () |
Public Member Functions | |
virtual void | setDefaultKeySequence (const QKeySequence &key)=0 |
virtual QKeySequence | defaultKeySequence () const =0 |
virtual QKeySequence | keySequence () const =0 |
virtual void | setDefaultText (const QString &text)=0 |
virtual QString | defaultText () const =0 |
virtual int | id () const =0 |
virtual QAction * | action () const =0 |
virtual QShortcut * | shortcut () const =0 |
virtual void | setAttribute (CommandAttribute attr)=0 |
virtual void | removeAttribute (CommandAttribute attr)=0 |
virtual bool | hasAttribute (CommandAttribute attr) const =0 |
virtual bool | isActive () const =0 |
virtual | ~Command () |
virtual void | setKeySequence (const QKeySequence &key)=0 |
virtual QString | stringWithAppendedShortcut (const QString &str) const =0 |
The class Command represents an action like a menu item, tool button, or shortcut. You don't create Command objects directly, instead use {ActionManager::registerAction()} to register an action and retrieve a Command. The Command object represents the user visible action and its properties. If multiple actions are registered with the same ID (but different contexts) the returned Command is the shared one between these actions.
A Command has two basic properties: A default shortcut and a default text. The default shortcut is a key sequence that the user can use to trigger the active action that the Command represents. The default text is e.g. used for representing the Command in the keyboard shortcut preference pane. If the default text is empty, the text of the visible action is used.
The user visible action is updated to represent the state of the active action (if any). For performance reasons only the enabled and visible state are considered by default though. You can tell a Command to also update the actions icon and text by setting the corresponding {Command::CommandAttribute}{attribute}.
If there is no active action, the default behavior of the visible action is to be disabled. You can change that behavior to make the visible action hide instead via the Command's {Command::CommandAttribute}{attributes}.