From 423bbfe686e3b00037227902c4f298ed8c667f63 Mon Sep 17 00:00:00 2001 From: Joe Hultgren Date: Wed, 31 Oct 2018 10:18:54 -0700 Subject: [PATCH 1/2] turn colored text on for warnings and errors This was already here I just uncommented it. --- .../progress/progress_handler.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python/tk_multi_publish2/progress/progress_handler.py b/python/tk_multi_publish2/progress/progress_handler.py index 25eb3de7..986d4f11 100644 --- a/python/tk_multi_publish2/progress/progress_handler.py +++ b/python/tk_multi_publish2/progress/progress_handler.py @@ -198,16 +198,16 @@ def process_log_message(self, message, status, action): self._progress_details.log_tree.addTopLevelItem(item) # assign color - # if status == self.WARNING: - # item.setForeground(0, self._warning_brush) - # elif status == self.ERROR: - # item.setForeground(0, self._error_brush) - # elif status == self.DEBUG: - # item.setForeground(0, self._debug_brush) - - if status == self.DEBUG: + if status == self.WARNING: + item.setForeground(0, self._warning_brush) + elif status == self.ERROR: + item.setForeground(0, self._error_brush) + elif status == self.DEBUG: item.setForeground(0, self._debug_brush) + # if status == self.DEBUG: + # item.setForeground(0, self._debug_brush) + if action: # add any action button to the log item self._process_action(item, action) From 67bc29994fb3c56a8a76dfa66835b8da0fa5b365 Mon Sep 17 00:00:00 2001 From: Joe Hultgren Date: Thu, 29 Nov 2018 18:52:22 -0800 Subject: [PATCH 2/2] support thumbnails for more image types If pillow is available fall back to it if qt can't load an image. This is useful for image formats qt doesn't understand directly such as single channel tgas --- python/tk_multi_publish2/api/item.py | 33 +++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/python/tk_multi_publish2/api/item.py b/python/tk_multi_publish2/api/item.py index 58a1af44..619750ae 100644 --- a/python/tk_multi_publish2/api/item.py +++ b/python/tk_multi_publish2/api/item.py @@ -508,6 +508,21 @@ def _validate_image(self, path): try: icon = QtGui.QPixmap(path) + if icon.isNull(): + try: + from PIL import Image + im = Image.open(path) + # needs to be rgba + im = im.convert('RGBA') + r, g, b, a = im.split() + # swapping channel order for qt + im2 = Image.merge("RGBA", (b, g, r, a)) + + data = im2.tobytes("raw", "RGBA") + qim = QtGui.QImage(data, im.size[0], im.size[1], QtGui.QImage.Format_ARGB32) + icon = QtGui.QPixmap.fromImage(qim) + except ImportError: + pass except Exception as e: logger.warning( "%r: Could not load icon '%s': %s" % (self, path, e) @@ -737,7 +752,23 @@ def _get_image(self, get_img_path, get_pixmap, set_pixmap, get_parent_pixmap, de if get_img_path() and not get_pixmap(): # we have a path but haven't yet created the pixmap. create it try: - set_pixmap(QtGui.QPixmap(get_img_path())) + pixmap = QtGui.QPixmap(get_img_path()) + if pixmap.isNull(): + try: + from PIL import Image + im = Image.open(get_img_path()) + # needs to be rgba + im = im.convert('RGBA') + r, g, b, a = im.split() + # swapping channel order for qt + im2 = Image.merge("RGBA", (b, g, r, a)) + + data = im2.tobytes("raw", "RGBA") + qim = QtGui.QImage(data, im.size[0], im.size[1], QtGui.QImage.Format_ARGB32) + pixmap = QtGui.QPixmap.fromImage(qim) + except ImportError: + pass + set_pixmap(pixmap) except Exception, e: logger.warning( "%r: Could not load icon '%s': %s" %