mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use window-text rather than white as the color for non-hovered tag browser items
This commit is contained in:
parent
411136c614
commit
4e9b12f71b
@ -67,14 +67,14 @@ class TagDelegate(QStyledItemDelegate): # {{{
|
|||||||
icon = option.icon
|
icon = option.icon
|
||||||
icon.paint(painter, r, option.decorationAlignment, QIcon.Mode.Normal, QIcon.State.On)
|
icon.paint(painter, r, option.decorationAlignment, QIcon.Mode.Normal, QIcon.State.On)
|
||||||
|
|
||||||
def paint_text(self, painter, rect, flags, text, hover):
|
def paint_text(self, painter, rect, flags, text, hover, option):
|
||||||
painter.save()
|
painter.save()
|
||||||
pen = painter.pen()
|
pen = painter.pen()
|
||||||
if QApplication.instance().is_dark_theme:
|
if QApplication.instance().is_dark_theme:
|
||||||
if hover:
|
if hover:
|
||||||
pen.setColor(QColor(Qt.GlobalColor.black))
|
pen.setColor(QColor(Qt.GlobalColor.black))
|
||||||
else:
|
else:
|
||||||
pen.setColor(QColor(Qt.GlobalColor.white))
|
pen.setColor(option.palette.color(QPalette.ColorRole.WindowText))
|
||||||
painter.setPen(pen)
|
painter.setPen(pen)
|
||||||
painter.drawText(rect, flags, text)
|
painter.drawText(rect, flags, text)
|
||||||
painter.restore()
|
painter.restore()
|
||||||
@ -90,7 +90,7 @@ class TagDelegate(QStyledItemDelegate): # {{{
|
|||||||
width = painter.fontMetrics().boundingRect(count).width()
|
width = painter.fontMetrics().boundingRect(count).width()
|
||||||
r = QRect(tr)
|
r = QRect(tr)
|
||||||
r.setRight(r.right() - 1), r.setLeft(r.right() - width - 4)
|
r.setRight(r.right() - 1), r.setLeft(r.right() - width - 4)
|
||||||
self.paint_text(painter, r, Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextSingleLine, count, hover)
|
self.paint_text(painter, r, Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextSingleLine, count, hover, option)
|
||||||
tr.setRight(r.left() - 1)
|
tr.setRight(r.left() - 1)
|
||||||
else:
|
else:
|
||||||
tr.setRight(tr.right() - 1)
|
tr.setRight(tr.right() - 1)
|
||||||
@ -111,7 +111,7 @@ class TagDelegate(QStyledItemDelegate): # {{{
|
|||||||
pen = QPen()
|
pen = QPen()
|
||||||
pen.setBrush(QBrush(g))
|
pen.setBrush(QBrush(g))
|
||||||
painter.setPen(pen)
|
painter.setPen(pen)
|
||||||
self.paint_text(painter, tr, flags, text, hover)
|
self.paint_text(painter, tr, flags, text, hover, option)
|
||||||
|
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
QStyledItemDelegate.paint(self, painter, option, empty_index)
|
QStyledItemDelegate.paint(self, painter, option, empty_index)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user