From bb3f3991e8652a794feb28a0d5e866582dadd5ee Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Wed, 19 Oct 2022 10:00:56 +0200 Subject: [PATCH] qml: detect request paid status on receive dialog --- electrum/gui/qml/components/ReceiveDialog.qml | 39 ++++++++++++++++++- electrum/gui/qml/qerequestdetails.py | 20 ++++++++-- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index 499854966..bdefa37e3 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -19,6 +19,8 @@ ElDialog { property bool _render_qr: false // delay qr rendering until dialog is shown + property bool _ispaid: false + parent: Overlay.overlay modal: true standardButtons: Dialog.Close @@ -31,6 +33,7 @@ ElDialog { id: rootLayout width: parent.width spacing: constants.paddingMedium + visible: !_ispaid states: [ State { @@ -198,9 +201,38 @@ ElDialog { onClicked: receiveDetailsDialog.open() } } - } + ColumnLayout { + visible: _ispaid + anchors.centerIn: parent + states: [ + State { + name: 'paid' + when: _ispaid + } + ] + transitions: [ + Transition { + from: '' + to: 'paid' + NumberAnimation { target: paidIcon; properties: 'opacity'; from: 0; to: 1; duration: 200 } + NumberAnimation { target: paidIcon; properties: 'scale'; from: 0; to: 1; duration: 500; easing.type: Easing.OutBack; easing.overshoot: 10 } + } + ] + Image { + id: paidIcon + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: constants.iconSizeXXLarge + Layout.preferredHeight: constants.iconSizeXXLarge + source: '../../icons/confirmed.png' + } + Label { + Layout.alignment: Qt.AlignHCenter + text: qsTr('Paid!') + font.pixelSize: constants.fontSizeXXLarge + } + } // make clicking the dialog background move the scope away from textedit fields // so the keyboard goes away @@ -266,6 +298,11 @@ ElDialog { rootLayout.state = 'address' } } + onStatusChanged: { + if (status == RequestDetails.Paid || status == RequestDetails.Unconfirmed) { + _ispaid = true + } + } } ReceiveDetailsDialog { diff --git a/electrum/gui/qml/qerequestdetails.py b/electrum/gui/qml/qerequestdetails.py index 8dbf9f71f..38bc8522e 100644 --- a/electrum/gui/qml/qerequestdetails.py +++ b/electrum/gui/qml/qerequestdetails.py @@ -1,22 +1,34 @@ from time import time -from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QTimer +from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QTimer, Q_ENUMS from electrum.logging import get_logger -from electrum.invoices import PR_UNPAID, LN_EXPIRY_NEVER +from electrum.invoices import (PR_UNPAID, PR_EXPIRED, PR_UNKNOWN, PR_PAID, PR_INFLIGHT, + PR_FAILED, PR_ROUTING, PR_UNCONFIRMED, LN_EXPIRY_NEVER) from .qewallet import QEWallet from .qetypes import QEAmount class QERequestDetails(QObject): - _logger = get_logger(__name__) + class Status: + Unpaid = PR_UNPAID + Expired = PR_EXPIRED + Unknown = PR_UNKNOWN + Paid = PR_PAID + Inflight = PR_INFLIGHT + Failed = PR_FAILED + Routing = PR_ROUTING + Unconfirmed = PR_UNCONFIRMED + + Q_ENUMS(Status) + + _logger = get_logger(__name__) _wallet = None _key = None _req = None _timer = None - _amount = None detailsChanged = pyqtSignal() # generic request properties changed signal