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:
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user