From e43983e8543424df3a84db280c33262947c7094a Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sun, 22 May 2022 13:32:24 +0200 Subject: [PATCH] Qt: update current request when update_tabs is called --- electrum/gui/qt/main_window.py | 14 +++++++++++++- electrum/gui/qt/request_list.py | 6 ++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 6d4dbe336..bcd7af4f5 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -203,6 +203,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): self.showing_cert_mismatch_error = False self.tl_windows = [] self.pending_invoice = None + self.current_request = None # request shown in the receive tab Logger.__init__(self) self._coroutines_scheduled = set() # type: Set[concurrent.futures.Future] @@ -1039,6 +1040,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): return self.history_model.refresh('update_tabs') self.request_list.update() + self.update_current_request() self.invoice_list.update() self.address_list.update() self.utxo_list.update() @@ -1293,7 +1295,17 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): return w - def show_receive_request(self, req): + def set_current_request(self, req): + self.current_request = req + self.update_current_request() + + def update_current_request(self): + req = self.current_request + if req is None: + self.receive_URI_e.setText('') + self.receive_lightning_e.setText('') + self.receive_address_e.setText('') + return addr = req.get_address() or '' amount_sat = req.get_amount_sat() or 0 address_help = '' if addr else _('Amount too small to be received onchain') diff --git a/electrum/gui/qt/request_list.py b/electrum/gui/qt/request_list.py index 571cf5d24..e25cb63d5 100644 --- a/electrum/gui/qt/request_list.py +++ b/electrum/gui/qt/request_list.py @@ -85,9 +85,7 @@ class RequestList(MyTreeView): def item_changed(self, idx: Optional[QModelIndex]): if idx is None: - self.parent.receive_URI_e.setText('') - self.parent.receive_lightning_e.setText('') - self.parent.receive_address_e.setText('') + self.parent.set_current_request(None) return if not idx.isValid(): return @@ -98,7 +96,7 @@ class RequestList(MyTreeView): if req is None: self.update() return - self.parent.show_receive_request(req) + self.parent.set_current_request(req) def clearSelection(self): super().clearSelection()