From 455acfaae9cee59b6a864b1c7fae0732ba55faef Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 25 Jun 2021 15:10:43 +0200 Subject: [PATCH] paste_value_to_path is simplified --- openpype/tools/settings/settings/base.py | 29 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/openpype/tools/settings/settings/base.py b/openpype/tools/settings/settings/base.py index 09a36cd99b..40a6562fd0 100644 --- a/openpype/tools/settings/settings/base.py +++ b/openpype/tools/settings/settings/base.py @@ -195,6 +195,26 @@ class BaseWidget(QtWidgets.QWidget): path = mime_data_value["path"] root_key = mime_data_value["root_key"] + # Try to find matching entity to be able paste values to same spot + # - entity can't by dynamic or in dynamic item + # - must be in same root entity as source copy + # Can't copy system settings <-> project settings + matching_entity = None + if path and root_key == self.entity.root_key: + try: + matching_entity = self.entity.get_entity_from_path(path) + except Exception: + pass + + # Paste value to matchin entity + def paste_value_to_path(): + matching_entity.set(value) + + if matching_entity is not None: + action = QtWidgets.QAction("Paste to same entity", menu) + actions_mapping[action] = paste_value_to_path + menu.addAction(action) + def paste_value(): try: self.entity.set(value) @@ -208,15 +228,6 @@ class BaseWidget(QtWidgets.QWidget): )) dialog.exec_() - def paste_value_to_path(): - entity = self.entity.get_entity_from_path(path) - entity.set(value) - - if path and root_key == self.entity.root_key: - action = QtWidgets.QAction("Paste to same entity") - actions_mapping[action] = paste_value_to_path - menu.addAction(action) - action = QtWidgets.QAction("Paste") actions_mapping[action] = paste_value menu.addAction(action)