From 36f14182cde2bd2cb3407a2cc70fc4224ccb4475 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 3 Feb 2022 18:03:31 +0100 Subject: [PATCH 1/8] Improve UI updates during processing - This now defaults to having "animations" disabled - with the small timeout that was there '3' that didn't visually show anyway. So disabling them doesn't make much of a difference, except for that the UI correctly updates to the latest state. --- openpype/tools/pyblish_pype/control.py | 8 ++++++-- openpype/tools/pyblish_pype/settings.py | 2 +- openpype/tools/pyblish_pype/window.py | 9 --------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/openpype/tools/pyblish_pype/control.py b/openpype/tools/pyblish_pype/control.py index 64a7f193b4..b20adc0056 100644 --- a/openpype/tools/pyblish_pype/control.py +++ b/openpype/tools/pyblish_pype/control.py @@ -11,7 +11,7 @@ import inspect import logging import collections -from Qt import QtCore +from Qt import QtCore, QtWidgets import pyblish.api import pyblish.util @@ -47,7 +47,7 @@ class MainThreadProcess(QtCore.QObject): This approach gives ability to update UI meanwhile plugin is in progress. """ - timer_interval = 3 + timer_interval = 0 def __init__(self): super(MainThreadProcess, self).__init__() @@ -74,6 +74,10 @@ class MainThreadProcess(QtCore.QObject): item = self._items_to_process.popleft() item.process() + # Process events directly after the item processed. This allows the + # to correctly show "highlighted" state for the next item to process + QtWidgets.QApplication.instance().processEvents() + def start(self): if not self._timer.isActive(): self._timer.start() diff --git a/openpype/tools/pyblish_pype/settings.py b/openpype/tools/pyblish_pype/settings.py index 11539f67a6..9b6498b3f4 100644 --- a/openpype/tools/pyblish_pype/settings.py +++ b/openpype/tools/pyblish_pype/settings.py @@ -24,4 +24,4 @@ TerminalFilters = { } # Allow animations in GUI -Animated = env_variable_to_bool("OPENPYPE_PYBLISH_ANIMATED", True) +Animated = env_variable_to_bool("OPENPYPE_PYBLISH_ANIMATED", False) diff --git a/openpype/tools/pyblish_pype/window.py b/openpype/tools/pyblish_pype/window.py index edcf6f53b6..74a116cb6f 100644 --- a/openpype/tools/pyblish_pype/window.py +++ b/openpype/tools/pyblish_pype/window.py @@ -307,11 +307,6 @@ class Window(QtWidgets.QDialog): on.setStartValue(0) on.setEndValue(1) - off = QtCore.QPropertyAnimation(info_effect, b"opacity") - off.setDuration(0) - off.setStartValue(1) - off.setEndValue(0) - fade = QtCore.QPropertyAnimation(info_effect, b"opacity") fade.setDuration(500) fade.setStartValue(1.0) @@ -319,10 +314,6 @@ class Window(QtWidgets.QDialog): animation_info_msg = QtCore.QSequentialAnimationGroup() animation_info_msg.addAnimation(on) - animation_info_msg.addPause(50) - animation_info_msg.addAnimation(off) - animation_info_msg.addPause(50) - animation_info_msg.addAnimation(on) animation_info_msg.addPause(2000) animation_info_msg.addAnimation(fade) From 796db6a3fc74e3b9e576ffa94f13e40b33f269e5 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 3 Feb 2022 23:51:18 +0100 Subject: [PATCH 2/8] Fix typo --- openpype/tools/pyblish_pype/control.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/tools/pyblish_pype/control.py b/openpype/tools/pyblish_pype/control.py index b20adc0056..ffc709f162 100644 --- a/openpype/tools/pyblish_pype/control.py +++ b/openpype/tools/pyblish_pype/control.py @@ -74,8 +74,8 @@ class MainThreadProcess(QtCore.QObject): item = self._items_to_process.popleft() item.process() - # Process events directly after the item processed. This allows the - # to correctly show "highlighted" state for the next item to process + # Process events directly after the item processed. This allows to + # correctly show "highlighted" state for the next item to process QtWidgets.QApplication.instance().processEvents() def start(self): From 4c7f36158439a8752c166895ce0d0e4570a808a0 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 4 Feb 2022 01:09:15 +0100 Subject: [PATCH 3/8] handle animations during processing --- openpype/tools/pyblish_pype/view.py | 4 +--- openpype/tools/pyblish_pype/window.py | 13 +++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/openpype/tools/pyblish_pype/view.py b/openpype/tools/pyblish_pype/view.py index 7245393714..3b75e67d4c 100644 --- a/openpype/tools/pyblish_pype/view.py +++ b/openpype/tools/pyblish_pype/view.py @@ -16,7 +16,7 @@ class OverviewView(QtWidgets.QTreeView): toggled = QtCore.Signal(QtCore.QModelIndex, object) show_perspective = QtCore.Signal(QtCore.QModelIndex) - def __init__(self, animated, parent=None): + def __init__(self, parent=None): super(OverviewView, self).__init__(parent) self.horizontalScrollBar().hide() @@ -28,8 +28,6 @@ class OverviewView(QtWidgets.QTreeView): self.setHeaderHidden(True) self.setRootIsDecorated(False) self.setIndentation(0) - if animated: - self.setAnimated(True) def event(self, event): if not event.type() == QtCore.QEvent.KeyPress: diff --git a/openpype/tools/pyblish_pype/window.py b/openpype/tools/pyblish_pype/window.py index 74a116cb6f..3f9cd17deb 100644 --- a/openpype/tools/pyblish_pype/window.py +++ b/openpype/tools/pyblish_pype/window.py @@ -143,9 +143,8 @@ class Window(QtWidgets.QDialog): # TODO add parent overview_page = QtWidgets.QWidget() - overview_instance_view = view.InstanceView( - animated=settings.Animated, parent=overview_page - ) + overview_instance_view = view.InstanceView(parent=overview_page) + overview_instance_view.setAnimated(settings.Animated) overview_instance_delegate = delegate.InstanceDelegate( parent=overview_instance_view ) @@ -156,9 +155,8 @@ class Window(QtWidgets.QDialog): overview_instance_view.setItemDelegate(overview_instance_delegate) overview_instance_view.setModel(instance_sort_proxy) - overview_plugin_view = view.PluginView( - animated=settings.Animated, parent=overview_page - ) + overview_plugin_view = view.PluginView(parent=overview_page) + overview_plugin_view.setAnimated(settings.Animated) overview_plugin_delegate = delegate.PluginDelegate( parent=overview_plugin_view ) @@ -1014,9 +1012,11 @@ class Window(QtWidgets.QDialog): {GroupStates.HasFinished: True}, Roles.PublishFlagsRole ) + self.overview_plugin_view.setAnimated(False) self.overview_plugin_view.collapse(group_index) def on_was_stopped(self): + self.overview_plugin_view.setAnimated(settings.Animated) errored = self.controller.errored if self.controller.collect_state == 0: self.footer_button_play.setEnabled(False) @@ -1048,6 +1048,7 @@ class Window(QtWidgets.QDialog): ) def on_was_finished(self): + self.overview_plugin_view.setAnimated(settings.Animated) self.footer_button_play.setEnabled(False) self.footer_button_validate.setEnabled(False) self.footer_button_reset.setEnabled(True) From 8c963726ddd929e2f63744cea1156bf3f2d4526c Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 4 Feb 2022 01:10:16 +0100 Subject: [PATCH 4/8] enable animations by default --- openpype/tools/pyblish_pype/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/tools/pyblish_pype/settings.py b/openpype/tools/pyblish_pype/settings.py index 9b6498b3f4..11539f67a6 100644 --- a/openpype/tools/pyblish_pype/settings.py +++ b/openpype/tools/pyblish_pype/settings.py @@ -24,4 +24,4 @@ TerminalFilters = { } # Allow animations in GUI -Animated = env_variable_to_bool("OPENPYPE_PYBLISH_ANIMATED", False) +Animated = env_variable_to_bool("OPENPYPE_PYBLISH_ANIMATED", True) From f13c83eb5e0f2c49d272bb3c7310711db6d184a4 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 4 Feb 2022 09:32:31 +0100 Subject: [PATCH 5/8] Allow disabling of printing to console via settings (or env var) --- openpype/tools/pyblish_pype/settings.py | 3 +++ openpype/tools/pyblish_pype/window.py | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openpype/tools/pyblish_pype/settings.py b/openpype/tools/pyblish_pype/settings.py index 11539f67a6..aaa35d0b56 100644 --- a/openpype/tools/pyblish_pype/settings.py +++ b/openpype/tools/pyblish_pype/settings.py @@ -25,3 +25,6 @@ TerminalFilters = { # Allow animations in GUI Animated = env_variable_to_bool("OPENPYPE_PYBLISH_ANIMATED", True) + +# Print UI info message to console +PrintInfo = env_variable_to_bool("OPENPYPE_PYBLISH_PRINT_INFO", True) diff --git a/openpype/tools/pyblish_pype/window.py b/openpype/tools/pyblish_pype/window.py index 3f9cd17deb..7bb11745d6 100644 --- a/openpype/tools/pyblish_pype/window.py +++ b/openpype/tools/pyblish_pype/window.py @@ -1305,9 +1305,9 @@ class Window(QtWidgets.QDialog): self.animation_info_msg.stop() self.animation_info_msg.start() - # TODO(marcus): Should this be configurable? Do we want - # the shell to fill up with these messages? - util.u_print(message) + if settings.PrintInfo: + # Print message to console + util.u_print(message) def warning(self, message): """Block processing and print warning until user hits "Continue" From 6c129320941dd316615371369b3994a8f4b1c3ef Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 4 Feb 2022 09:33:21 +0100 Subject: [PATCH 6/8] Revert timer interval to 3 --- openpype/tools/pyblish_pype/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/tools/pyblish_pype/control.py b/openpype/tools/pyblish_pype/control.py index ffc709f162..9ad6ad0d4d 100644 --- a/openpype/tools/pyblish_pype/control.py +++ b/openpype/tools/pyblish_pype/control.py @@ -47,7 +47,7 @@ class MainThreadProcess(QtCore.QObject): This approach gives ability to update UI meanwhile plugin is in progress. """ - timer_interval = 0 + timer_interval = 3 def __init__(self): super(MainThreadProcess, self).__init__() From 90ad762f9f61577e95fb0b5c90cc646611d588a7 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Sun, 6 Feb 2022 12:43:32 +0100 Subject: [PATCH 7/8] avoid using processEvents with passing 2 qapplication loops --- openpype/tools/pyblish_pype/control.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/openpype/tools/pyblish_pype/control.py b/openpype/tools/pyblish_pype/control.py index 9ad6ad0d4d..d20f7c46e7 100644 --- a/openpype/tools/pyblish_pype/control.py +++ b/openpype/tools/pyblish_pype/control.py @@ -47,18 +47,22 @@ class MainThreadProcess(QtCore.QObject): This approach gives ability to update UI meanwhile plugin is in progress. """ - timer_interval = 3 + # How many times let pass QtApplication to process events + # - use 2 as resize event can trigger repaint event but not process in + # same loop + count_timeout = 2 def __init__(self): super(MainThreadProcess, self).__init__() self._items_to_process = collections.deque() timer = QtCore.QTimer() - timer.setInterval(self.timer_interval) + timer.setInterval(0) timer.timeout.connect(self._execute) self._timer = timer + self._switch_counter = self.count_timeout def process(self, func, *args, **kwargs): item = MainThreadItem(func, *args, **kwargs) @@ -71,13 +75,15 @@ class MainThreadProcess(QtCore.QObject): if not self._items_to_process: return + if self._switch_counter > 0: + self._switch_counter -= 1 + return + + self._switch_counter = self.count_timeout + item = self._items_to_process.popleft() item.process() - # Process events directly after the item processed. This allows to - # correctly show "highlighted" state for the next item to process - QtWidgets.QApplication.instance().processEvents() - def start(self): if not self._timer.isActive(): self._timer.start() From 2142e5cfbe4d6889f1af6ad83762c0899b3f3b93 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Sat, 12 Feb 2022 10:05:11 +0100 Subject: [PATCH 8/8] Remove unused import --- openpype/tools/pyblish_pype/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/tools/pyblish_pype/control.py b/openpype/tools/pyblish_pype/control.py index d20f7c46e7..9774c8020b 100644 --- a/openpype/tools/pyblish_pype/control.py +++ b/openpype/tools/pyblish_pype/control.py @@ -11,7 +11,7 @@ import inspect import logging import collections -from Qt import QtCore, QtWidgets +from Qt import QtCore import pyblish.api import pyblish.util