From fd791f4fb1b664df031eaf12a8ff43999275d3fd Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 30 Sep 2022 09:27:55 +0200 Subject: [PATCH] qml: make request types clickable, some fixes --- electrum/gui/qml/components/InvoiceDialog.qml | 6 +++--- electrum/gui/qml/components/Pin.qml | 10 +++++++--- .../gui/qml/components/ReceiveDetailsDialog.qml | 2 ++ electrum/gui/qml/components/ReceiveDialog.qml | 15 +++++++++++++++ electrum/gui/qml/qewallet.py | 2 +- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index bdda90aa2..518e867bd 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -227,7 +227,7 @@ ElDialog { Label { visible: invoice.invoiceType == Invoice.LightningInvoice Layout.fillWidth: true - text: invoice.lnprops.pubkey + text: invoice.lnprops ? invoice.lnprops.pubkey : '' font.family: FixedFont wrapMode: Text.Wrap } @@ -241,7 +241,7 @@ ElDialog { Label { visible: invoice.invoiceType == Invoice.LightningInvoice Layout.fillWidth: true - text: invoice.lnprops.t + text: invoice.lnprops ? invoice.lnprops.t : '' font.family: FixedFont wrapMode: Text.Wrap } @@ -255,7 +255,7 @@ ElDialog { Label { visible: invoice.invoiceType == Invoice.LightningInvoice Layout.fillWidth: true - text: invoice.lnprops.r + text: invoice.lnprops ? invoice.lnprops.r : '' font.family: FixedFont wrapMode: Text.Wrap } diff --git a/electrum/gui/qml/components/Pin.qml b/electrum/gui/qml/components/Pin.qml index 62ca09d7a..c7209641b 100644 --- a/electrum/gui/qml/components/Pin.qml +++ b/electrum/gui/qml/components/Pin.qml @@ -15,8 +15,7 @@ ElDialog { width: parent.width * 2/3 height: parent.height * 1/3 - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 + anchors.centerIn: parent modal: true parent: Overlay.overlay @@ -121,7 +120,7 @@ ElDialog { TextField { id: pin - Layout.preferredWidth: root.width *2/3 + Layout.preferredWidth: fontMetrics.advanceWidth(passwordCharacter) * 6 Layout.alignment: Qt.AlignHCenter font.pixelSize: constants.fontSizeXXLarge maximumLength: 6 @@ -146,4 +145,9 @@ ElDialog { Item { Layout.fillHeight: true; Layout.preferredWidth: 1 } } + FontMetrics { + id: fontMetrics + font: pin.font + } + } diff --git a/electrum/gui/qml/components/ReceiveDetailsDialog.qml b/electrum/gui/qml/components/ReceiveDetailsDialog.qml index 6c59f209e..f72599c96 100644 --- a/electrum/gui/qml/components/ReceiveDetailsDialog.qml +++ b/electrum/gui/qml/components/ReceiveDetailsDialog.qml @@ -25,6 +25,8 @@ ElDialog { color: "#aa000000" } + implicitWidth: parent.width + GridLayout { id: form width: parent.width diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index 77f9fe6dc..7ef4477d9 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -120,6 +120,11 @@ ElDialog { id: bolt11label text: qsTr('Lightning') color: _bolt11 ? Material.foreground : constants.mutedForeground + MouseArea { + anchors.fill: parent + enabled: _bolt11 + onClicked: rootLayout.state = 'bolt11' + } } Rectangle { Layout.preferredWidth: constants.paddingXXSmall @@ -131,6 +136,11 @@ ElDialog { id: bip21label text: qsTr('URI') color: _bip21uri ? Material.foreground : constants.mutedForeground + MouseArea { + anchors.fill: parent + enabled: _bip21uri + onClicked: rootLayout.state = 'bip21uri' + } } Rectangle { Layout.preferredWidth: constants.paddingXXSmall @@ -142,6 +152,11 @@ ElDialog { id: addresslabel text: qsTr('Address') color: _address ? Material.foreground : constants.mutedForeground + MouseArea { + anchors.fill: parent + enabled: _address + onClicked: rootLayout.state = 'address' + } } } diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index c06917a5f..f0709d877 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -534,7 +534,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener): def createDefaultRequest(self, ignore_gap: bool = False): try: default_expiry = self.wallet.config.get('request_expiry', PR_DEFAULT_EXPIRATION_WHEN_CREATING) - if self.wallet.lnworker.channels: + if self.wallet.lnworker and self.wallet.lnworker.channels: addr = None if self.wallet.config.get('bolt11_fallback', True): addr = self.wallet.get_unused_address()