electrum

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

commit 4c2e1970f260a9688f7bf528657f0e1351b73ee3
parent 947211fe4ecde0488063b3f54dc5e46424b098b5
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 23 Feb 2020 21:18:46 +0100

qt receive tab: better "Clear" behaviour

Previously, the selection would not get cleared, and if the user clicked
again on the already selected item, the click would get ignored
(request would not get populated).

Diffstat:
Melectrum/gui/qt/main_window.py | 1+
Melectrum/gui/qt/request_list.py | 10++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -1206,6 +1206,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): self.receive_amount_e.setAmount(None) self.expires_label.hide() self.expires_combo.show() + self.request_list.clearSelection() def toggle_qr_window(self): from . import qrwindow diff --git a/electrum/gui/qt/request_list.py b/electrum/gui/qt/request_list.py @@ -27,7 +27,7 @@ from enum import IntEnum from PyQt5.QtGui import QStandardItemModel, QStandardItem from PyQt5.QtWidgets import QMenu -from PyQt5.QtCore import Qt, QItemSelectionModel +from PyQt5.QtCore import Qt, QItemSelectionModel, QModelIndex from electrum.i18n import _ from electrum.util import format_time, get_request_status @@ -75,7 +75,9 @@ class RequestList(MyTreeView): self.selectionModel().setCurrentIndex(item, QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows) break - def item_changed(self, idx): + def item_changed(self, idx: QModelIndex): + if not idx.isValid(): + return # TODO use siblingAtColumn when min Qt version is >=5.11 item = self.model().itemFromIndex(idx.sibling(idx.row(), self.Columns.DATE)) request_type = item.data(ROLE_REQUEST_TYPE) @@ -91,6 +93,10 @@ class RequestList(MyTreeView): self.parent.receive_payreq_e.setText(req.get('URI')) self.parent.receive_address_e.setText(req['address']) + def clearSelection(self): + super().clearSelection() + self.selectionModel().clearCurrentIndex() + def refresh_status(self): m = self.model() for r in range(m.rowCount()):