qt: fit StatusBarButton to inner height of status bar
This commit is contained in:
@@ -111,14 +111,15 @@ LN_NUM_PAYMENT_ATTEMPTS = 10
|
||||
|
||||
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
|
||||
@@ -1527,6 +1528,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
||||
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;} ")
|
||||
@@ -1546,18 +1548,18 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user