From f12fe4af4d75befa74cf3d3b8b42fe5500a95cd7 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 24 Feb 2023 14:47:28 +0100 Subject: [PATCH] qml: add option to open ReceiveDialog with existing request key --- electrum/gui/qml/components/ReceiveDialog.qml | 10 ++++++++-- electrum/gui/qml/components/ReceiveRequests.qml | 10 ++++++---- electrum/gui/qml/components/WalletMainView.qml | 6 ++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index ac666c58a..52cc2a87b 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -13,6 +13,8 @@ ElDialog { title: qsTr('Receive Payment') + property string key + property string _bolt11: request.bolt11 property string _bip21uri: request.bip21 property string _address: request.address @@ -441,8 +443,12 @@ ElDialog { } Component.onCompleted: { - // callLater to make sure any popups are on top of the dialog stacking order - Qt.callLater(createDefaultRequest) + if (dialog.key) { + request.key = dialog.key + } else { + // callLater to make sure any popups are on top of the dialog stacking order + Qt.callLater(createDefaultRequest) + } } // hack. delay qr rendering until dialog is shown diff --git a/electrum/gui/qml/components/ReceiveRequests.qml b/electrum/gui/qml/components/ReceiveRequests.qml index b4d285b4f..f0171ab91 100644 --- a/electrum/gui/qml/components/ReceiveRequests.qml +++ b/electrum/gui/qml/components/ReceiveRequests.qml @@ -5,6 +5,8 @@ import QtQuick.Controls.Material 2.0 import QtQml.Models 2.1 import QtQml 2.6 +import org.electrum 1.0 + import "controls" Pane { @@ -35,10 +37,10 @@ Pane { model: Daemon.currentWallet.requestModel delegate: InvoiceDelegate { onClicked: { - //var dialog = app.stack.getRoot().openInvoice(model.key) - // dialog.invoiceAmountChanged.connect(function () { - // Daemon.currentWallet.invoiceModel.init_model() - // }) + // TODO: only open unpaid? + if (model.status == Invoice.Unpaid) { + app.stack.getRoot().openRequest(model.key) + } } } } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index 72a4df14b..d629cf4b7 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -21,6 +21,12 @@ Item { return dialog } + function openRequest(key) { + var dialog = receiveDialog.createObject(app, { key: key }) + dialog.open() + return dialog + } + function openSendDialog() { _sendDialog = sendDialog.createObject(mainView, {invoiceParser: invoiceParser}) _sendDialog.open()