User Tools

Site Tools


DzActionMgr

Manager responsible for 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 identifier )
ArrayfindActionsForShortcut ( String shortcut )
NumberfindCustomAction ( String guid )
DzActionfindPaneAction ( String identifier )
DzPersistentMenufindPersistentMenu ( String className )
DzActionfindViewToolAction ( String className )
DzActiongetAction ( Number index )
DzActionMenugetActiveMenu ()
NumbergetCustomAction ( String guid )
DzActiongetCustomActionByIndex ( Number index )
StringgetCustomActionDescription ( Number index )
StringgetCustomActionFile ( Number index )
StringgetCustomActionIcon ( Number index )
StringgetCustomActionName ( Number index )
StringgetCustomActionScript ( Number index )
StringgetCustomActionShortcut ( Number index )
NumbergetCustomActionShowTextWithIcon ( Number index )
StringgetCustomActionText ( Number index )
StringgetDocumentationUrl ()
DzActionMenugetMenu ()
NumbergetNumActions ()
NumbergetNumCustomActions ()
NumbergetNumPersistentMenus ()
DzPersistentMenugetPersistentMenu ( Number index )
BooleanloadInterfaceFile ( String filename, Boolean overrideDefaults )
voidremoveAllCustomActions ()
voidremoveCustomAction ( Number index )
BooleansaveActionsFile ( String filename )
BooleansaveCustomActionsFile ( String filename )
BooleansaveInterfaceFiles ()
BooleansaveMenusFile ( String filename )
BooleansaveToolBarsFile ( String filename )
voidsetAccel ( String className, String key )
voidsetActiveMenu ( DzActionMenu menu )
voidsetCustomActionDescription ( Number index, String desc )
voidsetCustomActionIcon ( Number index, String iconFile )
voidsetCustomActionScript ( Number index, String script, Boolean isFile=true )
voidsetCustomActionShortcut ( Number index, String shortcut )
voidsetCustomActionShowTextWithIcon ( Number index, Boolean onOff )
voidsetCustomActionText ( Number index, String text )
voidunsetAccel ( String key )

Signals

Detailed Description

Responsible for the management of 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. Request the instance 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 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 identifier )

Parameter(s):

  • identifier - The classname of the DzAction subclass to find the action for.

Return Value:

  • The DzAction subclass with the specified classname (if any), otherwise null.

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 );
}

Array : findActionsForShortcut( String shortcut )

Parameter(s):

  • shortcut - The shortcut to find actions for.

Return Value:

  • The list of actions whose shortcuts start with the specified sequence (if any), otherwise an empty list.

Example:

(function(){
 
	var oActionMgr = MainWindow.getActionMgr();
 
	var oAction;
 
	var aActions = oActionMgr.findActionsForShortcut( "Ctrl+N" );
	for( var i = 0, n = aActions.length; i < n; i += 1 ){
		oAction = aActions[ i ];
		if( oAction.inherits( "DzCustomAction" ) ){
			print( i, "Custom:", oAction.name, ":", oAction.shortcut );
		} else {
			print( i, oAction.className(), ":", oAction.shortcut );
		}
	}
 
})();

Since:

  • 4.12.1.63

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 specified identifier (if any), otherwise -1.

DzAction : findPaneAction( String identifier )

Parameter(s):

  • identifier - The classname of the DzPane to find the action for.

Return Value:

  • The action that toggles visibility of the specified DzPane (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 specified 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 specified 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 index )

Parameter(s):

  • index - The index of the action to return.

Return Value:

  • The DzAction subclass at the specified 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 specified GUID; creates a custom action if one does not already exist.

See Also:


DzAction : getCustomActionByIndex( Number index )

Parameter(s):

  • index - The index of the custom action to return.

Return Value:

  • The custom action at the specified index (if any), otherwise null.

Attention:

See Also:

Since:

  • 4.12.1.63

String : getCustomActionDescription( Number index )

Parameter(s):

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

Return Value:

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

Since:

  • 4.11.0.164

String : getCustomActionFile( Number index )

Parameter(s):

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

Return Value:

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

String : getCustomActionIcon( Number index )

Parameter(s):

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

Return Value:

  • The icon file for the custom action at the specified index (if any), otherwise an empty string.

String : getCustomActionName( Number index )

Parameter(s):

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

Return Value:

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

String : getCustomActionScript( Number index )

Parameter(s):

  • index - 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 index )

Parameter(s):

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

Return Value:

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

Number : getCustomActionShowTextWithIcon( Number index )

Parameter(s):

  • index - The index of the custom action to check.

Return Value:

  • 1 if action text is displayed with the icon for the custom action at index, 0 if action text is not displayed with the icon, -1 if index is out of range.

Since:

  • 4.22.1.182

String : getCustomActionText( Number index )

Parameter(s):

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

Return Value:

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

String : getDocumentationUrl()

Return Value:

  • The online URL for action documentation.

Since:

  • 4.22.1.208

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 index )

Parameter(s):

  • index - 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 specified file.

Parameter(s):

  • filename - The absolute path of the interface file to load.
  • overrideDefaults - Whether 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

void : removeAllCustomActions()

Removes all custom actions from the application.


void : removeCustomAction( Number index )

Removes the custom action at the specified index.

Parameter(s):

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

Boolean : saveActionsFile( String filename )

Saves the actions to the specified file.

Parameter(s):

  • filename - The absolute path 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 custom actions to the specified file.

Parameter(s):

  • filename - The absolute path 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, persistent menus, and view tool menus to the specified file.

Parameter(s):

  • filename - The absolute path 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 specified file.

Parameter(s):

  • filename - The absolute path 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 : setCustomActionDescription( Number index, String desc )

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

Parameter(s):

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

Since:

  • 4.11.0.164

void : setCustomActionIcon( Number index, String iconFile )

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

Parameter(s):

  • index - 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 index, String script, Boolean isFile=true )

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

Parameter(s):

  • index - 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 index, String shortcut )

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

Parameter(s):

  • index - 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 index, Boolean onOff )

Sets whether the text of the action is displayed with the icon for the custom action at the specified index.

Parameter(s):

  • index - 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 index, String text )

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

Parameter(s):

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