From 58e3e0c235e68f2cfb089e3b6aa4ccc81618fcd0 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Mon, 26 Sep 2022 15:41:16 +0200 Subject: [PATCH] add manual input option --- electrum/gui/qml/components/SendDialog.qml | 53 ++++++++++++-- .../gui/qml/components/WalletMainView.qml | 73 ++++++++++--------- 2 files changed, 85 insertions(+), 41 deletions(-) diff --git a/electrum/gui/qml/components/SendDialog.qml b/electrum/gui/qml/components/SendDialog.qml index c3ea45743..a0af923de 100644 --- a/electrum/gui/qml/components/SendDialog.qml +++ b/electrum/gui/qml/components/SendDialog.qml @@ -2,7 +2,6 @@ import QtQuick 2.6 import QtQuick.Controls 2.14 import QtQuick.Layouts 1.0 import QtQuick.Controls.Material 2.0 -import QtQml.Models 2.1 import org.electrum 1.0 @@ -13,8 +12,6 @@ ElDialog { property InvoiceParser invoiceParser - signal manualInput - parent: Overlay.overlay modal: true standardButtons: Dialog.Close @@ -28,8 +25,6 @@ ElDialog { padding: 0 - onClosed: destroy() - ColumnLayout { anchors.fill: parent @@ -44,7 +39,12 @@ ElDialog { Layout.fillWidth: true text: qsTr('Manual input') onClicked: { - manualInput() + var _mid = manualInputDialog.createObject(mainView) + _mid.accepted.connect(function() { + console.log(_mid.recipient) + invoiceParser.recipient = _mid.recipient + }) + _mid.open() } } @@ -55,4 +55,45 @@ ElDialog { } } + Component { + id: manualInputDialog + ElDialog { + property alias recipient: recipientTextEdit.text + + anchors.centerIn: parent + implicitWidth: parent.width * 0.9 + + parent: Overlay.overlay + modal: true + standardButtons: Dialog.Ok + + Overlay.modal: Rectangle { + color: "#aa000000" + } + + title: qsTr('Manual Input') + + ColumnLayout { + width: parent.width + + Label { + text: 'Enter a bitcoin address or a Lightning invoice' + wrapMode: Text.Wrap + } + + TextField { + id: recipientTextEdit + topPadding: constants.paddingXXLarge + bottomPadding: constants.paddingXXLarge + Layout.preferredWidth: parent.width + font.family: FixedFont + + wrapMode: TextInput.WrapAnywhere + placeholderText: qsTr('Enter the payment request here') + } + } + + onClosed: destroy() + } + } } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index a300b3fa7..492c3e870 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -73,8 +73,6 @@ Item { } } - property var _sendDialog - ColumnLayout { anchors.centerIn: parent width: parent.width @@ -115,11 +113,7 @@ Item { text: qsTr('Send') onClicked: { console.log('send') - var comp = Qt.createComponent(Qt.resolvedUrl('SendDialog.qml')) - if (comp.status == Component.Error) - console.log(comp.errorString()) - _sendDialog = comp.createObject(mainView, { invoiceParser: invoiceParser } ) - // dialog. + _sendDialog = sendDialog.createObject(mainView, {invoiceParser: invoiceParser}) _sendDialog.open() } } @@ -180,39 +174,48 @@ Item { Component { id: invoiceDialog - InvoiceDialog { - onDoPay: { - if (invoice.invoiceType == Invoice.OnchainInvoice) { - var dialog = confirmPaymentDialog.createObject(mainView, { - 'address': invoice.address, - 'satoshis': invoice.amount, - 'message': invoice.message - }) - var wo = Daemon.currentWallet.isWatchOnly - dialog.txaccepted.connect(function() { - if (wo) { - showUnsignedTx(dialog.finalizer.serializedTx(false), dialog.finalizer.serializedTx(true)) - } else { - dialog.finalizer.send_onchain() + InvoiceDialog { + onDoPay: { + if (invoice.invoiceType == Invoice.OnchainInvoice) { + var dialog = confirmPaymentDialog.createObject(mainView, { + 'address': invoice.address, + 'satoshis': invoice.amount, + 'message': invoice.message + }) + var wo = Daemon.currentWallet.isWatchOnly + dialog.txaccepted.connect(function() { + if (wo) { + showUnsignedTx(dialog.finalizer.serializedTx(false), dialog.finalizer.serializedTx(true)) + } else { + dialog.finalizer.send_onchain() + } + }) + dialog.open() + } else if (invoice.invoiceType == Invoice.LightningInvoice) { + console.log('About to pay lightning invoice') + if (invoice.key == '') { + console.log('No invoice key, aborting') + return } - }) - dialog.open() - } else if (invoice.invoiceType == Invoice.LightningInvoice) { - console.log('About to pay lightning invoice') - if (invoice.key == '') { - 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) } - var dialog = lightningPaymentProgressDialog.createObject(mainView, { - invoice_key: invoice.key - }) - dialog.open() - Daemon.currentWallet.pay_lightning_invoice(invoice.key) + close() } - close() + // onClosed: destroy() } - // onClosed: destroy() } + + property var _sendDialog + + Component { + id: sendDialog + SendDialog { + onClosed: destroy() + } } Component {