Skip to content

Commit

Permalink
DispatcherUI : Restore "Ctrl + R" shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Feb 7, 2024
1 parent 957ab7f commit b6274ad
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
48 changes: 42 additions & 6 deletions python/GafferDispatchUI/DispatcherUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,47 @@

)

##################################################################################
# Dispatch
##################################################################################

def appendMenuDefinitions( menuDefinition, prefix = "" ) :

menuDefinition.append(
prefix + "/Repeat Previous",
{
"command" : __repeatLastDispatch,
"shortCut" : "Ctrl+R",
"active" : lambda menu : __getLastDispatcher( menu.ancestor( GafferUI.ScriptWindow ).scriptNode() ) is not None
}
)

def _dispatch( dispatcher, parentWindow ) :

with dispatcher.scriptNode().context() :
with GafferUI.ErrorDialogue.ErrorHandler(
title = "Errors Occurred During Dispatch",
parentWindow = parentWindow
) :
dispatcher["task"].execute()
__setLastDispatcher( dispatcher.scriptNode(), dispatcher )

def __setLastDispatcher( script, dispatcher ) :

GafferUI.ScriptWindow.acquire( script ).__lastDispatcher = weakref.ref( dispatcher )

def __getLastDispatcher( script ) :

try :
return GafferUI.ScriptWindow.acquire( script ).__lastDispatcher()
except AttributeError :
return None

def __repeatLastDispatch( menu ) :

scriptWindow = menu.ancestor( GafferUI.ScriptWindow )
_dispatch( __getLastDispatcher( scriptWindow.scriptNode() ), scriptWindow )

##################################################################################
# DispatchButton
##################################################################################
Expand All @@ -166,12 +207,7 @@ def __init__( self, node, **kw ) :

def __clicked( self, button ) :

with self.__node.scriptNode().context() :
with GafferUI.ErrorDialogue.ErrorHandler(
title = "Errors Occurred During Dispatch",
parentWindow = self.ancestor( GafferUI.Window )
) :
self.__node["task"].execute()
_dispatch( self.__node, self.ancestor( GafferUI.Window ) )

##########################################################################
# Additional Metadata for TaskNode
Expand Down
2 changes: 2 additions & 0 deletions startup/gui/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ def __usdLightCreator( lightType ) :
GafferTractor.tractorAPI()
nodeMenu.append( "/Dispatch/Tractor Dispatcher", GafferTractor.TractorDispatcher, searchText = "TractorDispatcher" )

GafferDispatchUI.DispatcherUI.appendMenuDefinitions( scriptWindowMenu, "/Tools/Dispatch" )

## Metadata cleanup
###########################################################################

Expand Down

0 comments on commit b6274ad

Please sign in to comment.