From 4d44a374ae1ced9f03c95006e614e08982d452c8 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 22 Feb 2022 15:15:12 +0100 Subject: [PATCH 1/5] Preserve comment on reset --- openpype/tools/pyblish_pype/control.py | 8 ++++++++ openpype/tools/pyblish_pype/window.py | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/openpype/tools/pyblish_pype/control.py b/openpype/tools/pyblish_pype/control.py index 455a338499..d479124be1 100644 --- a/openpype/tools/pyblish_pype/control.py +++ b/openpype/tools/pyblish_pype/control.py @@ -228,6 +228,10 @@ class Controller(QtCore.QObject): def reset_context(self): self.log.debug("Resetting pyblish context object") + comment = None + if self.context is not None and self.context.data.get("comment"): + comment = self.context.data["comment"] + self.context = pyblish.api.Context() self.context._publish_states = InstanceStates.ContextType @@ -249,6 +253,10 @@ class Controller(QtCore.QObject): self.context.families = ("__context__",) + if comment: + # Preserve comment on reset if user previously had a comment + self.context.data["comment"] = comment + self.log.debug("Reset of pyblish context object done") def reset(self): diff --git a/openpype/tools/pyblish_pype/window.py b/openpype/tools/pyblish_pype/window.py index 38907c1a52..ef9be8093c 100644 --- a/openpype/tools/pyblish_pype/window.py +++ b/openpype/tools/pyblish_pype/window.py @@ -1138,8 +1138,9 @@ class Window(QtWidgets.QDialog): if self.intent_model.has_items: self.intent_box.setCurrentIndex(self.intent_model.default_index) - self.comment_box.placeholder.setVisible(False) - self.comment_box.placeholder.setVisible(True) + if self.comment_box.text(): + self.comment_box.placeholder.setVisible(False) + self.comment_box.placeholder.setVisible(True) # Launch controller reset self.controller.reset() From f6e9d688c61765b098d09a15633700cbf3b25e1d Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 22 Feb 2022 15:42:02 +0100 Subject: [PATCH 2/5] fix visibility of placeholder after reset --- openpype/tools/pyblish_pype/window.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/tools/pyblish_pype/window.py b/openpype/tools/pyblish_pype/window.py index ef9be8093c..2195f6f44e 100644 --- a/openpype/tools/pyblish_pype/window.py +++ b/openpype/tools/pyblish_pype/window.py @@ -1138,8 +1138,8 @@ class Window(QtWidgets.QDialog): if self.intent_model.has_items: self.intent_box.setCurrentIndex(self.intent_model.default_index) - if self.comment_box.text(): - self.comment_box.placeholder.setVisible(False) + self.comment_box.placeholder.setVisible(False) + if not self.comment_box.text(): self.comment_box.placeholder.setVisible(True) # Launch controller reset self.controller.reset() From a7f15cd21b949efeae8e5325e858af21c1c1c8a3 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Feb 2022 11:29:18 +0100 Subject: [PATCH 3/5] Controller is only used when creating a new window --- openpype/tools/pyblish_pype/app.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openpype/tools/pyblish_pype/app.py b/openpype/tools/pyblish_pype/app.py index d15d586103..a252b96427 100644 --- a/openpype/tools/pyblish_pype/app.py +++ b/openpype/tools/pyblish_pype/app.py @@ -90,9 +90,8 @@ def show(parent=None): install_fonts() install_translator(app) - ctrl = control.Controller() - if self._window is None: + ctrl = control.Controller() self._window = window.Window(ctrl, parent) self._window.destroyed.connect(on_destroyed) From 6ed4497444bec2ec7bfe2d8eab1da7470e63224c Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Feb 2022 11:33:18 +0100 Subject: [PATCH 4/5] Ensure comment content is checked after the controller reset --- openpype/tools/pyblish_pype/window.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/tools/pyblish_pype/window.py b/openpype/tools/pyblish_pype/window.py index 2195f6f44e..d27ec34345 100644 --- a/openpype/tools/pyblish_pype/window.py +++ b/openpype/tools/pyblish_pype/window.py @@ -1139,10 +1139,10 @@ class Window(QtWidgets.QDialog): self.intent_box.setCurrentIndex(self.intent_model.default_index) self.comment_box.placeholder.setVisible(False) - if not self.comment_box.text(): - self.comment_box.placeholder.setVisible(True) # Launch controller reset self.controller.reset() + if not self.comment_box.text(): + self.comment_box.placeholder.setVisible(True) def validate(self): self.info(self.tr("Preparing validate..")) From ece0d0cdcd8d7f24caa996c00ce6dae8ed18b4ee Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Feb 2022 11:34:28 +0100 Subject: [PATCH 5/5] Clear comment on reset after successful publish --- openpype/tools/pyblish_pype/control.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openpype/tools/pyblish_pype/control.py b/openpype/tools/pyblish_pype/control.py index d479124be1..6f89952c22 100644 --- a/openpype/tools/pyblish_pype/control.py +++ b/openpype/tools/pyblish_pype/control.py @@ -229,7 +229,13 @@ class Controller(QtCore.QObject): self.log.debug("Resetting pyblish context object") comment = None - if self.context is not None and self.context.data.get("comment"): + if ( + self.context is not None and + self.context.data.get("comment") and + # We only preserve the user typed comment if we are *not* + # resetting from a successful publish without errors + self._current_state != "Published" + ): comment = self.context.data["comment"] self.context = pyblish.api.Context()