mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-13 16:34:34 +12:00
Improves readabily of tree and card delegate
This commit is contained in:
parent
40b07938d0
commit
cc84f53f04
|
@ -153,6 +153,9 @@ def mixColors(col1, col2, f=.5):
|
||||||
|
|
||||||
|
|
||||||
def outlineItemColors(item):
|
def outlineItemColors(item):
|
||||||
|
|
||||||
|
from manuskript.ui import style as S
|
||||||
|
|
||||||
"""Takes an OutlineItem and returns a dict of colors."""
|
"""Takes an OutlineItem and returns a dict of colors."""
|
||||||
colors = {}
|
colors = {}
|
||||||
mw = mainWindow()
|
mw = mainWindow()
|
||||||
|
@ -184,9 +187,9 @@ def outlineItemColors(item):
|
||||||
|
|
||||||
# Compile
|
# Compile
|
||||||
if item.compile() in [0, "0"]:
|
if item.compile() in [0, "0"]:
|
||||||
colors["Compile"] = QColor(Qt.gray)
|
colors["Compile"] = mixColors(QColor(S.text), QColor(S.window))
|
||||||
else:
|
else:
|
||||||
colors["Compile"] = QColor(Qt.black)
|
colors["Compile"] = QColor(S.text)
|
||||||
|
|
||||||
return colors
|
return colors
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,19 @@ from PyQt5.QtWidgets import qApp
|
||||||
|
|
||||||
from manuskript import settings
|
from manuskript import settings
|
||||||
|
|
||||||
|
# Loading palette colors.
|
||||||
|
# Manuskript as to restart to reload
|
||||||
|
p = qApp.palette()
|
||||||
# window = "#d6d2d0" #"#eee" / #eff0f1
|
# 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"
|
bgHover = "#ccc"
|
||||||
bgChecked = "#bbb"
|
bgChecked = "#bbb"
|
||||||
|
@ -152,7 +163,7 @@ def mainEditorTabSS():
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
QScrollBar::sub-line:vertical {{
|
QScrollBar::sub-line:vertical {{
|
||||||
width:0;
|
width:0;
|
||||||
height: 0;
|
height: 0;
|
||||||
|
@ -240,8 +251,8 @@ def lineEditSS():
|
||||||
""".format(window=window,
|
""".format(window=window,
|
||||||
checked=bgChecked,
|
checked=bgChecked,
|
||||||
blue=blue)
|
blue=blue)
|
||||||
|
|
||||||
|
|
||||||
def transparentSS():
|
def transparentSS():
|
||||||
return """
|
return """
|
||||||
QTextEdit{
|
QTextEdit{
|
||||||
|
@ -264,10 +275,10 @@ def simpleScrollBarV():
|
||||||
height: 0;
|
height: 0;
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
}
|
}
|
||||||
QScrollBar::sub-line:vertical {
|
QScrollBar::sub-line:vertical {
|
||||||
width:0;
|
width:0;
|
||||||
height: 0;
|
height: 0;
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
}"""
|
}"""
|
||||||
|
|
|
@ -10,6 +10,7 @@ from manuskript.functions import colorifyPixmap
|
||||||
from manuskript.functions import mainWindow
|
from manuskript.functions import mainWindow
|
||||||
from manuskript.functions import mixColors
|
from manuskript.functions import mixColors
|
||||||
from manuskript.functions import outlineItemColors
|
from manuskript.functions import outlineItemColors
|
||||||
|
from manuskript.ui import style as S
|
||||||
|
|
||||||
|
|
||||||
class corkDelegate(QStyledItemDelegate):
|
class corkDelegate(QStyledItemDelegate):
|
||||||
|
@ -240,9 +241,11 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
if c == QColor(Qt.transparent):
|
if c == QColor(Qt.transparent):
|
||||||
c = QColor(Qt.white)
|
c = QColor(Qt.white)
|
||||||
col = mixColors(c, QColor(Qt.white), .2)
|
col = mixColors(c, QColor(Qt.white), .2)
|
||||||
|
backgroundColor = col
|
||||||
p.setBrush(col)
|
p.setBrush(col)
|
||||||
else:
|
else:
|
||||||
p.setBrush(Qt.white)
|
p.setBrush(Qt.white)
|
||||||
|
backgroundColor = QColor(Qt.white)
|
||||||
|
|
||||||
p.setPen(Qt.NoPen)
|
p.setPen(Qt.NoPen)
|
||||||
p.drawRect(self.cardRect)
|
p.drawRect(self.cardRect)
|
||||||
|
@ -302,10 +305,20 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
p.setPen(Qt.black)
|
p.setPen(Qt.black)
|
||||||
|
textColor = QColor(Qt.black)
|
||||||
if settings.viewSettings["Cork"]["Text"] != "Nothing":
|
if settings.viewSettings["Cork"]["Text"] != "Nothing":
|
||||||
col = colors[settings.viewSettings["Cork"]["Text"]]
|
col = colors[settings.viewSettings["Cork"]["Text"]]
|
||||||
if col == Qt.transparent:
|
if col == Qt.transparent:
|
||||||
col = Qt.black
|
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)
|
p.setPen(col)
|
||||||
f = QFont(option.font)
|
f = QFont(option.font)
|
||||||
f.setPointSize(f.pointSize() + 4)
|
f.setPointSize(f.pointSize() + 4)
|
||||||
|
@ -358,7 +371,7 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
f = QFont(option.font)
|
f = QFont(option.font)
|
||||||
f.setBold(True)
|
f.setBold(True)
|
||||||
p.setFont(f)
|
p.setFont(f)
|
||||||
p.setPen(Qt.black)
|
p.setPen(textColor)
|
||||||
fm = QFontMetrics(f)
|
fm = QFontMetrics(f)
|
||||||
elidedText = fm.elidedText(lineSummary, Qt.ElideRight, self.mainLineRect.width())
|
elidedText = fm.elidedText(lineSummary, Qt.ElideRight, self.mainLineRect.width())
|
||||||
p.drawText(self.mainLineRect, Qt.AlignLeft | Qt.AlignVCenter, elidedText)
|
p.drawText(self.mainLineRect, Qt.AlignLeft | Qt.AlignVCenter, elidedText)
|
||||||
|
@ -368,7 +381,7 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
if fullSummary:
|
if fullSummary:
|
||||||
p.save()
|
p.save()
|
||||||
p.setFont(option.font)
|
p.setFont(option.font)
|
||||||
p.setPen(Qt.black)
|
p.setPen(textColor)
|
||||||
p.drawText(self.mainTextRect, Qt.TextWordWrap, fullSummary)
|
p.drawText(self.mainTextRect, Qt.TextWordWrap, fullSummary)
|
||||||
p.restore()
|
p.restore()
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ from manuskript.enums import Outline
|
||||||
from manuskript.functions import mixColors, colorifyPixmap
|
from manuskript.functions import mixColors, colorifyPixmap
|
||||||
from manuskript.functions import outlineItemColors
|
from manuskript.functions import outlineItemColors
|
||||||
from manuskript.functions import toFloat
|
from manuskript.functions import toFloat
|
||||||
|
from manuskript.ui import style as S
|
||||||
|
|
||||||
|
|
||||||
class treeTitleDelegate(QStyledItemDelegate):
|
class treeTitleDelegate(QStyledItemDelegate):
|
||||||
|
@ -44,7 +45,7 @@ class treeTitleDelegate(QStyledItemDelegate):
|
||||||
col = colors[settings.viewSettings["Tree"]["Background"]]
|
col = colors[settings.viewSettings["Tree"]["Background"]]
|
||||||
|
|
||||||
if col != QColor(Qt.transparent):
|
if col != QColor(Qt.transparent):
|
||||||
col2 = QColor(Qt.white)
|
col2 = QColor(S.window)
|
||||||
if opt.state & QStyle.State_Selected:
|
if opt.state & QStyle.State_Selected:
|
||||||
col2 = opt.palette.brush(QPalette.Normal, QPalette.Highlight).color()
|
col2 = opt.palette.brush(QPalette.Normal, QPalette.Highlight).color()
|
||||||
col = mixColors(col, col2, .2)
|
col = mixColors(col, col2, .2)
|
||||||
|
@ -81,10 +82,13 @@ class treeTitleDelegate(QStyledItemDelegate):
|
||||||
# Text
|
# Text
|
||||||
if opt.text:
|
if opt.text:
|
||||||
painter.save()
|
painter.save()
|
||||||
|
if option.state & QStyle.State_Selected:
|
||||||
|
col = QColor(S.highlightedText)
|
||||||
|
painter.setPen(col)
|
||||||
if settings.viewSettings["Tree"]["Text"] != "Nothing":
|
if settings.viewSettings["Tree"]["Text"] != "Nothing":
|
||||||
col = colors[settings.viewSettings["Tree"]["Text"]]
|
col = colors[settings.viewSettings["Tree"]["Text"]]
|
||||||
if col == Qt.transparent:
|
if col == Qt.transparent:
|
||||||
col = Qt.black
|
col = QColor(S.text)
|
||||||
painter.setPen(col)
|
painter.setPen(col)
|
||||||
f = QFont(opt.font)
|
f = QFont(opt.font)
|
||||||
painter.setFont(f)
|
painter.setFont(f)
|
||||||
|
@ -131,8 +135,11 @@ class treeTitleDelegate(QStyledItemDelegate):
|
||||||
f = painter.font()
|
f = painter.font()
|
||||||
f.setWeight(QFont.Normal)
|
f.setWeight(QFont.Normal)
|
||||||
painter.setFont(f)
|
painter.setFont(f)
|
||||||
painter.setPen(Qt.darkGray)
|
col = mixColors(
|
||||||
painter.drawText(r, Qt.AlignLeft | Qt.AlignBottom, extraText)
|
QColor(S.window),
|
||||||
|
QColor(S.text))
|
||||||
|
painter.setPen(col) #Qt.darkGray
|
||||||
|
painter.drawText(r, Qt.AlignLeft | Qt.AlignVCenter, extraText)
|
||||||
painter.restore()
|
painter.restore()
|
||||||
|
|
||||||
painter.restore()
|
painter.restore()
|
||||||
|
|
Loading…
Reference in a new issue