From 82458e7cf06c41e99b35aa2ed250caac154794b1 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Mon, 9 Jan 2023 17:36:12 +0100 Subject: [PATCH] qml: use FormattedAmount in LightningPaymentDetails, formatter and fx now use millisats if available, else sats --- .../gui/qml/components/LightningPaymentDetails.qml | 13 ++----------- .../gui/qml/components/controls/FormattedAmount.qml | 2 +- electrum/gui/qml/qefx.py | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/electrum/gui/qml/components/LightningPaymentDetails.qml b/electrum/gui/qml/components/LightningPaymentDetails.qml index 9c496511f..e7127fc73 100644 --- a/electrum/gui/qml/components/LightningPaymentDetails.qml +++ b/electrum/gui/qml/components/LightningPaymentDetails.qml @@ -12,10 +12,7 @@ Pane { width: parent.width height: parent.height - // property string title: qsTr("Lightning payment details") - property string key - property alias label: lnpaymentdetails.label signal detailsChanged @@ -70,14 +67,8 @@ Pane { color: Material.accentColor } - RowLayout { - Label { - text: Config.formatMilliSats(lnpaymentdetails.amount) - } - Label { - text: Config.baseUnit - color: Material.accentColor - } + FormattedAmount { + amount: lnpaymentdetails.amount } Label { diff --git a/electrum/gui/qml/components/controls/FormattedAmount.qml b/electrum/gui/qml/components/controls/FormattedAmount.qml index 43f1d1f83..9d23113ae 100644 --- a/electrum/gui/qml/components/controls/FormattedAmount.qml +++ b/electrum/gui/qml/components/controls/FormattedAmount.qml @@ -9,7 +9,7 @@ RowLayout { required property Amount amount property bool showAlt: true Label { - text: Config.formatSats(amount) + text: amount.msatsInt > 0 ? Config.formatMilliSats(amount) : Config.formatSats(amount) font.family: FixedFont } Label { diff --git a/electrum/gui/qml/qefx.py b/electrum/gui/qml/qefx.py index c7b37c191..79d833aae 100644 --- a/electrum/gui/qml/qefx.py +++ b/electrum/gui/qml/qefx.py @@ -101,7 +101,7 @@ class QEFX(QObject, QtEventListener): def fiatValue(self, satoshis, plain=True): rate = self.fx.exchange_rate() if isinstance(satoshis, QEAmount): - satoshis = satoshis.satsInt + satoshis = satoshis.msatsInt / 1000 if satoshis.msatsInt > 0 else satoshis.satsInt else: try: sd = Decimal(satoshis) @@ -118,7 +118,7 @@ class QEFX(QObject, QtEventListener): @pyqtSlot(QEAmount, str, bool, result=str) def fiatValueHistoric(self, satoshis, timestamp, plain=True): if isinstance(satoshis, QEAmount): - satoshis = satoshis.satsInt + satoshis = satoshis.msatsInt / 1000 if satoshis.msatsInt > 0 else satoshis.satsInt else: try: sd = Decimal(satoshis)