Browse Source

qml: show historic fiat amounts when enabled and applicable

master
Sander van Grieken 3 years ago
parent
commit
3115ce2f53
  1. 2
      electrum/gui/qml/components/LightningPaymentDetails.qml
  2. 2
      electrum/gui/qml/components/TxDetails.qml
  3. 8
      electrum/gui/qml/components/controls/FormattedAmount.qml
  4. 11
      electrum/gui/qml/qelnpaymentdetails.py
  5. 6
      electrum/gui/qml/qetxdetails.py

2
electrum/gui/qml/components/LightningPaymentDetails.qml

@ -60,6 +60,7 @@ Pane {
FormattedAmount {
amount: lnpaymentdetails.amount
timestamp: lnpaymentdetails.timestamp
}
Label {
@ -71,6 +72,7 @@ Pane {
FormattedAmount {
visible: lnpaymentdetails.amount.msatsInt < 0
amount: lnpaymentdetails.fee
timestamp: lnpaymentdetails.timestamp
}
Label {

2
electrum/gui/qml/components/TxDetails.qml

@ -90,6 +90,7 @@ Pane {
Layout.preferredWidth: 1
Layout.fillWidth: true
amount: txdetails.lnAmount.isEmpty ? txdetails.amount : txdetails.lnAmount
timestamp: txdetails.timestamp
}
Label {
@ -104,6 +105,7 @@ Pane {
FormattedAmount {
Layout.fillWidth: true
amount: txdetails.fee
timestamp: txdetails.timestamp
}
}

8
electrum/gui/qml/components/controls/FormattedAmount.qml

@ -10,6 +10,8 @@ GridLayout {
property bool showAlt: true
property bool singleLine: true
property bool valid: true
property bool historic: Daemon.fx.historicRates
property int timestamp: 0
columns: !valid
? 1
@ -42,7 +44,11 @@ GridLayout {
function setFiatValue() {
if (showAlt)
fiatLabel.text = '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')'
if (historic && timestamp)
fiatLabel.text = '(' + Daemon.fx.fiatValueHistoric(amount, timestamp) + ' ' + Daemon.fx.fiatCurrency + ')'
else
fiatLabel.text = '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')'
}
onAmountChanged: setFiatValue()

11
electrum/gui/qml/qelnpaymentdetails.py

@ -6,6 +6,7 @@ from electrum.util import bfh, format_time
from .qetypes import QEAmount
from .qewallet import QEWallet
class QELnPaymentDetails(QObject):
_logger = get_logger(__name__)
@ -16,9 +17,14 @@ class QELnPaymentDetails(QObject):
self._wallet = None
self._key = None
self._label = ''
self._date = None
self._timestamp = 0
self._fee = QEAmount()
self._amount = QEAmount()
self._status = ''
self._phash = ''
self._preimage = ''
walletChanged = pyqtSignal()
@pyqtProperty(QEWallet, notify=walletChanged)
@ -64,6 +70,10 @@ class QELnPaymentDetails(QObject):
def date(self):
return self._date
@pyqtProperty(int, notify=detailsChanged)
def timestamp(self):
return self._timestamp
@pyqtProperty(str, notify=detailsChanged)
def paymentHash(self):
return self._phash
@ -93,6 +103,7 @@ class QELnPaymentDetails(QObject):
self._amount.msatsInt = int(tx['amount_msat'])
self._label = tx['label']
self._date = format_time(tx['timestamp'])
self._timestamp = tx['timestamp']
self._status = 'settled' # TODO: other states? get_lightning_history is deciding the filter for us :(
self._phash = tx['payment_hash']
self._preimage = tx['preimage']

6
electrum/gui/qml/qetxdetails.py

@ -57,6 +57,7 @@ class QETxDetails(QObject, QtEventListener):
self._mempool_depth = ''
self._date = ''
self._timestamp = 0
self._confirmations = 0
self._header_hash = ''
self._short_id = ""
@ -172,6 +173,10 @@ class QETxDetails(QObject, QtEventListener):
def date(self):
return self._date
@pyqtProperty(int, notify=detailsChanged)
def timestamp(self):
return self._timestamp
@pyqtProperty(int, notify=detailsChanged)
def confirmations(self):
return self._confirmations
@ -307,6 +312,7 @@ class QETxDetails(QObject, QtEventListener):
def update_mined_status(self, tx_mined_info: TxMinedInfo):
self._mempool_depth = ''
self._date = format_time(tx_mined_info.timestamp)
self._timestamp = tx_mined_info.timestamp
self._confirmations = tx_mined_info.conf
self._header_hash = tx_mined_info.header_hash
self._short_id = tx_mined_info.short_id() or ""

Loading…
Cancel
Save