Merge pull request #118 from ynput/enhancement/OP-6968_Invert-the-logic-of-Skip-Opening-of-Last-Workfile

Launcher: Invert the logic of skip opening of last workfile - OP-6968
This commit is contained in:
Jakub Trllo 2024-02-28 12:27:42 +01:00 committed by GitHub
commit e567c2d05b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 49 additions and 7 deletions

View file

@ -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,

View file

@ -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()