Browse Source

follow-up 7dcd8d8dc8

- set minimumHeight of VTabWidget (needed for small window size)
  - keep self.tabBar visible, otherwise the widget border is rendered with a gap on linux
  - apply stylesheet to both tabTar and surrounding widget
  - buttons style: align text left, NoFocus
  - on button click: setChecked always True, draw qr code at the end because it is slow
patch-4
ThomasV 2 years ago
parent
commit
0c8a828704
  1. 2
      electrum/gui/qt/receive_tab.py
  2. 11
      electrum/gui/qt/util.py

2
electrum/gui/qt/receive_tab.py

@ -155,6 +155,8 @@ class ReceiveTab(QWidget, MessageBoxMixin, Logger):
from .util import VTabWidget from .util import VTabWidget
self.receive_tabs = VTabWidget() self.receive_tabs = VTabWidget()
self.receive_tabs.setMinimumHeight(ReceiveTabWidget.min_size.height())
#self.receive_tabs.setMinimumHeight(ReceiveTabWidget.min_size.height() + 4) # for margins #self.receive_tabs.setMinimumHeight(ReceiveTabWidget.min_size.height() + 4) # for margins
self.receive_tabs.addTab(self.receive_URI_widget, read_QIcon("link.png"), _('URI')) self.receive_tabs.addTab(self.receive_URI_widget, read_QIcon("link.png"), _('URI'))
self.receive_tabs.addTab(self.receive_address_widget, read_QIcon("bitcoin.png"), _('Address')) self.receive_tabs.addTab(self.receive_address_widget, read_QIcon("bitcoin.png"), _('Address'))

11
electrum/gui/qt/util.py

@ -1576,7 +1576,6 @@ class SquareTabWidget(QtWidgets.QTabWidget):
# keep square aspect ratio when resized # keep square aspect ratio when resized
size = e.size() size = e.size()
w = size.height() w = size.height()
w += self.tabBar().width() if self.tabBar().isVisible() else 0
self.setFixedWidth(w) self.setFixedWidth(w)
return super().resizeEvent(e) return super().resizeEvent(e)
@ -1606,9 +1605,8 @@ class VTabWidget(QWidget):
_tabs_vbox_outer.addStretch(1) _tabs_vbox_outer.addStretch(1)
self.content_w = content_w = SquareTabWidget() self.content_w = content_w = SquareTabWidget()
content_w.setStyleSheet("QTabBar::tab {height: 0px;}") # TODO Linux/mac: still insufficient to rm top padding... content_w.setStyleSheet("QWidget {height: 0px; padding:0px; } QTabBar::tab {height: 0px; padding:0px; }")
content_w.tabBar().hide() content_w.tabBar().setMaximumHeight(0) # without this QDarkStyle displays the underlining
hbox.addStretch(1) hbox.addStretch(1)
hbox.addWidget(_tabs_vbox_outer_w) hbox.addWidget(_tabs_vbox_outer_w)
hbox.addWidget(content_w) hbox.addWidget(content_w)
@ -1618,14 +1616,17 @@ class VTabWidget(QWidget):
def addTab(self, widget: QWidget, icon: QIcon, text: str): def addTab(self, widget: QWidget, icon: QIcon, text: str):
btn = QPushButton(icon, text) btn = QPushButton(icon, text)
btn.setStyleSheet("QPushButton { text-align: left; }")
btn.setFocusPolicy(QtCore.Qt.NoFocus)
btn.setCheckable(True) btn.setCheckable(True)
btn.setSizePolicy(QSizePolicy.Preferred, btn.sizePolicy().verticalPolicy()) btn.setSizePolicy(QSizePolicy.Preferred, btn.sizePolicy().verticalPolicy())
def on_btn_click(): def on_btn_click():
self.content_w.setCurrentIndex(idx) btn.setChecked(True)
for btn2 in self._tab_btns: for btn2 in self._tab_btns:
if btn2 != btn: if btn2 != btn:
btn2.setChecked(False) btn2.setChecked(False)
self.content_w.setCurrentIndex(idx)
btn.clicked.connect(on_btn_click) btn.clicked.connect(on_btn_click)
idx = len(self._tab_btns) idx = len(self._tab_btns)
self._tab_btns.append(btn) self._tab_btns.append(btn)

Loading…
Cancel
Save