Command Class
(Core::Command)The Command class represents an action, such as a menu item, tool button, or shortcut. You do not create Command objects directly, but 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...
| Header: | #include <Command> |
Public Types
| enum | CommandAttribute { CA_UpdateText, CA_UpdateIcon, CA_Hide, CA_NonConfigurable } |
| flags | CommandAttributes |
Detailed Description
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 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 attributes.
Member Type Documentation
enum Command::CommandAttribute
flags Command::CommandAttributes
This enum defines how the user visible action is updated when the active action changes. The default is to update the enabled and visible state, and to disable the user visible action when there is no active action.
| Constant | Value | Description |
|---|---|---|
Core::Command::CA_UpdateText | 2 | Also update the actions text. |
Core::Command::CA_UpdateIcon | 4 | Also update the actions icon. |
Core::Command::CA_Hide | 1 | When there is no active action, hide the user "visible" action, instead of just disabling it. |
Core::Command::CA_NonConfigurable | 8 | Flag to indicate that the keyboard shortcut of this Command should not be configurable by the user. |
The CommandAttributes type is a typedef for QFlags<CommandAttribute>. It stores an OR combination of CommandAttribute values.