electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit abb076061615e77cf01ed105a9520ab7f8eaad42
parent 99f736f3e73c5b3ed5832f360fefd82e6b289e89
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 29 Feb 2020 11:21:10 +0100

Simplify receive tab:
 - display receiving address in receiving tabs
 - display lightning invoice as 'address'
 - save last active tab in preferences

Diffstat:
Melectrum/gui/qt/main_window.py | 43++++++++++---------------------------------
Melectrum/gui/qt/request_list.py | 2+-
2 files changed, 11 insertions(+), 34 deletions(-)

diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -1049,6 +1049,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): grid.addLayout(buttons, 4, 3, 1, 2) self.receive_payreq_e = ButtonsTextEdit() + self.receive_payreq_e.setFont(QFont(MONOSPACE_FONT)) self.receive_payreq_e.addCopyButton(self.app) self.receive_payreq_e.setReadOnly(True) self.receive_payreq_e.textChanged.connect(self.update_receive_qr) @@ -1059,21 +1060,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): self.receive_qr.enterEvent = lambda x: self.app.setOverrideCursor(QCursor(Qt.PointingHandCursor)) self.receive_qr.leaveEvent = lambda x: self.app.setOverrideCursor(QCursor(Qt.ArrowCursor)) - def on_receive_address_changed(): - addr = str(self.receive_address_e.text()) - self.receive_address_widgets.setVisible(bool(addr)) - - msg = _('Bitcoin address where the payment should be received. Note that each payment request uses a different Bitcoin address.') - receive_address_label = HelpLabel(_('Receiving address'), msg) - self.receive_address_e = ButtonsTextEdit() self.receive_address_e.setFont(QFont(MONOSPACE_FONT)) self.receive_address_e.addCopyButton(self.app) self.receive_address_e.setReadOnly(True) - self.receive_address_e.textChanged.connect(on_receive_address_changed) self.receive_address_e.textChanged.connect(self.update_receive_address_styling) - self.receive_address_e.setMinimumHeight(6 * char_width_in_lineedit()) - self.receive_address_e.setMaximumHeight(10 * char_width_in_lineedit()) + qr_show = lambda: self.show_qrcode(str(self.receive_address_e.text()), _('Receiving address'), parent=self) qr_icon = "qrcode_white.png" if ColorScheme.dark_scheme else "qrcode.png" self.receive_address_e.addButton(qr_icon, qr_show, _("Show as QR code")) @@ -1083,34 +1075,21 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): from .request_list import RequestList self.request_list = RequestList(self) + receive_tabs = QTabWidget() + receive_tabs.addTab(self.receive_address_e, _('Address')) + receive_tabs.addTab(self.receive_payreq_e, _('Request')) + receive_tabs.addTab(self.receive_qr, _('QR Code')) + receive_tabs.setCurrentIndex(self.config.get('receive_tabs_index', 0)) + receive_tabs.currentChanged.connect(lambda i: self.config.set_key('receive_tabs_index', i)) + # layout vbox_g = QVBoxLayout() vbox_g.addLayout(grid) vbox_g.addStretch() - - receive_tabbed_widgets = QTabWidget() - receive_tabbed_widgets.addTab(self.receive_qr, 'QR Code') - receive_tabbed_widgets.addTab(self.receive_payreq_e, 'Text') - - vbox_receive_address = QVBoxLayout() - vbox_receive_address.setContentsMargins(0, 0, 0, 0) - vbox_receive_address.setSpacing(0) - vbox_receive_address.addWidget(receive_address_label) - vbox_receive_address.addWidget(self.receive_address_e) - self.receive_address_widgets = QWidget() - self.receive_address_widgets.setLayout(vbox_receive_address) - size_policy = self.receive_address_widgets.sizePolicy() - size_policy.setRetainSizeWhenHidden(True) - self.receive_address_widgets.setSizePolicy(size_policy) - - vbox_receive = QVBoxLayout() - vbox_receive.addWidget(receive_tabbed_widgets) - vbox_receive.addWidget(self.receive_address_widgets) - hbox = QHBoxLayout() hbox.addLayout(vbox_g) hbox.addStretch() - hbox.addLayout(vbox_receive) + hbox.addWidget(receive_tabs) w = QWidget() w.searchable_list = self.request_list @@ -1122,8 +1101,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): vbox.addWidget(self.request_list) vbox.setStretchFactor(self.request_list, 1000) - on_receive_address_changed() - return w def delete_request(self, key): diff --git a/electrum/gui/qt/request_list.py b/electrum/gui/qt/request_list.py @@ -93,7 +93,7 @@ class RequestList(MyTreeView): return if request_type == PR_TYPE_LN: self.parent.receive_payreq_e.setText(req.get('invoice')) - self.parent.receive_address_e.setText('') + self.parent.receive_address_e.setText(req.get('invoice')) else: self.parent.receive_payreq_e.setText(req.get('URI')) self.parent.receive_address_e.setText(req['address'])