mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Scale count right margin by devicepixelratio
This commit is contained in:
parent
b51c799276
commit
57017c437e
@ -11,6 +11,7 @@ import traceback
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from math import ceil
|
||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemView,
|
QAbstractItemView,
|
||||||
@ -113,7 +114,8 @@ class TagDelegate(QStyledItemDelegate): # {{{
|
|||||||
count = str(index.data(COUNT_ROLE))
|
count = str(index.data(COUNT_ROLE))
|
||||||
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)
|
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)
|
painter.drawText(r, Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextSingleLine, count)
|
||||||
tr.setRight(r.left() - 1)
|
tr.setRight(r.left() - 1)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user