add shortcut to action if in configuration (#4927)

Co-authored-by: Thomas Fricard <tfricard@ws114.prs.vfx.int>
This commit is contained in:
Thomas Fricard 2023-05-12 14:57:17 +02:00 committed by GitHub
parent 592d0ac908
commit 6968c7c8ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,9 +19,9 @@ class ScriptsMenu(QtWidgets.QMenu):
Args:
title (str): the name of the root menu which will be created
parent (QtWidgets.QObject) : the QObject to parent the menu to
Returns:
None
@ -94,7 +94,7 @@ class ScriptsMenu(QtWidgets.QMenu):
parent(QtWidgets.QWidget): the object to parent the menu to
title(str): the title of the menu
Returns:
QtWidget.QMenu instance
"""
@ -111,7 +111,7 @@ class ScriptsMenu(QtWidgets.QMenu):
return menu
def add_script(self, parent, title, command, sourcetype, icon=None,
tags=None, label=None, tooltip=None):
tags=None, label=None, tooltip=None, shortcut=None):
"""Create an action item which runs a script when clicked
Args:
@ -134,6 +134,8 @@ class ScriptsMenu(QtWidgets.QMenu):
tooltip (str): A tip for the user about the usage fo the tool
shortcut (str): A shortcut to run the command
Returns:
QtWidget.QAction instance
@ -166,6 +168,9 @@ class ScriptsMenu(QtWidgets.QMenu):
raise RuntimeError("Script action can't be "
"processed: {}".format(e))
if shortcut:
script_action.setShortcut(shortcut)
if icon:
iconfile = os.path.expandvars(icon)
script_action.iconfile = iconfile
@ -253,7 +258,7 @@ class ScriptsMenu(QtWidgets.QMenu):
def _update_search(self, search):
"""Hide all the samples which do not match the user's import
Returns:
None