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() 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) ) diff --git a/pype/tools/pyblish_pype/settings.py b/pype/tools/pyblish_pype/settings.py index a3ae83ff0a..fefdbea77f 100644 --- a/pype/tools/pyblish_pype/settings.py +++ b/pype/tools/pyblish_pype/settings.py @@ -1,5 +1,10 @@ -WindowTitle = "Pyblish" # Customize the window of the pyblish-lite window. -UseLabel = True # Customize whether to show label names for plugins. +from .util import env_variable_to_bool + +# Customize the window of the pyblish-lite window. +WindowTitle = "Pyblish" + +# Customize whether to show label names for plugins. +UseLabel = True # Customize which tab to start on. Possible choices are: "artist", "overview" # and "terminal". @@ -17,3 +22,6 @@ TerminalFilters = { "log_critical": True, "traceback": True, } + +# Allow animations in GUI +Animated = env_variable_to_bool("PYPE_PYBLISH_ANIMATED", True) diff --git a/pype/tools/pyblish_pype/util.py b/pype/tools/pyblish_pype/util.py index 5a4dbfb250..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 @@ -311,10 +315,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 diff --git a/pype/tools/pyblish_pype/view.py b/pype/tools/pyblish_pype/view.py index 248c1fbbf9..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: @@ -157,8 +158,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 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)