Skip to content

Commit

Permalink
qt: fit StatusBarButton to inner height of status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
accumulator committed Mar 14, 2023
1 parent 4979346 commit 842229c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions electrum/gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@

class StatusBarButton(QToolButton):
# 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)
self.setText('')
self.setIcon(icon)
self.setToolTip(tooltip)
self.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
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.clicked.connect(self.onPress)
self.func = func
Expand Down Expand Up @@ -1527,6 +1528,7 @@ def create_status_bar(self):
font_height = QFontMetrics(self.balance_label.font()).height()
sb_height = max(35, int(2 * font_height))
sb.setFixedHeight(sb_height)
sb_inner_height = sb.childrenRect().height()

# remove border of all items in status bar
self.setStyleSheet("QStatusBar::item { border: 0px;} ")
Expand All @@ -1546,18 +1548,18 @@ def create_status_bar(self):
self.tasks_label = QLabel('')
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(StatusBarButton(read_QIcon("preferences.png"), _("Preferences"), self.settings_dialog))
self.seed_button = StatusBarButton(read_QIcon("seed.png"), _("Seed"), self.show_seed_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, sb_inner_height)
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)
self.update_lightning_icon()
self.status_button = None
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)
run_hook('create_status_bar', sb)
self.setStatusBar(sb)
Expand Down

0 comments on commit 842229c

Please sign in to comment.