From d005da1ea248df1c99883860c893644c924621dc Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Mon, 24 Feb 2025 17:49:52 +0100 Subject: [PATCH] qml: remove display states in ReceiveDialog, add balance check for enabling Lightning receive option. --- .../qml/components/ReceiveDetailsDialog.qml | 1 + electrum/gui/qml/components/ReceiveDialog.qml | 65 +++---------------- 2 files changed, 9 insertions(+), 57 deletions(-) diff --git a/electrum/gui/qml/components/ReceiveDetailsDialog.qml b/electrum/gui/qml/components/ReceiveDetailsDialog.qml index 040d8cd80..23c840e9e 100644 --- a/electrum/gui/qml/components/ReceiveDetailsDialog.qml +++ b/electrum/gui/qml/components/ReceiveDetailsDialog.qml @@ -106,6 +106,7 @@ ElDialog { } FlatButton { Layout.fillWidth: true + enabled: Daemon.currentWallet.isLightning && Daemon.currentWallet.lightningCanReceive.satsInt > amountBtc.textAsSats.satsInt text: qsTr('Lightning') icon.source: '../../icons/lightning.png' onClicked: { dialog.isLightning = true; doAccept() } diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index aadde2175..c4837cd66 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -48,21 +48,6 @@ ElDialog { width: parent.width spacing: constants.paddingMedium - states: [ - State { - name: 'bolt11' - PropertyChanges { target: qrloader; sourceComponent: qri_bolt11 } - }, - State { - name: 'bip21uri' - PropertyChanges { target: qrloader; sourceComponent: qri_bip21uri } - }, - State { - name: 'address' - PropertyChanges { target: qrloader; sourceComponent: qri_address } - } - ] - TextHighlightPane { Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true @@ -80,33 +65,15 @@ ElDialog { color: 'white' - Loader { - id: qrloader + QRImage { anchors.centerIn: parent - Component { - id: qri_bolt11 - QRImage { - qrdata: _bolt11 - render: _render_qr - enableToggleText: true - } - } - Component { - id: qri_bip21uri - QRImage { - qrdata: _bip21uri - render: _render_qr - enableToggleText: true - } - } - Component { - id: qri_address - QRImage { - qrdata: _address - render: _render_qr - enableToggleText: true - } - } + qrdata: _bolt11 + ? _bolt11 + : _bip21uri + ? _bip21uri + : _address + render: _render_qr + enableToggleText: true } } } @@ -250,22 +217,6 @@ ElDialog { RequestDetails { id: request wallet: Daemon.currentWallet - onDetailsChanged: { - var req_type = Config.preferredRequestType - if (bolt11 && req_type == 'bolt11') { - rootLayout.state = 'bolt11' - } else if (bip21 && req_type == 'bip21uri') { - rootLayout.state = 'bip21uri' - } else if (req_type == 'address') { - rootLayout.state = 'address' - } else if (bolt11) { - rootLayout.state = 'bolt11' - } else if (bip21) { - rootLayout.state = 'bip21uri' - } else { - rootLayout.state = 'address' - } - } onStatusChanged: { if (status == RequestDetails.Paid || status == RequestDetails.Unconfirmed) { _ispaid = true