Scale count right margin by devicepixelratio

This commit is contained in:
Kovid Goyal 2024-10-27 18:21:22 +05:30
parent b51c799276
commit 57017c437e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -11,6 +11,7 @@ import traceback
from collections import defaultdict
from contextlib import suppress
from functools import partial
from math import ceil
from qt.core import (
QAbstractItemView,
@ -113,7 +114,8 @@ class TagDelegate(QStyledItemDelegate): # {{{
count = str(index.data(COUNT_ROLE))
width = painter.fontMetrics().boundingRect(count).width()
r = QRect(tr)
r.setRight(r.right() - 1), r.setLeft(r.right() - width - 4)
dr = 1 if widget is None else widget.devicePixelRatioF()
r.setRight(r.right() - 1), r.setLeft(r.right() - width - int(ceil(4 * dr)))
painter.drawText(r, Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextSingleLine, count)
tr.setRight(r.left() - 1)
else: