This class manages actions that the user can perform in the interface via pressing a hot key or clicking on a menu/toolbar item. There is only one instance of this manager in an application. This instance is created and owned by DzMainWindow. Don't create an instance of this class, but rather request a pointer to it from DzMainWindow via DzMainWindow::getActionMgr().
String DzActionMgr::addCustomAction | ( | String | text, | |
String | desc, | |||
String | script, | |||
Boolean | isFile = true , |
|||
String | shortcut = "" , |
|||
String | iconFile = "" | |||
) |
Adds a custom action to the action manager.
text | The text of the action. This is displayed in menus the action is added to unless a different menu text is specified. | |
desc | The description of the action. | |
script | The filename of the script to execute, or the actual text of the script to execute. | |
isFile | If true, then script is assumed to contain a filename, otherwise script is assumed to be the actual script. | |
shortcut | The default keyboard shortcut for the action. | |
iconFile | The path of an image file that will be the icon for the action. |
DzActionMgr::customActionAdded | ( | String | name | ) | [signal] |
Signature: "customActionAdded( const QString &name )"
Emitted when a custom action is added to the action manager
void DzActionMgr::customActionListChanged | ( | ) | [signal] |
Signature: "customActionListChanged()"
Emitted when custom actions are added to or removed from the action manager
DzActionMgr::customActionRemoved | ( | String | name | ) | [signal] |
Signature: "customActionRemoved( const QString &name )"
Emitted when a custom action is removed from the action manager
className | The class name of the action to find. |
var action; var mgr = MainWindow.getActionMgr(); // find the 'New File' action and print its accelerator to the log file. action = mgr.findAction( "DzNewAction" ); if( action ) print( action.text + ": " + action.shortcut );
name | The name of the custom action to find. |
which | The index of the action to return. |
var i, n; var action; var mgr = MainWindow.getActionMgr(); // go through the list of actions, and print their accelerators to the log file n = mgr.getNumActions(); for( i = 0; i < n; i++ ){ action = mgr.getAction( i ); print( action.text + ": " + action.shortcut ); }
name | The name of the custom action to get. |
which | The index of the custom action to get the description of. |
which | The index of the custom action to get the filename for. |
which | The index of the custom action to get the icon file for. |
which | The index of the custom action to get the name of. |
which | The index of the custom action to get the script for. | |
script | The string that will be set to the action's script. | |
isFile | This will be set to true if the script is a filename, if the script is code, this will be set to false. |
which | The index of the custom action to return the shortcut for. |
which | The index of the custom action to get the text for. |
DzActionMenu DzActionMgr::getMenu | ( | ) |
Number DzActionMgr::getNumActions | ( | ) |
Number DzActionMgr::getNumCustomActions | ( | ) |
Builds the main menu, pane menus and tool bars from the given file.
filename | The name of the interface file to load. |
void DzActionMgr::removeAllCustomActions | ( | ) |
Removes all custom actions from the application.
void DzActionMgr::removeCustomAction | ( | Number | which | ) |
which | The index of the custom action to remove. Removes the custom action at the given index. |
Saves the main menu, pane menus and tool bars to the given file.
filename | The name of the file to save the interface settings to. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
className | The name of the action class to set the accelerator for. | |
key | The string representation of the accelerator. |
var mgr = MainWindow.getActionMgr(); // set the accelerator for the 'New File' action to be 'Control+N' mgr.setAccel( "DzNewAction","Ctrl+N" );
which | The index of the custom action to set the accelerator for. | |
shortcut | The string representation of the accelerator. Sets the keyboard shortcut for the custom action at the given index. |
which | The index of the custom action to set the description for. | |
desc | The description of the custom action. Sets the description for the custom action at the given index. |
which | The index of the custom action to set the icon file for. | |
iconFile | The name of the file that will be loaded for the action's icon. Sets the icon for the custom action at the given index. |
Sets the script for the custom action at the given index.
which | The index of the custom action to set the script for. | |
script | The script to set as the Custom action's script. | |
isFile | If true, script contains the name of a script file that should be loaded, if false, script contains the code for the action's script. |
which | The index of the custom action to set the text for. | |
text | The new text for the action. Sets the text for the custom action at the given index. |
void DzActionMgr::unsetAccel | ( | String | key | ) |
key | The accelerator to remove from actions in the app. |
var mgr = MainWindow.getActionMgr(); // unset the accelerator for the action using 'Control+N' mgr.unsetAccel( "Ctrl+N" );