diff --git a/client/ayon_core/tools/launcher/models/actions.py b/client/ayon_core/tools/launcher/models/actions.py index 8d7da2748b..6b9a33e57a 100644 --- a/client/ayon_core/tools/launcher/models/actions.py +++ b/client/ayon_core/tools/launcher/models/actions.py @@ -293,6 +293,34 @@ class ActionsModel: self._get_action_objects() self._controller.emit_event("actions.refresh.finished") + def _should_start_last_workfile( + self, + project_name, + task_id, + identifier, + host_name, + not_open_workfile_actions + ): + from ayon_core.lib.applications import should_start_last_workfile + + if identifier in not_open_workfile_actions: + return not not_open_workfile_actions[identifier] + + task_name = None + task_type = None + if task_id is not None: + task = self._controller.get_task_entity(project_name, task_id) + task_name = task["name"] + task_type = task["taskType"] + + output = should_start_last_workfile( + project_name, + host_name, + task_name, + task_type + ) + return output + def get_action_items(self, project_name, folder_id, task_id): """Get actions for project. @@ -304,7 +332,6 @@ class ActionsModel: Returns: list[ActionItem]: List of actions. """ - not_open_workfile_actions = self._get_no_last_workfile_for_context( project_name, folder_id, task_id) session = self._prepare_session(project_name, folder_id, task_id) @@ -318,8 +345,15 @@ class ActionsModel: # Handling of 'force_not_open_workfile' for applications if action_item.is_application: action_item = action_item.copy() + start_last_workfile = self._should_start_last_workfile( + project_name, + task_id, + identifier, + action.application.host_name, + not_open_workfile_actions + ) action_item.force_not_open_workfile = ( - not_open_workfile_actions.get(identifier, False) + not start_last_workfile ) output.append(action_item) @@ -359,11 +393,15 @@ class ActionsModel: per_action = self._get_no_last_workfile_for_context( project_name, folder_id, task_id ) - force_not_open_workfile = per_action.get(identifier, False) - if force_not_open_workfile: - action.data["start_last_workfile"] = False - else: - action.data.pop("start_last_workfile", None) + start_last_workfile = self._should_start_last_workfile( + project_name, + task_id, + identifier, + action.application.host_name, + per_action + ) + action.data["start_last_workfile"] = start_last_workfile + action.process(session) except Exception as exc: self.log.warning("Action trigger failed.", exc_info=True) @@ -461,9 +499,11 @@ class ActionsModel: if is_application: action.project_entities[project_name] = project_entity action.project_settings[project_name] = project_settings + label = action.label or identifier variant_label = getattr(action, "label_variant", None) icon = get_action_icon(action) + item = ActionItem( identifier, label, diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 6667b4ed5f..617f3b0c91 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -358,6 +358,8 @@ class ActionsWidget(QtWidgets.QWidget): def _on_model_refresh(self): self._proxy_model.sort(0) + # Force repaint all items + self._view.update() def _on_animation(self): time_now = time.time()