From 867dae4c6af3fd4e64a6727b22e6a0991311b2b2 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 22 Apr 2025 12:12:24 +0200 Subject: [PATCH] pass action label to trigger action --- client/ayon_core/tools/launcher/abstract.py | 2 + client/ayon_core/tools/launcher/control.py | 2 + .../tools/launcher/models/actions.py | 6 +-- .../tools/launcher/ui/actions_widget.py | 52 ++++++++++--------- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/client/ayon_core/tools/launcher/abstract.py b/client/ayon_core/tools/launcher/abstract.py index dd65c95167..c62faa28db 100644 --- a/client/ayon_core/tools/launcher/abstract.py +++ b/client/ayon_core/tools/launcher/abstract.py @@ -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. diff --git a/client/ayon_core/tools/launcher/control.py b/client/ayon_core/tools/launcher/control.py index 445b17ac38..cdd8806421 100644 --- a/client/ayon_core/tools/launcher/control.py +++ b/client/ayon_core/tools/launcher/control.py @@ -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, diff --git a/client/ayon_core/tools/launcher/models/actions.py b/client/ayon_core/tools/launcher/models/actions.py index 9e566f5958..e36143f9df 100644 --- a/client/ayon_core/tools/launcher/models/actions.py +++ b/client/ayon_core/tools/launcher/models/actions.py @@ -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: diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 99fd249918..69b5f76c29 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -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."""