diff --git a/manuskript/functions.py b/manuskript/functions.py index 03e2a792..24652ba2 100644 --- a/manuskript/functions.py +++ b/manuskript/functions.py @@ -153,6 +153,9 @@ def mixColors(col1, col2, f=.5): def outlineItemColors(item): + + from manuskript.ui import style as S + """Takes an OutlineItem and returns a dict of colors.""" colors = {} mw = mainWindow() @@ -184,9 +187,9 @@ def outlineItemColors(item): # Compile if item.compile() in [0, "0"]: - colors["Compile"] = QColor(Qt.gray) + colors["Compile"] = mixColors(QColor(S.text), QColor(S.window)) else: - colors["Compile"] = QColor(Qt.black) + colors["Compile"] = QColor(S.text) return colors diff --git a/manuskript/ui/style.py b/manuskript/ui/style.py index ad5c907d..ba88fc67 100644 --- a/manuskript/ui/style.py +++ b/manuskript/ui/style.py @@ -9,8 +9,19 @@ from PyQt5.QtWidgets import qApp from manuskript import settings +# Loading palette colors. +# Manuskript as to restart to reload +p = qApp.palette() # window = "#d6d2d0" #"#eee" / #eff0f1 -window = qApp.palette().color(QPalette.Window).name() +window = p.color(QPalette.Window).name() # General background +windowText = p.color(QPalette.WindowText).name() # General foregroung +base = p.color(QPalette.Base).name() # Other background +text = p.color(QPalette.Text).name() # Base Text +brightText = p.color(QPalette.BrightText).name() # Contrast Text +button = p.color(QPalette.Window).name() # Button background +buttonText = p.color(QPalette.Window).name() # Button Text +highlight = p.color(QPalette.Highlight).name() # Other background +highlightedText = p.color(QPalette.HighlightedText).name() # Base Text bgHover = "#ccc" bgChecked = "#bbb" @@ -152,7 +163,7 @@ def mainEditorTabSS(): border: none; background: none; }} - + QScrollBar::sub-line:vertical {{ width:0; height: 0; @@ -240,8 +251,8 @@ def lineEditSS(): """.format(window=window, checked=bgChecked, blue=blue) - - + + def transparentSS(): return """ QTextEdit{ @@ -264,10 +275,10 @@ def simpleScrollBarV(): height: 0; border: none; background: none; - } + } QScrollBar::sub-line:vertical { width:0; height: 0; border: none; background: none; - }""" \ No newline at end of file + }""" diff --git a/manuskript/ui/views/corkDelegate.py b/manuskript/ui/views/corkDelegate.py index 6e6eee95..2bb2a4dd 100644 --- a/manuskript/ui/views/corkDelegate.py +++ b/manuskript/ui/views/corkDelegate.py @@ -10,6 +10,7 @@ from manuskript.functions import colorifyPixmap from manuskript.functions import mainWindow from manuskript.functions import mixColors from manuskript.functions import outlineItemColors +from manuskript.ui import style as S class corkDelegate(QStyledItemDelegate): @@ -240,9 +241,11 @@ class corkDelegate(QStyledItemDelegate): if c == QColor(Qt.transparent): c = QColor(Qt.white) col = mixColors(c, QColor(Qt.white), .2) + backgroundColor = col p.setBrush(col) else: p.setBrush(Qt.white) + backgroundColor = QColor(Qt.white) p.setPen(Qt.NoPen) p.drawRect(self.cardRect) @@ -302,10 +305,20 @@ class corkDelegate(QStyledItemDelegate): if text: p.setPen(Qt.black) + textColor = QColor(Qt.black) if settings.viewSettings["Cork"]["Text"] != "Nothing": col = colors[settings.viewSettings["Cork"]["Text"]] if col == Qt.transparent: col = Qt.black + + # If title setting is compile, we have to hack the color + # Or we won't see anything in some themes + if settings.viewSettings["Cork"]["Text"] == "Compile": + if item.compile() in [0, "0"]: + col = mixColors(QColor(Qt.black), backgroundColor) + else: + col = Qt.black + textColor = col p.setPen(col) f = QFont(option.font) f.setPointSize(f.pointSize() + 4) @@ -358,7 +371,7 @@ class corkDelegate(QStyledItemDelegate): f = QFont(option.font) f.setBold(True) p.setFont(f) - p.setPen(Qt.black) + p.setPen(textColor) fm = QFontMetrics(f) elidedText = fm.elidedText(lineSummary, Qt.ElideRight, self.mainLineRect.width()) p.drawText(self.mainLineRect, Qt.AlignLeft | Qt.AlignVCenter, elidedText) @@ -368,7 +381,7 @@ class corkDelegate(QStyledItemDelegate): if fullSummary: p.save() p.setFont(option.font) - p.setPen(Qt.black) + p.setPen(textColor) p.drawText(self.mainTextRect, Qt.TextWordWrap, fullSummary) p.restore() diff --git a/manuskript/ui/views/treeDelegates.py b/manuskript/ui/views/treeDelegates.py index a9ee4542..4921a7e1 100644 --- a/manuskript/ui/views/treeDelegates.py +++ b/manuskript/ui/views/treeDelegates.py @@ -9,6 +9,7 @@ from manuskript.enums import Outline from manuskript.functions import mixColors, colorifyPixmap from manuskript.functions import outlineItemColors from manuskript.functions import toFloat +from manuskript.ui import style as S class treeTitleDelegate(QStyledItemDelegate): @@ -44,7 +45,7 @@ class treeTitleDelegate(QStyledItemDelegate): col = colors[settings.viewSettings["Tree"]["Background"]] if col != QColor(Qt.transparent): - col2 = QColor(Qt.white) + col2 = QColor(S.window) if opt.state & QStyle.State_Selected: col2 = opt.palette.brush(QPalette.Normal, QPalette.Highlight).color() col = mixColors(col, col2, .2) @@ -81,10 +82,13 @@ class treeTitleDelegate(QStyledItemDelegate): # Text if opt.text: painter.save() + if option.state & QStyle.State_Selected: + col = QColor(S.highlightedText) + painter.setPen(col) if settings.viewSettings["Tree"]["Text"] != "Nothing": col = colors[settings.viewSettings["Tree"]["Text"]] if col == Qt.transparent: - col = Qt.black + col = QColor(S.text) painter.setPen(col) f = QFont(opt.font) painter.setFont(f) @@ -131,8 +135,11 @@ class treeTitleDelegate(QStyledItemDelegate): f = painter.font() f.setWeight(QFont.Normal) painter.setFont(f) - painter.setPen(Qt.darkGray) - painter.drawText(r, Qt.AlignLeft | Qt.AlignBottom, extraText) + col = mixColors( + QColor(S.window), + QColor(S.text)) + painter.setPen(col) #Qt.darkGray + painter.drawText(r, Qt.AlignLeft | Qt.AlignVCenter, extraText) painter.restore() painter.restore()