Browse Source

qt ReceiveTabWidget: add frame to "help label", and rm some nesting

patch-4
SomberNight 3 years ago
parent
commit
b97d080617
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 25
      electrum/gui/qt/receive_tab.py

25
electrum/gui/qt/receive_tab.py

@ -7,7 +7,7 @@ from typing import Optional, TYPE_CHECKING
from PyQt5.QtGui import QFont from PyQt5.QtGui import QFont
from PyQt5.QtCore import Qt, QSize from PyQt5.QtCore import Qt, QSize
from PyQt5.QtWidgets import (QComboBox, QLabel, QVBoxLayout, QGridLayout, QLineEdit, from PyQt5.QtWidgets import (QComboBox, QLabel, QVBoxLayout, QGridLayout, QLineEdit,
QHBoxLayout, QPushButton, QWidget, QSizePolicy) QHBoxLayout, QPushButton, QWidget, QSizePolicy, QFrame)
from electrum.bitcoin import is_address from electrum.bitcoin import is_address
from electrum.i18n import _ from electrum.i18n import _
@ -101,17 +101,12 @@ class ReceiveTab(QWidget, MessageBoxMixin, Logger):
grid.addLayout(buttons, 4, 0, 1, -1) grid.addLayout(buttons, 4, 0, 1, -1)
self.receive_address_e = ButtonsTextEdit() self.receive_address_e = ButtonsTextEdit()
self.receive_address_help_text = WWLabel('') self.receive_address_help = WWLabel('')
vbox = QVBoxLayout()
vbox.addWidget(self.receive_address_help_text)
self.receive_address_help = QWidget()
self.receive_address_help.setVisible(False)
self.receive_address_help.setLayout(vbox)
self.receive_URI_e = ButtonsTextEdit() self.receive_URI_e = ButtonsTextEdit()
self.receive_URI_help = WWLabel('') self.receive_URI_help = WWLabel('')
self.receive_lightning_e = ButtonsTextEdit() self.receive_lightning_e = ButtonsTextEdit()
self.receive_lightning_help_text = WWLabel('') self.receive_lightning_help = WWLabel('')
self.receive_rebalance_button = QPushButton('Rebalance') self.receive_rebalance_button = QPushButton('Rebalance')
self.receive_rebalance_button.suggestion = None self.receive_rebalance_button.suggestion = None
def on_receive_rebalance(): def on_receive_rebalance():
@ -129,12 +124,6 @@ class ReceiveTab(QWidget, MessageBoxMixin, Logger):
buttons = QHBoxLayout() buttons = QHBoxLayout()
buttons.addWidget(self.receive_rebalance_button) buttons.addWidget(self.receive_rebalance_button)
buttons.addWidget(self.receive_swap_button) buttons.addWidget(self.receive_swap_button)
vbox = QVBoxLayout()
vbox.addWidget(self.receive_lightning_help_text)
vbox.addLayout(buttons)
self.receive_lightning_help = QWidget()
self.receive_lightning_help.setVisible(False)
self.receive_lightning_help.setLayout(vbox)
self.receive_address_qr = QRCodeWidget() self.receive_address_qr = QRCodeWidget()
self.receive_URI_qr = QRCodeWidget() self.receive_URI_qr = QRCodeWidget()
self.receive_lightning_qr = QRCodeWidget() self.receive_lightning_qr = QRCodeWidget()
@ -268,12 +257,12 @@ class ReceiveTab(QWidget, MessageBoxMixin, Logger):
self.receive_address_e.setText(addr) self.receive_address_e.setText(addr)
self.update_receive_address_styling() self.update_receive_address_styling()
self.receive_address_qr.setData(addr) self.receive_address_qr.setData(addr)
self.receive_address_help_text.setText(address_help) self.receive_address_help.setText(address_help)
self.receive_URI_e.setText(URI) self.receive_URI_e.setText(URI)
self.receive_URI_qr.setData(URI) self.receive_URI_qr.setData(URI)
self.receive_URI_help.setText(URI_help) self.receive_URI_help.setText(URI_help)
self.receive_lightning_e.setText(lnaddr) # TODO maybe prepend "lightning:" ?? self.receive_lightning_e.setText(lnaddr) # TODO maybe prepend "lightning:" ??
self.receive_lightning_help_text.setText(ln_help) self.receive_lightning_help.setText(ln_help)
self.receive_lightning_qr.setData(lnaddr_qr) self.receive_lightning_qr.setData(lnaddr_qr)
# macOS hack (similar to #4777) # macOS hack (similar to #4777)
self.receive_lightning_e.repaint() self.receive_lightning_e.repaint()
@ -397,7 +386,7 @@ class ReceiveTab(QWidget, MessageBoxMixin, Logger):
class ReceiveTabWidget(QWidget): class ReceiveTabWidget(QWidget):
min_size = QSize(200, 200) min_size = QSize(200, 200)
def __init__(self, receive_tab: 'ReceiveTab', textedit: QWidget, qr: QWidget, help_widget: QWidget): def __init__(self, receive_tab: 'ReceiveTab', textedit: QWidget, qr: QWidget, help_widget: QLabel):
self.textedit = textedit self.textedit = textedit
self.qr = qr self.qr = qr
self.help_widget = help_widget self.help_widget = help_widget
@ -409,6 +398,8 @@ class ReceiveTabWidget(QWidget):
tooltip = _('Click to switch between text and QR code view') tooltip = _('Click to switch between text and QR code view')
w.setToolTip(tooltip) w.setToolTip(tooltip)
textedit.setFocusPolicy(Qt.NoFocus) textedit.setFocusPolicy(Qt.NoFocus)
help_widget.setFrameStyle(QFrame.StyledPanel)
help_widget.setStyleSheet("QLabel {border:1px solid gray; border-radius:2px; }")
hbox = QHBoxLayout() hbox = QHBoxLayout()
hbox.setContentsMargins(0, 0, 0, 0) hbox.setContentsMargins(0, 0, 0, 0)
hbox.addWidget(textedit) hbox.addWidget(textedit)

Loading…
Cancel
Save