Browse Source

qt: fit StatusBarButton to inner height of status bar

master
Sander van Grieken 3 years ago
parent
commit
842229c4bb
  1. 16
      electrum/gui/qt/main_window.py

16
electrum/gui/qt/main_window.py

@ -111,14 +111,15 @@ LN_NUM_PAYMENT_ATTEMPTS = 10
class StatusBarButton(QToolButton): class StatusBarButton(QToolButton):
# note: this class has a custom stylesheet applied in stylesheet_patcher.py # note: this class has a custom stylesheet applied in stylesheet_patcher.py
def __init__(self, icon, tooltip, func): def __init__(self, icon, tooltip, func, size=0):
QToolButton.__init__(self) QToolButton.__init__(self)
self.setText('') self.setText('')
self.setIcon(icon) self.setIcon(icon)
self.setToolTip(tooltip) self.setToolTip(tooltip)
self.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.setAutoRaise(True) self.setAutoRaise(True)
size = max(25, round(1.8 * font_height())) if not size:
size = max(25, round(1.8 * font_height()))
self.setMaximumWidth(size) self.setMaximumWidth(size)
self.clicked.connect(self.onPress) self.clicked.connect(self.onPress)
self.func = func self.func = func
@ -1527,6 +1528,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
font_height = QFontMetrics(self.balance_label.font()).height() font_height = QFontMetrics(self.balance_label.font()).height()
sb_height = max(35, int(2 * font_height)) sb_height = max(35, int(2 * font_height))
sb.setFixedHeight(sb_height) sb.setFixedHeight(sb_height)
sb_inner_height = sb.childrenRect().height()
# remove border of all items in status bar # remove border of all items in status bar
self.setStyleSheet("QStatusBar::item { border: 0px;} ") self.setStyleSheet("QStatusBar::item { border: 0px;} ")
@ -1546,18 +1548,18 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
self.tasks_label = QLabel('') self.tasks_label = QLabel('')
sb.addPermanentWidget(self.tasks_label) sb.addPermanentWidget(self.tasks_label)
self.password_button = StatusBarButton(QIcon(), _("Password"), self.change_password_dialog) self.password_button = StatusBarButton(QIcon(), _("Password"), self.change_password_dialog, sb_inner_height)
sb.addPermanentWidget(self.password_button) sb.addPermanentWidget(self.password_button)
sb.addPermanentWidget(StatusBarButton(read_QIcon("preferences.png"), _("Preferences"), self.settings_dialog)) sb.addPermanentWidget(StatusBarButton(read_QIcon("preferences.png"), _("Preferences"), self.settings_dialog, sb_inner_height))
self.seed_button = StatusBarButton(read_QIcon("seed.png"), _("Seed"), self.show_seed_dialog) self.seed_button = StatusBarButton(read_QIcon("seed.png"), _("Seed"), self.show_seed_dialog, sb_inner_height)
sb.addPermanentWidget(self.seed_button) sb.addPermanentWidget(self.seed_button)
self.lightning_button = StatusBarButton(read_QIcon("lightning.png"), _("Lightning Network"), self.gui_object.show_lightning_dialog) self.lightning_button = StatusBarButton(read_QIcon("lightning.png"), _("Lightning Network"), self.gui_object.show_lightning_dialog, sb_inner_height)
sb.addPermanentWidget(self.lightning_button) sb.addPermanentWidget(self.lightning_button)
self.update_lightning_icon() self.update_lightning_icon()
self.status_button = None self.status_button = None
if self.network: if self.network:
self.status_button = StatusBarButton(read_QIcon("status_disconnected.png"), _("Network"), self.gui_object.show_network_dialog) self.status_button = StatusBarButton(read_QIcon("status_disconnected.png"), _("Network"), self.gui_object.show_network_dialog, sb_inner_height)
sb.addPermanentWidget(self.status_button) sb.addPermanentWidget(self.status_button)
run_hook('create_status_bar', sb) run_hook('create_status_bar', sb)
self.setStatusBar(sb) self.setStatusBar(sb)

Loading…
Cancel
Save