Merge pull request #2793 from BigRoy/pyblish_pype_preserve_comment_on_reset

Pyblish Pype: Preserve comment on reset
This commit is contained in:
Milan Kolar 2022-02-23 18:01:48 +01:00 committed by GitHub
commit c0dde86027
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

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

View file

@ -228,6 +228,16 @@ 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") 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()
self.context._publish_states = InstanceStates.ContextType
@ -249,6 +259,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):

View file

@ -1139,9 +1139,10 @@ class Window(QtWidgets.QDialog):
self.intent_box.setCurrentIndex(self.intent_model.default_index)
self.comment_box.placeholder.setVisible(False)
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.."))