From 7efd6fe1e2db66de93292ead2259138bde1b4ade Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Wed, 29 Mar 2023 18:25:29 +0200 Subject: [PATCH] qml: don't show ln payment dialog, update info text instead --- electrum/gui/qml/components/InvoiceDialog.qml | 25 +++++++++++++++++-- .../gui/qml/components/WalletMainView.qml | 5 ---- electrum/gui/qml/qeinvoice.py | 4 ++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index 688e93720..20c944905 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -47,10 +47,11 @@ ElDialog { columns: 2 InfoTextArea { + id: helpText Layout.columnSpan: 2 Layout.fillWidth: true Layout.bottomMargin: constants.paddingLarge - visible: invoice.userinfo + visible: text text: invoice.userinfo iconStyle: InfoTextArea.IconStyle.Warn } @@ -457,14 +458,34 @@ ElDialog { // save invoice if new or modified invoice.save_invoice() } - dialog.close() doPay() // only signal here + helpText.text = qsTr('Payment in progress...') } } } } + Connections { + target: Daemon.currentWallet + function onPaymentSucceeded(key) { + if (key != invoice.key) { + console.log('wrong invoice ' + key + ' != ' + invoice.key) + return + } + console.log('payment succeeded!') + helpText.text = qsTr('Paid!') + } + function onPaymentFailed(key, reason) { + if (key != invoice.key) { + console.log('wrong invoice ' + key + ' != ' + invoice.key) + return + } + console.log('payment failed: ' + reason) + helpText.text = qsTr('Payment failed: ' + reason) + } + } + Component.onCompleted: { if (invoice_key != '') { invoice.initFromKey(invoice_key) diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index c4fd23c55..91f008575 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -312,13 +312,8 @@ Item { console.log('No invoice key, aborting') return } - var dialog = lightningPaymentProgressDialog.createObject(mainView, { - invoice_key: invoice.key - }) - dialog.open() Daemon.currentWallet.pay_lightning_invoice(invoice.key) } - close() } onClosed: destroy() diff --git a/electrum/gui/qml/qeinvoice.py b/electrum/gui/qml/qeinvoice.py index 5707e0228..f887b7d0f 100644 --- a/electrum/gui/qml/qeinvoice.py +++ b/electrum/gui/qml/qeinvoice.py @@ -347,8 +347,10 @@ class QEInvoiceParser(QEInvoice): self.canSave = True - if amount.isEmpty: # unspecified amount + if self.amount.isEmpty: self.userinfo = _('Enter the amount you want to send') + + if amount.isEmpty and self.status == PR_UNPAID: # unspecified amount return if self.invoiceType == QEInvoice.Type.LightningInvoice: