From 6111c69f1e86ec1e5801af01587a48e8c1ed9c58 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 31 Jan 2023 14:00:41 +0100 Subject: [PATCH] qml: move Lightning can receive amount to ReceiveDialog, rename Lightning can send to Lightning (balance) in BalanceSummary FormattedAmount is now aware of FX rate changing and updates accordingly --- electrum/gui/qml/components/ReceiveDialog.qml | 20 +++++++- .../components/controls/BalanceSummary.qml | 49 +------------------ .../components/controls/FormattedAmount.qml | 23 ++++++++- 3 files changed, 42 insertions(+), 50 deletions(-) diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index 22a0fcc03..34d15ae1d 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -179,6 +179,25 @@ ElDialog { } } + RowLayout { + Layout.alignment: Qt.AlignHCenter + visible: Daemon.currentWallet.isLightning + spacing: constants.paddingXSmall + Image { + Layout.preferredWidth: constants.iconSizeSmall + Layout.preferredHeight: constants.iconSizeSmall + source: '../../icons/lightning.png' + } + Label { + text: qsTr('can receive:') + font.pixelSize: constants.fontSizeSmall + color: Material.accentColor + } + FormattedAmount { + amount: Daemon.currentWallet.lightningCanReceive + } + } + Rectangle { height: 1 Layout.alignment: Qt.AlignHCenter @@ -410,5 +429,4 @@ ElDialog { } } } - } diff --git a/electrum/gui/qml/components/controls/BalanceSummary.qml b/electrum/gui/qml/components/controls/BalanceSummary.qml index e3ef3afba..e3c9ffb92 100644 --- a/electrum/gui/qml/components/controls/BalanceSummary.qml +++ b/electrum/gui/qml/components/controls/BalanceSummary.qml @@ -11,18 +11,14 @@ Item { property string formattedTotalBalance property string formattedTotalBalanceFiat - property string formattedLightningCanReceive - property string formattedLightningCanReceiveFiat property string formattedLightningCanSend property string formattedLightningCanSendFiat function setBalances() { root.formattedTotalBalance = Config.formatSats(Daemon.currentWallet.totalBalance) - root.formattedLightningCanReceive = Config.formatSats(Daemon.currentWallet.lightningCanReceive) root.formattedLightningCanSend = Config.formatSats(Daemon.currentWallet.lightningCanSend) if (Daemon.fx.enabled) { root.formattedTotalBalanceFiat = Daemon.fx.fiatValue(Daemon.currentWallet.totalBalance, false) - root.formattedLightningCanReceiveFiat = Daemon.fx.fiatValue(Daemon.currentWallet.lightningCanReceive, false) root.formattedLightningCanSendFiat = Daemon.fx.fiatValue(Daemon.currentWallet.lightningCanSend, false) } } @@ -68,49 +64,6 @@ Item { color: constants.mutedForeground text: Daemon.fx.fiatCurrency } - RowLayout { - visible: Daemon.currentWallet.isLightning - Image { - Layout.preferredWidth: constants.iconSizeSmall - Layout.preferredHeight: constants.iconSizeSmall - source: '../../../icons/lightning.png' - } - Label { - text: qsTr('can receive:') - font.pixelSize: constants.fontSizeSmall - color: Material.accentColor - } - } - Label { - visible: Daemon.currentWallet.isLightning - Layout.alignment: Qt.AlignRight - text: formattedLightningCanReceive - font.family: FixedFont - } - Label { - visible: Daemon.currentWallet.isLightning - font.pixelSize: constants.fontSizeSmall - color: Material.accentColor - text: Config.baseUnit - } - Item { - visible: Daemon.currentWallet.isLightning && Daemon.fx.enabled - Layout.preferredHeight: 1 - Layout.preferredWidth: 1 - } - Label { - Layout.alignment: Qt.AlignRight - visible: Daemon.currentWallet.isLightning && Daemon.fx.enabled - font.pixelSize: constants.fontSizeSmall - color: constants.mutedForeground - text: formattedLightningCanReceiveFiat - } - Label { - visible: Daemon.currentWallet.isLightning && Daemon.fx.enabled - font.pixelSize: constants.fontSizeSmall - color: constants.mutedForeground - text: Daemon.fx.fiatCurrency - } RowLayout { visible: Daemon.currentWallet.isLightning @@ -120,7 +73,7 @@ Item { source: '../../../icons/lightning.png' } Label { - text: qsTr('can send:') + text: qsTr('Lightning:') font.pixelSize: constants.fontSizeSmall color: Material.accentColor } diff --git a/electrum/gui/qml/components/controls/FormattedAmount.qml b/electrum/gui/qml/components/controls/FormattedAmount.qml index ae1e716e0..cafc3d3c3 100644 --- a/electrum/gui/qml/components/controls/FormattedAmount.qml +++ b/electrum/gui/qml/components/controls/FormattedAmount.qml @@ -34,9 +34,30 @@ GridLayout { } Label { + id: fiatLabel Layout.columnSpan: singleLine ? 1 : 2 visible: showAlt && Daemon.fx.enabled && valid - text: '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')' font.pixelSize: constants.fontSizeSmall } + + function setFiatValue() { + fiatLabel.text = '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')' + } + + Connections { + target: Daemon.fx + function onQuotesUpdated() { setFiatValue() } + } + + Connections { + target: amount + function onValueChanged() { + setFiatValue() + } + } + + Component.onCompleted: { + if (showAlt) + setFiatValue() + } }