From d82b95e59bc25cc751eea33a36912eada5b045ab Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 19:12:13 +0100 Subject: [PATCH 1/9] moved compat.py directly to app.py --- pype/tools/pyblish_pype/app.py | 12 +++++++++--- pype/tools/pyblish_pype/compat.py | 14 -------------- 2 files changed, 9 insertions(+), 17 deletions(-) delete mode 100644 pype/tools/pyblish_pype/compat.py diff --git a/pype/tools/pyblish_pype/app.py b/pype/tools/pyblish_pype/app.py index 9879c63030..1bf16ff56a 100644 --- a/pype/tools/pyblish_pype/app.py +++ b/pype/tools/pyblish_pype/app.py @@ -1,10 +1,12 @@ from __future__ import print_function -import contextlib import os import sys +import ctypes +import platform +import contextlib -from . import compat, control, settings, util, window +from . import control, settings, util, window from Qt import QtCore, QtGui, QtWidgets self = sys.modules[__name__] @@ -79,7 +81,11 @@ def show(parent=None): css = css.replace("url(\"", "url(\"%s" % root) with application() as app: - compat.init() + + if platform.system().lower() == "windows": + ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( + u"pyblish_pype" + ) install_fonts() install_translator(app) diff --git a/pype/tools/pyblish_pype/compat.py b/pype/tools/pyblish_pype/compat.py deleted file mode 100644 index bb520d65f5..0000000000 --- a/pype/tools/pyblish_pype/compat.py +++ /dev/null @@ -1,14 +0,0 @@ -import os - - -def __windows_taskbar_compat(): - """Enable icon and taskbar grouping for Windows 7+""" - - import ctypes - ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( - u"pyblish_pype") - - -def init(): - if os.name == "nt": - __windows_taskbar_compat() From e0a08007ce57afe5afd572c73bcfda07bee3b371 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 19:13:37 +0100 Subject: [PATCH 2/9] `env_variable_to_bool` function is more specific and have ability of default value --- pype/tools/pyblish_pype/util.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pype/tools/pyblish_pype/util.py b/pype/tools/pyblish_pype/util.py index 5a4dbfb250..e016b28ed7 100644 --- a/pype/tools/pyblish_pype/util.py +++ b/pype/tools/pyblish_pype/util.py @@ -311,10 +311,14 @@ class OrderGroups: return float(group_range) -def env_variable_to_bool(env_key): +def env_variable_to_bool(env_key, default=False): + """Boolean based on environment variable value.""" + # TODO: move to pype lib value = os.environ.get(env_key) if value is not None: value = value.lower() - if value in ("true", "1", "yes"): + if value in ("true", "1", "yes", "on"): return True - return False + elif value in ("false", "0", "no", "off"): + return False + return default From 5e06798beaa379a3901361bdc43a2162fc213f44 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 19:13:52 +0100 Subject: [PATCH 3/9] instance view just pass args andkwargs to super --- pype/tools/pyblish_pype/view.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pype/tools/pyblish_pype/view.py b/pype/tools/pyblish_pype/view.py index 248c1fbbf9..19d95216fd 100644 --- a/pype/tools/pyblish_pype/view.py +++ b/pype/tools/pyblish_pype/view.py @@ -157,8 +157,8 @@ class PluginView(OverviewView): class InstanceView(OverviewView): - def __init__(self, parent=None): - super(InstanceView, self).__init__(parent) + def __init__(self, *args, **kwargs): + super(InstanceView, self).__init__(*args, **kwargs) self.viewport().setMouseTracking(True) self._pressed_group_index = None self._pressed_expander = None From 8753dcfffc6389278c7ab2269598a2105f2e9fbe Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 19:14:21 +0100 Subject: [PATCH 4/9] OverviewView has argument to allow(set) animations --- pype/tools/pyblish_pype/view.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pype/tools/pyblish_pype/view.py b/pype/tools/pyblish_pype/view.py index 19d95216fd..b18738c9ab 100644 --- a/pype/tools/pyblish_pype/view.py +++ b/pype/tools/pyblish_pype/view.py @@ -71,7 +71,7 @@ class OverviewView(QtWidgets.QTreeView): toggled = QtCore.Signal(QtCore.QModelIndex, object) show_perspective = QtCore.Signal(QtCore.QModelIndex) - def __init__(self, parent=None): + def __init__(self, animated, parent=None): super(OverviewView, self).__init__(parent) self.horizontalScrollBar().hide() @@ -83,7 +83,8 @@ class OverviewView(QtWidgets.QTreeView): self.setHeaderHidden(True) self.setRootIsDecorated(False) self.setIndentation(0) - self.setAnimated(True) + if animated: + self.setAnimated(True) def event(self, event): if not event.type() == QtCore.QEvent.KeyPress: From 576c2726e53448db2897a3b34f42e96140dd1d46 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 19:14:43 +0100 Subject: [PATCH 5/9] settings has Animated variable based on `PYPE_PYBLISH_ANIMATED` env variable --- pype/tools/pyblish_pype/settings.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pype/tools/pyblish_pype/settings.py b/pype/tools/pyblish_pype/settings.py index a3ae83ff0a..dd7c820f56 100644 --- a/pype/tools/pyblish_pype/settings.py +++ b/pype/tools/pyblish_pype/settings.py @@ -1,3 +1,6 @@ +from .util import env_variable_to_bool + + WindowTitle = "Pyblish" # Customize the window of the pyblish-lite window. UseLabel = True # Customize whether to show label names for plugins. @@ -17,3 +20,5 @@ TerminalFilters = { "log_critical": True, "traceback": True, } + +Animated = env_variable_to_bool("PYPE_PYBLISH_ANIMATED", True) From 80f2b43b6a2e39706b2ddfc6e04cf733b2ef420d Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 19:14:59 +0100 Subject: [PATCH 6/9] have ability to not use animations in pyblish gui --- pype/tools/pyblish_pype/window.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pype/tools/pyblish_pype/window.py b/pype/tools/pyblish_pype/window.py index ab59f9f6a1..2f663cc08a 100644 --- a/pype/tools/pyblish_pype/window.py +++ b/pype/tools/pyblish_pype/window.py @@ -166,14 +166,18 @@ class Window(QtWidgets.QDialog): # TODO add parent overview_page = QtWidgets.QWidget() - overview_instance_view = view.InstanceView(parent=overview_page) + overview_instance_view = view.InstanceView( + animated=settings.Animated, parent=overview_page + ) overview_instance_delegate = delegate.InstanceDelegate( parent=overview_instance_view ) overview_instance_view.setItemDelegate(overview_instance_delegate) overview_instance_view.setModel(instance_model) - overview_plugin_view = view.PluginView(parent=overview_page) + overview_plugin_view = view.PluginView( + animated=settings.Animated, parent=overview_page + ) overview_plugin_delegate = delegate.PluginDelegate( parent=overview_plugin_view ) @@ -669,6 +673,11 @@ class Window(QtWidgets.QDialog): target_page.show() return + if not settings.Animated: + previous_page.setVisible(False) + target_page.setVisible(True) + return + width = previous_page.frameGeometry().width() offset = QtCore.QPoint(direction * width, 0) From 946828f232c6226dc1ed339a89c753ff5c145ac0 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 19:15:07 +0100 Subject: [PATCH 7/9] formatting modifications --- pype/tools/pyblish_pype/util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pype/tools/pyblish_pype/util.py b/pype/tools/pyblish_pype/util.py index e016b28ed7..0d581f17af 100644 --- a/pype/tools/pyblish_pype/util.py +++ b/pype/tools/pyblish_pype/util.py @@ -1,5 +1,9 @@ -from __future__ import (absolute_import, division, print_function, - unicode_literals) +from __future__ import ( + absolute_import, + division, + print_function, + unicode_literals +) import os import sys From 10fcf6eccb15502ee39f0efb87e68081e5430d81 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 19:15:46 +0100 Subject: [PATCH 8/9] fixed edge case exception handling, which can cause to end in endless loop --- pype/tools/pyblish_pype/control.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pype/tools/pyblish_pype/control.py b/pype/tools/pyblish_pype/control.py index 0162848f2b..a249f9ed27 100644 --- a/pype/tools/pyblish_pype/control.py +++ b/pype/tools/pyblish_pype/control.py @@ -384,8 +384,11 @@ class Controller(QtCore.QObject): except Exception: # TODO this should be handled much differently + # TODO emit crash signal to show message box with traceback exc_type, exc_msg, exc_tb = sys.exc_info() traceback.print_exception(exc_type, exc_msg, exc_tb) + self.is_running = False + self.was_stopped.emit() return util.defer( 500, lambda: on_unexpected_error(error=exc_msg) ) From fd7e0eb2b4f9faca79abf1435139c91dd54abf76 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 28 Oct 2020 19:22:03 +0100 Subject: [PATCH 9/9] moved with comments --- pype/tools/pyblish_pype/settings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pype/tools/pyblish_pype/settings.py b/pype/tools/pyblish_pype/settings.py index dd7c820f56..fefdbea77f 100644 --- a/pype/tools/pyblish_pype/settings.py +++ b/pype/tools/pyblish_pype/settings.py @@ -1,8 +1,10 @@ from .util import env_variable_to_bool +# Customize the window of the pyblish-lite window. +WindowTitle = "Pyblish" -WindowTitle = "Pyblish" # Customize the window of the pyblish-lite window. -UseLabel = True # Customize whether to show label names for plugins. +# Customize whether to show label names for plugins. +UseLabel = True # Customize which tab to start on. Possible choices are: "artist", "overview" # and "terminal". @@ -21,4 +23,5 @@ TerminalFilters = { "traceback": True, } +# Allow animations in GUI Animated = env_variable_to_bool("PYPE_PYBLISH_ANIMATED", True)