User Tools

Site Tools


DzActionMgr

Manager that handles actions.

More...

Inherits :

Constructors

DAZ Script
startic legalizeName ( String name )

Methods

DAZ Script
StringaddCustomAction ( String text, String desc, String script, Boolean isFile=true, String shortcut=“”, String iconFile=“” )
voidclearActiveMenu ()
DzActionfindAction ( String className )
NumberfindCustomAction ( String guid )
DzActionfindPaneAction ( String className )
DzPersistentMenufindPersistentMenu ( String className )
DzActionfindViewToolAction ( String className )
DzActiongetAction ( Number which )
DzActionMenugetActiveMenu ()
NumbergetCustomAction ( String guid )
StringgetCustomActionDesc ( Number which )
StringgetCustomActionFile ( Number which )
StringgetCustomActionIcon ( Number which )
StringgetCustomActionName ( Number which )
StringgetCustomActionScript ( Number which )
StringgetCustomActionShortcut ( Number which )
StringgetCustomActionText ( Number which )
DzActionMenugetMenu ()
NumbergetNumActions ()
NumbergetNumCustomActions ()
NumbergetNumPersistentMenus ()
DzPersistentMenugetPersistentMenu ( Number which )
BooleanloadInterfaceFile ( String filename, Boolean overrideDefaults )
BooleanloadInterfaceFile ( String filename )
voidremoveAllCustomActions ()
voidremoveCustomAction ( Number which )
BooleansaveActionsFile ( String filename )
BooleansaveCustomActionsFile ( String filename )
BooleansaveInterfaceFiles ()
BooleansaveMenusFile ( String filename )
BooleansaveToolBarsFile ( String filename )
voidsetAccel ( String className, String key )
voidsetActiveMenu ( DzActionMenu menu )
voidsetCustomActionAccel ( Number which, String shortcut )
voidsetCustomActionDesc ( Number which, String desc )
voidsetCustomActionIcon ( Number which, String iconFile )
voidsetCustomActionScript ( Number which, String script, Boolean isFile=true )
voidsetCustomActionShortcut ( Number which, String shortcut )
voidsetCustomActionShowTextWithIcon ( Number which, Boolean onOff )
voidsetCustomActionText ( Number which, String text )
voidunsetAccel ( String key )

Signals

Detailed Description

This class manages actions that the user can perform in the interface by pressing the key combination specified by its shortcut or by 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, rather request a pointer to it from DzMainWindow via DzMainWindow::getActionMgr().

See Also:

Constructors


startic : legalizeName( String name )

Uses the regular expression “([A-z]+[A-z0-9]*)” to strip characters/symbols/etc from a string in order to 'legalize' it.

Parameter(s):

  • name - The name to 'legalize.'

Return Value:

  • A 'legalized' version of name.

Since:

  • 4.6.2.102

Methods


String : addCustomAction( String text, String desc, String script, Boolean isFile=true, String shortcut=“”, String iconFile=“” )

Adds a custom action to the action manager.

Parameter(s):

  • 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.

Return Value:

  • The globally unique identifier for the newly created custom action.

void : clearActiveMenu()

Clears the active menu.


DzAction : findAction( String className )

Parameter(s):

  • className - The class name of the action to find.

Return Value:

  • A pointer to the action object of the given class type.

Example:

var oMgr = MainWindow.getActionMgr();
 
// Find the 'New File' action and print its accelerator to the log file
var oAction = oMgr.findAction( "DzNewAction" );
if( oAction ){
	print( oAction.text, ": ", oAction.shortcut );
}

Number : findCustomAction( String guid )

Parameter(s):

  • guid - The globally unique identifier (name) of the custom action to find.

Return Value:

  • The index of the custom action with the given identifier (if any), otherwise -1.

DzAction : findPaneAction( String className )

Parameter(s):

  • className - The class name of the DzPane to find the action for.

Return Value:

  • The action that toggles visibility of the given DzPane class (if any), otherwise NULL.

Example:

var oMgr = MainWindow.getActionMgr();
 
// Find the action for the 'Smart Content' pane and print its accelerator to the log file
var oAction = oMgr.findPaneAction( "DzSmartContentPane" );
if( oAction ){
	print( oAction.text, ": ", oAction.shortcut );
}

Since:

  • 4.8.1.18

DzPersistentMenu : findPersistentMenu( String className )

Parameter(s):

  • className - The class name of the persistent menu to find.

Return Value:

  • The persistent menu of the given class type (if any), otherwise NULL.

DzAction : findViewToolAction( String className )

Parameter(s):

  • className - The class name of the DzViewTool to find the action for.

Return Value:

  • The action that activates the given DzViewTool subclass (if any), otherwise NULL.

Example:

var oMgr = MainWindow.getActionMgr();
 
// Find the action for the 'Universal' tool and print its accelerator to the log file
var oAction = oMgr.findViewToolAction( "DzUniversalTool" );
if( oAction ){
	print( oAction.text, ": ", oAction.shortcut );
}

Since:

  • 4.8.1.18

DzAction : getAction( Number which )

Parameter(s):

  • which - The index of the action to return.

Return Value:

  • The action at the given index (if any), otherwise NULL.

Example:

var oAction;
var oMgr = MainWindow.getActionMgr();
 
// Go through the list of actions and print their accelerators to the log file
var nActions = oMgr.getNumActions();
for( var i = 0; i < nActions; i++ ){
	oAction = oMgr.getAction( i );
	print( oAction.text, ": ", oAction.shortcut );
}

DzActionMenu : getActiveMenu()

Return Value:

  • The currently set active menu (if any), otherwise NULL.

Number : getCustomAction( String guid )

Parameter(s):

  • guid - The globally unique identifier (name) of the custom action to get.

Return Value:

  • The index of the custom action with the given GUID; creates a custom action if one does not already exist.

String : getCustomActionDesc( Number which )

Parameter(s):

  • which - The index of the custom action to get the description of.

Return Value:

  • The description for the custom action at the given index (if any), otherwise an empty string.

String : getCustomActionFile( Number which )

Parameter(s):

  • which - The index of the custom action to get the filename for.

Return Value:

  • The path to the file for the custom action at the given index (if any) if the custom action refers a file, otherwise an empty string.

String : getCustomActionIcon( Number which )

Parameter(s):

  • which - The index of the custom action to get the icon file for.

Return Value:

  • The icon file for the custom action at the given index.

String : getCustomActionName( Number which )

Parameter(s):

  • which - The index of the custom action to get the name of.

Return Value:

  • The globally unique identifier for the custom action at the given index (if any), otherwise an empty string.

String : getCustomActionScript( Number which )

Parameter(s):

  • which - The index of the custom action to get information for.

Return Value:

  • The script code executed by the custom action or an empty string if the custom action refers to a file (if any), otherwise an empty string.

String : getCustomActionShortcut( Number which )

Parameter(s):

  • which - The index of the custom action to return the shortcut for.

Return Value:

  • The keyboard shortcut for the custom action at the given index (if any), otherwise an empty string.

String : getCustomActionText( Number which )

Parameter(s):

  • which - The index of the custom action to get the text for.

Return Value:

  • The text for the custom action at the given index (if any), otherwise an empty string.

DzActionMenu : getMenu()

Return Value:

  • The Main Menu for the application.

Number : getNumActions()

Return Value:

  • The number of action items in the application.

Number : getNumCustomActions()

Return Value:

  • The number of custom actions in the action manager.

Number : getNumPersistentMenus()

Return Value:

  • The number of persistent menus in the application.

DzPersistentMenu : getPersistentMenu( Number which )

Parameter(s):

  • which - The index of the persistent menu to return.

Return Value:

  • The persistent menu at the specified index (if any), otherwise NULL.

Boolean : loadInterfaceFile( String filename, Boolean overrideDefaults )

Builds the main menu, pane menus and tool bars from the given file.

Parameter(s):

  • filename - The name of the interface file to load.
  • overrideDefaults - Whether or not default triggers (i.e. version numbers on menus) cause certain items to be rebuilt using their defaults.

Return Value:

  • true if the file was successfully loaded, otherwise false.

Since:

  • 4.6.0.78

Boolean : loadInterfaceFile( String filename )

Deprecated

Exists only to keep old code from crashing. Do not use in new code. Use the overload that takes two arguments instead.


void : removeAllCustomActions()

Removes all custom actions from the application.


void : removeCustomAction( Number which )

Removes the custom action at the given index.

Parameter(s):

  • which - The index of the custom action to remove.

Boolean : saveActionsFile( String filename )

Saves the actions to the given file.

Parameter(s):

  • filename - The name of the file to save the interface settings to.

Return Value:

  • true if the file was saved successfully, otherwise false.

Boolean : saveCustomActionsFile( String filename )

Saves the actions to the given file.

Parameter(s):

  • filename - The name of the file to save the interface settings to.

Return Value:

  • true if the file was saved successfully, otherwise false.

Boolean : saveInterfaceFiles()

Saves the actions, menus and toolbars to their respective files in the default location.

Return Value:

  • true if the files were saved successfully, otherwise false.

See Also:


Boolean : saveMenusFile( String filename )

Saves the main menu, pane menus to the given file.

Parameter(s):

  • filename - The name of the file to save the interface settings to.

Return Value:

  • true if the file was saved successfully, otherwise false.

Boolean : saveToolBarsFile( String filename )

Saves the tool bars to the given file.

Parameter(s):

  • filename - The name of the file to save the interface settings to.

Return Value:

  • true if the file was saved successfully, otherwise false.

void : setAccel( String className, String key )

Parameter(s):

  • className - The name of the action class to set the accelerator for.
  • key - The string representation of the accelerator.

Example:

var oMgr = MainWindow.getActionMgr();
 
// Set the accelerator for the 'New File' action to be the 'Ctrl' key and the 'N' key
oMgr.setAccel( "DzNewAction", "Ctrl+N" );

void : setActiveMenu( DzActionMenu menu )

Sets the active menu, so that actions relying on the active menu can get it. This may be called before the menu exec() call to allow context for script actions.

Parameter(s):

  • menu - The menu to set as the active menu.

void : setCustomActionAccel( Number which, String shortcut )

Deprecated

Exists only to keep old code from crashing. Do not use in new code. Use setCustomActionShortcut() instead.


void : setCustomActionDesc( Number which, String desc )

Sets the description for the custom action at the given index.

Parameter(s):

  • which - The index of the custom action to set the description for.
  • desc - The description of the custom action.

void : setCustomActionIcon( Number which, String iconFile )

Sets the icon for the custom action at the given index.

Parameter(s):

  • which - The index of the custom action to set the icon file for.
  • iconFile - The path of the image file that will be loaded for the action's icon. The path can be absolute, or relative to DzApp::getResourcesPath().

void : setCustomActionScript( Number which, String script, Boolean isFile=true )

Sets the script for the custom action at the given index.

Parameter(s):

  • 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.

void : setCustomActionShortcut( Number which, String shortcut )

Sets the keyboard shortcut for the custom action at the given index.

Parameter(s):

  • which - The index of the custom action to set the shortcut for.
  • shortcut - The string representation of the shortcut.

Since:

  • 4.9.4.102

void : setCustomActionShowTextWithIcon( Number which, Boolean onOff )

Sets whether or not the text of the action is displayed with the icon for the custom action at the given index.

Parameter(s):

  • which - The index of the custom action to set.
  • onOff - If true, the text of the action is always displayed with the icon (e.g., in toolbars).

void : setCustomActionText( Number which, String text )

Sets the text for the custom action at the given index.

Parameter(s):

  • which - The index of the custom action to set the text for.
  • text - The new text for the action.

void : unsetAccel( String key )

Parameter(s):

  • key - The accelerator to remove from actions in the app.

Example:

var oMgr = MainWindow.getActionMgr();
 
// Unset the accelerator for the action using 'Control + N'
oMgr.unsetAccel( "Ctrl+N" );

Signals


void : customActionAdded( String name )

Signature:“customActionAdded(const QString&)”

Emitted when a custom action is added to the action manager.


void : customActionListChanged()

Signature:“customActionListChanged()”

Emitted when custom actions are added to or removed from the action manager.


void : customActionRemoved( String name )

Signature:“customActionRemoved(const QString&)”

Emitted when a custom action is removed from the action manager.