From 0c3f96014abe1716fb757a129ed30e3f09e30db3 Mon Sep 17 00:00:00 2001 From: Olivier Keshavjee Date: Tue, 14 Nov 2017 10:00:35 +0100 Subject: [PATCH] Improves readabily of outline delegate --- manuskript/functions.py | 2 +- manuskript/ui/views/outlineDelegates.py | 16 +++++++++++++--- manuskript/ui/views/treeDelegates.py | 9 ++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/manuskript/functions.py b/manuskript/functions.py index 24652ba..cdcd8ca 100644 --- a/manuskript/functions.py +++ b/manuskript/functions.py @@ -189,7 +189,7 @@ def outlineItemColors(item): if item.compile() in [0, "0"]: colors["Compile"] = mixColors(QColor(S.text), QColor(S.window)) else: - colors["Compile"] = QColor(S.text) + colors["Compile"] = QColor(Qt.transparent) # will use default return colors diff --git a/manuskript/ui/views/outlineDelegates.py b/manuskript/ui/views/outlineDelegates.py index 818718d..215f99a 100644 --- a/manuskript/ui/views/outlineDelegates.py +++ b/manuskript/ui/views/outlineDelegates.py @@ -8,7 +8,7 @@ from PyQt5.QtWidgets import qApp from manuskript import settings from manuskript.enums import Character, Outline from manuskript.functions import outlineItemColors, mixColors, colorifyPixmap, toInt, toFloat, drawProgress - +from manuskript.ui import style as S class outlineTitleDelegate(QStyledItemDelegate): def __init__(self, parent=None): @@ -39,7 +39,7 @@ class outlineTitleDelegate(QStyledItemDelegate): col = colors[settings.viewSettings["Outline"]["Background"]] if col != QColor(Qt.transparent): - col2 = QColor(Qt.white) + col2 = QColor(S.base) if opt.state & QStyle.State_Selected: col2 = opt.palette.brush(QPalette.Normal, QPalette.Highlight).color() col = mixColors(col, col2, .2) @@ -76,10 +76,20 @@ class outlineTitleDelegate(QStyledItemDelegate): # Text if opt.text: painter.save() + textColor = QColor(S.text) + if option.state & QStyle.State_Selected: + col = QColor(S.highlightedText) + textColor = col + painter.setPen(col) if settings.viewSettings["Outline"]["Text"] != "Nothing": col = colors[settings.viewSettings["Outline"]["Text"]] if col == Qt.transparent: - col = Qt.black + col = textColor + # If text color is Compile and item is selected, we have + # to change the color + if settings.viewSettings["Outline"]["Text"] == "Compile" and \ + item.compile() in [0, "0"]: + col = mixColors(textColor, QColor(S.window)) painter.setPen(col) f = QFont(opt.font) painter.setFont(f) diff --git a/manuskript/ui/views/treeDelegates.py b/manuskript/ui/views/treeDelegates.py index 4921a7e..6ed7a3b 100644 --- a/manuskript/ui/views/treeDelegates.py +++ b/manuskript/ui/views/treeDelegates.py @@ -82,13 +82,20 @@ class treeTitleDelegate(QStyledItemDelegate): # Text if opt.text: painter.save() + textColor = QColor(S.text) if option.state & QStyle.State_Selected: col = QColor(S.highlightedText) + textColor = col painter.setPen(col) if settings.viewSettings["Tree"]["Text"] != "Nothing": col = colors[settings.viewSettings["Tree"]["Text"]] if col == Qt.transparent: - col = QColor(S.text) + col = textColor + # If text color is Compile and item is selected, we have + # to change the color + if settings.viewSettings["Outline"]["Text"] == "Compile" and \ + item.compile() in [0, "0"]: + col = mixColors(textColor, QColor(S.window)) painter.setPen(col) f = QFont(opt.font) painter.setFont(f)