Browse Source

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
master
Sander van Grieken 3 years ago
parent
commit
6111c69f1e
  1. 20
      electrum/gui/qml/components/ReceiveDialog.qml
  2. 49
      electrum/gui/qml/components/controls/BalanceSummary.qml
  3. 23
      electrum/gui/qml/components/controls/FormattedAmount.qml

20
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 { Rectangle {
height: 1 height: 1
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
@ -410,5 +429,4 @@ ElDialog {
} }
} }
} }
} }

49
electrum/gui/qml/components/controls/BalanceSummary.qml

@ -11,18 +11,14 @@ Item {
property string formattedTotalBalance property string formattedTotalBalance
property string formattedTotalBalanceFiat property string formattedTotalBalanceFiat
property string formattedLightningCanReceive
property string formattedLightningCanReceiveFiat
property string formattedLightningCanSend property string formattedLightningCanSend
property string formattedLightningCanSendFiat property string formattedLightningCanSendFiat
function setBalances() { function setBalances() {
root.formattedTotalBalance = Config.formatSats(Daemon.currentWallet.totalBalance) root.formattedTotalBalance = Config.formatSats(Daemon.currentWallet.totalBalance)
root.formattedLightningCanReceive = Config.formatSats(Daemon.currentWallet.lightningCanReceive)
root.formattedLightningCanSend = Config.formatSats(Daemon.currentWallet.lightningCanSend) root.formattedLightningCanSend = Config.formatSats(Daemon.currentWallet.lightningCanSend)
if (Daemon.fx.enabled) { if (Daemon.fx.enabled) {
root.formattedTotalBalanceFiat = Daemon.fx.fiatValue(Daemon.currentWallet.totalBalance, false) 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) root.formattedLightningCanSendFiat = Daemon.fx.fiatValue(Daemon.currentWallet.lightningCanSend, false)
} }
} }
@ -68,49 +64,6 @@ Item {
color: constants.mutedForeground color: constants.mutedForeground
text: Daemon.fx.fiatCurrency 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 { RowLayout {
visible: Daemon.currentWallet.isLightning visible: Daemon.currentWallet.isLightning
@ -120,7 +73,7 @@ Item {
source: '../../../icons/lightning.png' source: '../../../icons/lightning.png'
} }
Label { Label {
text: qsTr('can send:') text: qsTr('Lightning:')
font.pixelSize: constants.fontSizeSmall font.pixelSize: constants.fontSizeSmall
color: Material.accentColor color: Material.accentColor
} }

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

@ -34,9 +34,30 @@ GridLayout {
} }
Label { Label {
id: fiatLabel
Layout.columnSpan: singleLine ? 1 : 2 Layout.columnSpan: singleLine ? 1 : 2
visible: showAlt && Daemon.fx.enabled && valid visible: showAlt && Daemon.fx.enabled && valid
text: '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')'
font.pixelSize: constants.fontSizeSmall 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()
}
} }

Loading…
Cancel
Save