Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launcher: Invert the logic of skip opening of last workfile - OP-6968 #118

54 changes: 47 additions & 7 deletions client/ayon_core/tools/launcher/models/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,34 @@ def refresh(self):
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.

Expand All @@ -304,7 +332,6 @@ def get_action_items(self, project_name, folder_id, task_id):
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)
Expand All @@ -318,8 +345,15 @@ def get_action_items(self, project_name, folder_id, task_id):
# 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)
Expand Down Expand Up @@ -359,11 +393,15 @@ def trigger_action(self, project_name, folder_id, task_id, identifier):
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)
Expand Down Expand Up @@ -461,9 +499,11 @@ def _get_action_items(self, project_name):
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,
Expand Down
2 changes: 2 additions & 0 deletions client/ayon_core/tools/launcher/ui/actions_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ def _set_row_height(self, rows):

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()
Expand Down