Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2646 from BigRoy/pyblish_pype_update
Browse files Browse the repository at this point in the history
Pyblish Pype: Improve UI updates during processing
  • Loading branch information
iLLiCiTiT authored Feb 12, 2022
2 parents 6964507 + 2142e5c commit 3d1ad12
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
14 changes: 12 additions & 2 deletions openpype/tools/pyblish_pype/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -71,6 +75,12 @@ def _execute(self):
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()

Expand Down
3 changes: 3 additions & 0 deletions openpype/tools/pyblish_pype/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@

# 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)
4 changes: 1 addition & 3 deletions openpype/tools/pyblish_pype/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -28,8 +28,6 @@ def __init__(self, animated, parent=None):
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:
Expand Down
28 changes: 10 additions & 18 deletions openpype/tools/pyblish_pype/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ def __init__(self, controller, parent=None):
# 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
)
Expand All @@ -156,9 +155,8 @@ def __init__(self, controller, parent=None):
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
)
Expand Down Expand Up @@ -307,22 +305,13 @@ def __init__(self, controller, parent=None):
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)
fade.setEndValue(0.0)

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)

Expand Down Expand Up @@ -1023,9 +1012,11 @@ def on_passed_group(self, order):
{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)
Expand Down Expand Up @@ -1057,6 +1048,7 @@ def on_was_skipped(self, plugin):
)

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)
Expand Down Expand Up @@ -1313,9 +1305,9 @@ def info(self, message):
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"
Expand Down

0 comments on commit 3d1ad12

Please sign in to comment.