Merge pull request #2646 from BigRoy/pyblish_pype_update

Pyblish Pype: Improve UI updates during processing
This commit is contained in:
Jakub Trllo 2022-02-12 10:21:28 +01:00 committed by GitHub
commit 3d1ad12581
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 23 deletions

View file

@ -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,6 +75,12 @@ 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()

View file

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

View file

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

View file

@ -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
)
@ -307,11 +305,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 +312,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)
@ -1023,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)
@ -1057,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)
@ -1313,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"