Skip to content

Commit

Permalink
Merge pull request #110 from renaudll/dev_item_warning
Browse files Browse the repository at this point in the history
Color an item yellow if its logger emitted a warning
  • Loading branch information
mottosso committed Aug 21, 2019
2 parents 9172b81 + 4a42564 commit 6a5d93d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pyblish_lite/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .awesome import tags as awesome

colors = {
"warning": QtGui.QColor("#ff4a4a"),
"failed": QtGui.QColor("#ff4a4a"),
"ok": QtGui.QColor("#77AE24"),
"active": QtGui.QColor("#99CEEE"),
"idle": QtCore.Qt.white,
Expand All @@ -15,6 +15,7 @@
"hover": QtGui.QColor(255, 255, 255, 10),
"selected": QtGui.QColor(255, 255, 255, 20),
"outline": QtGui.QColor("#333"),
"warning": QtGui.QColor("#ffa700"),
}

record_colors = {
Expand Down Expand Up @@ -66,6 +67,9 @@ def paint(self, painter, option, index):
check_color = colors["active"]

elif index.data(model.HasFailed) is True:
check_color = colors["failed"]

elif index.data(model.HasWarning) is True:
check_color = colors["warning"]

elif index.data(model.HasSucceeded) is True:
Expand Down
7 changes: 7 additions & 0 deletions pyblish_lite/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"""
from __future__ import unicode_literals

import logging

from . import settings
from .awesome import tags as awesome
from .vendor.Qt import QtCore, __binding__
Expand Down Expand Up @@ -58,6 +60,7 @@
HasFailed = QtCore.Qt.UserRole + 6
HasSucceeded = QtCore.Qt.UserRole + 7
HasProcessed = QtCore.Qt.UserRole + 8
HasWarning = QtCore.Qt.UserRole + 62
Duration = QtCore.Qt.UserRole + 11

# PLUGINS
Expand Down Expand Up @@ -176,6 +179,7 @@ def __init__(self):
Docstring: "__doc__",
ActionIdle: "_action_idle",
ActionFailed: "_action_failed",
HasWarning: "_has_warning",
})

def append(self, item):
Expand All @@ -191,6 +195,7 @@ def append(self, item):
item._has_processed = False
item._has_succeeded = False
item._has_failed = False
item._has_warning = False
item._type = "plugin"

item._action_idle = True
Expand Down Expand Up @@ -306,9 +311,11 @@ def update_with_result(self, result, action=False):

index = self.items.index(item)
index = self.createIndex(index, 0)
hasWarning = any([record.levelno == logging.WARNING for record in result["records"]])

self.setData(index, False, IsIdle)
self.setData(index, False, IsProcessing)
self.setData(index, hasWarning, HasWarning)
self.setData(index, True, HasProcessed)
self.setData(index, result["success"], HasSucceeded)

Expand Down
2 changes: 1 addition & 1 deletion pyblish_lite/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

VERSION_MAJOR = 0
VERSION_MINOR = 8
VERSION_PATCH = 4
VERSION_PATCH = 5


version_info = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
Expand Down

0 comments on commit 6a5d93d

Please sign in to comment.