mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
pass action label to trigger action
This commit is contained in:
parent
ce1375443f
commit
867dae4c6a
4 changed files with 34 additions and 28 deletions
|
|
@ -297,6 +297,7 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
|||
@abstractmethod
|
||||
def trigger_action(
|
||||
self,
|
||||
action_label,
|
||||
action_type,
|
||||
action_id,
|
||||
project_name,
|
||||
|
|
@ -308,6 +309,7 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
|||
"""Trigger action on given context.
|
||||
|
||||
Args:
|
||||
action_label (str): Action label.
|
||||
action_type (Literal["webaction", "local"]): Action type.
|
||||
action_id (str): Action identifier.
|
||||
project_name (Union[str, None]): Project name.
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ class BaseLauncherController(
|
|||
|
||||
def trigger_action(
|
||||
self,
|
||||
action_label,
|
||||
action_type,
|
||||
identifier,
|
||||
project_name,
|
||||
|
|
@ -146,6 +147,7 @@ class BaseLauncherController(
|
|||
addon_version,
|
||||
):
|
||||
self._actions_model.trigger_action(
|
||||
action_label,
|
||||
action_type,
|
||||
identifier,
|
||||
project_name,
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ class ActionsModel:
|
|||
|
||||
def trigger_action(
|
||||
self,
|
||||
action_label,
|
||||
acton_type,
|
||||
identifier,
|
||||
project_name,
|
||||
|
|
@ -242,6 +243,7 @@ class ActionsModel:
|
|||
):
|
||||
if acton_type == "webaction":
|
||||
self._trigger_webaction(
|
||||
action_label,
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
|
|
@ -447,6 +449,7 @@ class ActionsModel:
|
|||
|
||||
def _trigger_webaction(
|
||||
self,
|
||||
action_label,
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
|
|
@ -476,9 +479,6 @@ class ActionsModel:
|
|||
"entityIds": entity_ids,
|
||||
}
|
||||
|
||||
# TODO pass label in as argument?
|
||||
action_label = "Webaction"
|
||||
|
||||
failed = False
|
||||
error_message = None
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -438,23 +438,36 @@ class ActionsWidget(QtWidgets.QWidget):
|
|||
project_name = self._model.get_selected_project_name()
|
||||
folder_id = self._model.get_selected_folder_id()
|
||||
task_id = self._model.get_selected_task_id()
|
||||
if is_group:
|
||||
action_item = self._show_menu_on_group(action_id)
|
||||
if action_item is None:
|
||||
return
|
||||
|
||||
if not is_group:
|
||||
action_id = action_item.identifier
|
||||
action_label = action_item.full_label
|
||||
action_type = action_item.action_type
|
||||
addon_name = action_item.addon_name
|
||||
addon_version = action_item.addon_version
|
||||
else:
|
||||
action_label = index.data(QtCore.Qt.DisplayRole)
|
||||
action_type = index.data(ACTION_TYPE_ROLE)
|
||||
addon_name = index.data(ACTION_ADDON_NAME_ROLE)
|
||||
addon_version = index.data(ACTION_ADDON_VERSION_ROLE)
|
||||
self._controller.trigger_action(
|
||||
action_type,
|
||||
action_id,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
addon_name,
|
||||
addon_version,
|
||||
)
|
||||
self._start_animation(index)
|
||||
return
|
||||
|
||||
self._controller.trigger_action(
|
||||
action_label,
|
||||
action_type,
|
||||
action_id,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
addon_name,
|
||||
addon_version,
|
||||
)
|
||||
self._start_animation(index)
|
||||
self._start_animation(index)
|
||||
|
||||
def _show_menu_on_group(self, action_id):
|
||||
action_items = self._model.get_group_items(action_id)
|
||||
|
||||
menu = QtWidgets.QMenu(self)
|
||||
|
|
@ -467,20 +480,9 @@ class ActionsWidget(QtWidgets.QWidget):
|
|||
|
||||
result = menu.exec_(QtGui.QCursor.pos())
|
||||
if not result:
|
||||
return
|
||||
return None
|
||||
|
||||
action_item = actions_mapping[result]
|
||||
|
||||
self._controller.trigger_action(
|
||||
action_item.action_type,
|
||||
action_item.identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
action_item.addon_name,
|
||||
action_item.addon_version,
|
||||
)
|
||||
self._start_animation(index)
|
||||
return actions_mapping[result]
|
||||
|
||||
def _on_context_menu(self, point):
|
||||
"""Creates menu to force skip opening last workfile."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue