From 4c87773174f1d8da1eaecbea00c7d1019a1e0b58 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Mon, 3 Apr 2023 10:26:03 +0200 Subject: [PATCH] qml: move user_knowns_press_and_hold to config --- electrum/gui/qml/components/Invoices.qml | 2 +- electrum/gui/qml/components/ReceiveRequests.qml | 2 +- electrum/gui/qml/components/WalletMainView.qml | 2 +- electrum/gui/qml/qeconfig.py | 12 ++++++++++++ electrum/gui/qml/qewallet.py | 10 ---------- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/electrum/gui/qml/components/Invoices.qml b/electrum/gui/qml/components/Invoices.qml index 596427976..81a6eeee3 100644 --- a/electrum/gui/qml/components/Invoices.qml +++ b/electrum/gui/qml/components/Invoices.qml @@ -17,7 +17,7 @@ Pane { InfoTextArea { Layout.fillWidth: true Layout.bottomMargin: constants.paddingLarge - visible: !Daemon.currentWallet.userKnowsPressAndHold + visible: !Config.userKnowsPressAndHold text: qsTr('To access this list from the main screen, press and hold the Send button') } diff --git a/electrum/gui/qml/components/ReceiveRequests.qml b/electrum/gui/qml/components/ReceiveRequests.qml index f33ab8dea..456544728 100644 --- a/electrum/gui/qml/components/ReceiveRequests.qml +++ b/electrum/gui/qml/components/ReceiveRequests.qml @@ -20,7 +20,7 @@ Pane { InfoTextArea { Layout.fillWidth: true Layout.bottomMargin: constants.paddingLarge - visible: !Daemon.currentWallet.userKnowsPressAndHold + visible: !Config.userKnowsPressAndHold text: qsTr('To access this list from the main screen, press and hold the Receive button') } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index 7d89e80a3..5641d98b3 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -192,7 +192,7 @@ Item { dialog.open() } onPressAndHold: { - Daemon.currentWallet.userKnowsPressAndHold = true + Config.userKnowsPressAndHold = true Daemon.currentWallet.delete_expired_requests() app.stack.push(Qt.resolvedUrl('ReceiveRequests.qml')) } diff --git a/electrum/gui/qml/qeconfig.py b/electrum/gui/qml/qeconfig.py index 6dc934221..7a4c1720b 100644 --- a/electrum/gui/qml/qeconfig.py +++ b/electrum/gui/qml/qeconfig.py @@ -199,6 +199,18 @@ class QEConfig(AuthMixin, QObject): self.config.set_key('preferred_request_type', preferred_request_type) self.preferredRequestTypeChanged.emit() + userKnowsPressAndHoldChanged = pyqtSignal() + @pyqtProperty(bool, notify=userKnowsPressAndHoldChanged) + def userKnowsPressAndHold(self): + return self.config.get('user_knows_press_and_hold', False) + + @userKnowsPressAndHold.setter + def userKnowsPressAndHold(self, userKnowsPressAndHold): + if userKnowsPressAndHold != self.config.get('user_knows_press_and_hold', False): + self.config.set_key('user_knows_press_and_hold', userKnowsPressAndHold) + self.userKnowsPressAndHoldChanged.emit() + + @pyqtSlot('qint64', result=str) @pyqtSlot('qint64', bool, result=str) @pyqtSlot(QEAmount, result=str) diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index 605f9acc2..850bbf60e 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -125,18 +125,8 @@ class QEWallet(AuthMixin, QObject, QtEventListener): self.register_callbacks() self.destroyed.connect(lambda: self.on_destroy()) - self._user_knows_press_and_hold = False # maybe save in config? self.synchronizing = not wallet.is_up_to_date() - userKnowsPressAndHoldChanged = pyqtSignal() - @pyqtProperty(bool, notify=userKnowsPressAndHoldChanged) - def userKnowsPressAndHold(self): - return self._user_knows_press_and_hold - - @userKnowsPressAndHold.setter - def userKnowsPressAndHold(self, userKnowsPressAndHold): - self._user_knows_press_and_hold = userKnowsPressAndHold - synchronizingChanged = pyqtSignal() @pyqtProperty(bool, notify=synchronizingChanged) def synchronizing(self):