mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #3822 from pypeclub/bugfix/OP-3606_Skip-opening-last-work-file
Launcher: Skip opening last work file works for groups
This commit is contained in:
commit
e84263524e
2 changed files with 42 additions and 23 deletions
|
|
@ -281,18 +281,25 @@ class ActionModel(QtGui.QStandardItemModel):
|
|||
if not action_item:
|
||||
return
|
||||
|
||||
action = action_item.data(ACTION_ROLE)
|
||||
actual_data = self._prepare_compare_data(action)
|
||||
actions = action_item.data(ACTION_ROLE)
|
||||
if not isinstance(actions, list):
|
||||
actions = [actions]
|
||||
|
||||
action_actions_data = [
|
||||
self._prepare_compare_data(action)
|
||||
for action in actions
|
||||
]
|
||||
|
||||
stored = self.launcher_registry.get_item("force_not_open_workfile")
|
||||
if is_checked:
|
||||
stored.append(actual_data)
|
||||
else:
|
||||
final_values = []
|
||||
for config in stored:
|
||||
if config != actual_data:
|
||||
final_values.append(config)
|
||||
stored = final_values
|
||||
for actual_data in action_actions_data:
|
||||
if is_checked:
|
||||
stored.append(actual_data)
|
||||
else:
|
||||
final_values = []
|
||||
for config in stored:
|
||||
if config != actual_data:
|
||||
final_values.append(config)
|
||||
stored = final_values
|
||||
|
||||
self.launcher_registry.set_item("force_not_open_workfile", stored)
|
||||
self.launcher_registry._get_item.cache_clear()
|
||||
|
|
@ -329,21 +336,24 @@ class ActionModel(QtGui.QStandardItemModel):
|
|||
item (QStandardItem)
|
||||
stored (list) of dict
|
||||
"""
|
||||
action = item.data(ACTION_ROLE)
|
||||
if not self.is_application_action(action):
|
||||
|
||||
actions = item.data(ACTION_ROLE)
|
||||
if not isinstance(actions, list):
|
||||
actions = [actions]
|
||||
|
||||
if not self.is_application_action(actions[0]):
|
||||
return False
|
||||
|
||||
actual_data = self._prepare_compare_data(action)
|
||||
action_actions_data = [
|
||||
self._prepare_compare_data(action)
|
||||
for action in actions
|
||||
]
|
||||
for config in stored:
|
||||
if config == actual_data:
|
||||
if config in action_actions_data:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def _prepare_compare_data(self, action):
|
||||
if isinstance(action, list) and action:
|
||||
action = action[0]
|
||||
|
||||
compare_data = {}
|
||||
if action and action.label:
|
||||
compare_data = {
|
||||
|
|
|
|||
|
|
@ -312,11 +312,12 @@ class ActionBar(QtWidgets.QWidget):
|
|||
|
||||
is_group = index.data(GROUP_ROLE)
|
||||
is_variant_group = index.data(VARIANT_GROUP_ROLE)
|
||||
force_not_open_workfile = index.data(FORCE_NOT_OPEN_WORKFILE_ROLE)
|
||||
if not is_group and not is_variant_group:
|
||||
action = index.data(ACTION_ROLE)
|
||||
# Change data of application action
|
||||
if issubclass(action, ApplicationAction):
|
||||
if index.data(FORCE_NOT_OPEN_WORKFILE_ROLE):
|
||||
if force_not_open_workfile:
|
||||
action.data["start_last_workfile"] = False
|
||||
else:
|
||||
action.data.pop("start_last_workfile", None)
|
||||
|
|
@ -385,10 +386,18 @@ class ActionBar(QtWidgets.QWidget):
|
|||
menu.addMenu(sub_menu)
|
||||
|
||||
result = menu.exec_(QtGui.QCursor.pos())
|
||||
if result:
|
||||
action = actions_mapping[result]
|
||||
self._start_animation(index)
|
||||
self.action_clicked.emit(action)
|
||||
if not result:
|
||||
return
|
||||
|
||||
action = actions_mapping[result]
|
||||
if issubclass(action, ApplicationAction):
|
||||
if force_not_open_workfile:
|
||||
action.data["start_last_workfile"] = False
|
||||
else:
|
||||
action.data.pop("start_last_workfile", None)
|
||||
|
||||
self._start_animation(index)
|
||||
self.action_clicked.emit(action)
|
||||
|
||||
|
||||
class ActionHistory(QtWidgets.QPushButton):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue