1
0

qt BalanceToolButton: better sizing on high DPI screens

specifically, on Windows, with display scaling > 100%, the pie btn was too small (not scaled)
This commit is contained in:
SomberNight
2024-01-15 14:35:30 +00:00
parent 10be631039
commit 66b24411e0
2 changed files with 13 additions and 4 deletions

View File

@@ -102,9 +102,8 @@ class BalanceToolButton(QToolButton, PieChartObject):
def __init__(self):
QToolButton.__init__(self)
self.size = max(18, font_height())
self._list = []
self.R = QRect(6, 3, self.size, self.size)
self._update_size()
def update_list(self, l):
self._list = l
@@ -118,6 +117,14 @@ class BalanceToolButton(QToolButton, PieChartObject):
QToolButton.paintEvent(self, event)
PieChartObject.paintEvent(self, event)
def resizeEvent(self, e):
super().resizeEvent(e)
self._update_size()
def _update_size(self):
size = max(18, font_height(self))
self.R = QRect(6, 3, size, size)
class LegendWidget(QWidget):
size = 20

View File

@@ -1262,8 +1262,10 @@ def char_width_in_lineedit() -> int:
return max(9, char_width)
def font_height() -> int:
return QFontMetrics(QLabel().font()).height()
def font_height(widget: QWidget = None) -> int:
if widget is None:
widget = QLabel()
return QFontMetrics(widget.font()).height()
def webopen(url: str):