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

Parameter(s):

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

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

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

DzAction : findPaneAction( String identifier )

Parameter(s):

  • identifier - The classname of the DzPane, or in the case of a custom pane the globally unique identifier, to find the action for.

Return Value:

  • The action that toggles visibility of the given 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 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 i )

Parameter(s):

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

DzAction : getCustomActionByIndex( Number i )

Parameter(s):

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

Return Value:

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

Attention:

See Also:

Since:

  • 4.12.1.63

String : getCustomActionDescription( Number i )

Parameter(s):

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

Since:

  • 4.11.0.164

String : getCustomActionFile( Number i )

Parameter(s):

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

Parameter(s):

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

Parameter(s):

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

Parameter(s):

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

Parameter(s):

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

Parameter(s):

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

Parameter(s):

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

void : removeAllCustomActions()

Removes all custom actions from the application.


void : removeCustomAction( Number i )

Removes the custom action at the given index.

Parameter(s):

  • i - 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 i, String desc )

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

Parameter(s):

  • i - 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 i, String iconFile )

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

Parameter(s):

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

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

Parameter(s):

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

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

Parameter(s):

  • i - 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 i, 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):

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

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

Parameter(s):

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