Fixes: Index card text almost invisible in dark themes. #183

This commit is contained in:
Olivier Keshavjee 2017-11-02 12:14:45 +01:00
parent 2d020aba3a
commit 2cc721674a

View file

@ -141,14 +141,14 @@ class corkDelegate(QStyledItemDelegate):
iconSize = max(24 * self.factor, 18)
item = index.internalPointer()
fm = QFontMetrics(option.font)
h = fm.lineSpacing()
h = fm.lineSpacing()
self.itemRect = option.rect.adjusted(margin, margin, -margin, -margin)
top = 15 * self.factor
self.topRect = QRect(self.itemRect)
self.topRect.setHeight(top)
self.cardRect = QRect(self.itemRect.topLeft() + QPoint(0, top),
self.itemRect.bottomRight())
self.iconRect = QRect(self.cardRect.topLeft() + QPoint(margin, margin),
@ -167,7 +167,7 @@ class corkDelegate(QStyledItemDelegate):
self.mainRect.bottomRight())
if not item.data(Outline.summarySentence.value):
self.mainTextRect.setTopLeft(self.mainLineRect.topLeft())
def updateRects_v1(self, option, index):
margin = self.margin
iconSize = max(16 * self.factor, 12)
@ -196,7 +196,7 @@ class corkDelegate(QStyledItemDelegate):
self.paint_v2(p, option, index)
else:
self.paint_v1(p, option, index)
def paint_v2(self, p, option, index):
# QStyledItemDelegate.paint(self, p, option, index)
if not index.isValid():
@ -212,7 +212,7 @@ class corkDelegate(QStyledItemDelegate):
p.translate(self.mainRect.center())
p.rotate(angle)
p.translate(-self.mainRect.center())
def drawRect(r):
p.save()
p.setBrush(Qt.gray)
@ -243,7 +243,7 @@ class corkDelegate(QStyledItemDelegate):
p.setBrush(col)
else:
p.setBrush(Qt.white)
p.setPen(Qt.NoPen)
p.drawRect(self.cardRect)
if item.isFolder():
@ -273,10 +273,10 @@ class corkDelegate(QStyledItemDelegate):
self.labelRect.bottomRight() + QPointF(1, w / 2),
self.labelRect.bottomRight() + QPointF(1, 1),
])
p.drawPolygon(poly)
p.drawPolygon(poly)
p.restore()
if settings.viewSettings["Cork"]["Corner"] == "Nothing" or \
color == Qt.transparent:
# No corner, so title can be full width
@ -299,8 +299,9 @@ class corkDelegate(QStyledItemDelegate):
# Draw title
p.save()
text = index.data()
if text:
p.setPen(Qt.black)
if settings.viewSettings["Cork"]["Text"] != "Nothing":
col = colors[settings.viewSettings["Cork"]["Text"]]
if col == Qt.transparent:
@ -357,6 +358,7 @@ class corkDelegate(QStyledItemDelegate):
f = QFont(option.font)
f.setBold(True)
p.setFont(f)
p.setPen(Qt.black)
fm = QFontMetrics(f)
elidedText = fm.elidedText(lineSummary, Qt.ElideRight, self.mainLineRect.width())
p.drawText(self.mainLineRect, Qt.AlignLeft | Qt.AlignVCenter, elidedText)
@ -364,8 +366,11 @@ class corkDelegate(QStyledItemDelegate):
# Full summary
if fullSummary:
p.save()
p.setFont(option.font)
p.setPen(Qt.black)
p.drawText(self.mainTextRect, Qt.TextWordWrap, fullSummary)
p.restore()
def paint_v1(self, p, option, index):
# QStyledItemDelegate.paint(self, p, option, index)