From fed5fe59911d680d683789c81be37096331e2fa7 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 17 Mar 2023 23:02:43 +0100 Subject: [PATCH] Qml: new receive flow. fixes #8258 --- .../qml/components/ReceiveDetailsDialog.qml | 5 +- electrum/gui/qml/components/ReceiveDialog.qml | 61 ------------------- .../gui/qml/components/WalletMainView.qml | 51 +++++++++++++++- 3 files changed, 52 insertions(+), 65 deletions(-) diff --git a/electrum/gui/qml/components/ReceiveDetailsDialog.qml b/electrum/gui/qml/components/ReceiveDetailsDialog.qml index 290e6593e..f74998937 100644 --- a/electrum/gui/qml/components/ReceiveDetailsDialog.qml +++ b/electrum/gui/qml/components/ReceiveDetailsDialog.qml @@ -11,7 +11,7 @@ import "controls" ElDialog { id: dialog - title: qsTr('Edit payment request') + title: qsTr('Receive payment') property alias amount: amountBtc.text property alias description: message.text @@ -19,7 +19,6 @@ ElDialog { parent: Overlay.overlay modal: true - iconSource: Qt.resolvedUrl('../../icons/pen.png') Overlay.modal: Rectangle { color: "#aa000000" @@ -130,7 +129,7 @@ ElDialog { FlatButton { Layout.fillWidth: true - text: qsTr('Apply') + text: qsTr('Create request') icon.source: '../../icons/confirmed.png' onClicked: accept() } diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index d8cb65229..80336e307 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -22,8 +22,6 @@ ElDialog { property bool _render_qr: false // delay qr rendering until dialog is shown property bool _ispaid: false - property bool _ignore_gaplimit: false - property bool _reuse_address: false parent: Overlay.overlay modal: true @@ -283,14 +281,6 @@ ElDialog { enabled = true } } - FlatButton { - Layout.fillWidth: true - Layout.preferredWidth: 1 - - icon.source: '../../icons/pen.png' - text: qsTr('Edit') - onClicked: receiveDetailsDialog.open() - } } } @@ -334,41 +324,6 @@ ElDialog { FocusScope { id: parkFocus } } - function createRequest() { - var qamt = Config.unitsToSats(receiveDetailsDialog.amount) - Daemon.currentWallet.createRequest(qamt, receiveDetailsDialog.description, receiveDetailsDialog.expiry, _ignore_gaplimit, _reuse_address) - } - - function createDefaultRequest() { - console.log('Creating default request') - Daemon.currentWallet.createDefaultRequest(_ignore_gaplimit, _reuse_address) - } - - Connections { - target: Daemon.currentWallet - function onRequestCreateSuccess(key) { - request.key = key - } - function onRequestCreateError(code, error) { - if (code == 'gaplimit') { - var dialog = app.messageDialog.createObject(app, {text: error, yesno: true}) - dialog.yesClicked.connect(function() { - _ignore_gaplimit = true - createDefaultRequest() - }) - } else if (code == 'non-deterministic') { - var dialog = app.messageDialog.createObject(app, {text: error, yesno: true}) - dialog.yesClicked.connect(function() { - _reuse_address = true - createDefaultRequest() - }) - } else { - console.log(error) - var dialog = app.messageDialog.createObject(app, {text: error}) - } - dialog.open() - } - } RequestDetails { id: request @@ -396,22 +351,6 @@ ElDialog { } } - ReceiveDetailsDialog { - id: receiveDetailsDialog - - width: parent.width * 0.9 - anchors.centerIn: parent - - onAccepted: { - console.log('accepted') - Daemon.currentWallet.delete_request(request.key) - createRequest() - } - onRejected: { - console.log('rejected') - } - } - Toaster { id: toaster } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index a4d64daac..4d02dcd2f 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -16,6 +16,9 @@ Item { property var _sendDialog property string _intentUri + property bool _ignore_gaplimit: false + property bool _reuse_address: false + function openInvoice(key) { var dialog = invoiceDialog.createObject(app, { invoice: invoiceParser, invoice_key: key }) dialog.open() @@ -168,7 +171,7 @@ Item { icon.source: '../../icons/tab_receive.png' text: qsTr('Receive') onClicked: { - var dialog = receiveDialog.createObject(mainView) + var dialog = receiveDetails.createObject(mainView) dialog.open() } } @@ -238,6 +241,31 @@ Item { } } + Connections { + target: Daemon.currentWallet + function onRequestCreateSuccess(key) { + openRequest(key) + } + function onRequestCreateError(code, error) { + if (code == 'gaplimit') { + var dialog = app.messageDialog.createObject(app, {text: error, yesno: true}) + dialog.yesClicked.connect(function() { + _ignore_gaplimit = true + createDefaultRequest() + }) + } else if (code == 'non-deterministic') { + var dialog = app.messageDialog.createObject(app, {text: error, yesno: true}) + dialog.yesClicked.connect(function() { + _reuse_address = true + createDefaultRequest() + }) + } else { + console.log(error) + var dialog = app.messageDialog.createObject(app, {text: error}) + } + dialog.open() + } + } Connections { target: Daemon.currentWallet function onOtpRequested() { @@ -326,6 +354,27 @@ Item { } } + function createRequest(receiveDetailsDialog) { + var qamt = Config.unitsToSats(receiveDetailsDialog.amount) + Daemon.currentWallet.createRequest(qamt, receiveDetailsDialog.description, receiveDetailsDialog.expiry, _ignore_gaplimit, _reuse_address) + } + + Component { + id: receiveDetails + ReceiveDetailsDialog { + id: receiveDetailsDialog + width: parent.width * 0.9 + anchors.centerIn: parent + onAccepted: { + console.log('accepted') + createRequest(receiveDetailsDialog) + } + onRejected: { + console.log('rejected') + } + } + } + Component { id: receiveDialog ReceiveDialog {