Browse Source

qml: add total balance, fix initialization of create recoverable channels setting

patch-4
Sander van Grieken 2 years ago
parent
commit
3a8cfcd5b8
  1. 1
      electrum/gui/qml/components/Preferences.qml
  2. 83
      electrum/gui/qml/components/controls/BalanceSummary.qml
  3. 6
      electrum/gui/qml/qewallet.py

1
electrum/gui/qml/components/Preferences.qml

@ -270,5 +270,6 @@ Pane {
useFallbackAddress.checked = Config.useFallbackAddress useFallbackAddress.checked = Config.useFallbackAddress
enableDebugLogs.checked = Config.enableDebugLogs enableDebugLogs.checked = Config.enableDebugLogs
useRbf.checked = Config.useRbf useRbf.checked = Config.useRbf
useRecoverableChannels.checked = Config.useRecoverableChannels
} }
} }

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

@ -8,8 +8,10 @@ Frame {
font.pixelSize: constants.fontSizeMedium font.pixelSize: constants.fontSizeMedium
property string formattedBalance property string formattedTotalBalance
property string formattedBalanceFiat property string formattedTotalBalanceFiat
property string formattedOnchainBalance
property string formattedOnchainBalanceFiat
property string formattedUnconfirmed property string formattedUnconfirmed
property string formattedUnconfirmedFiat property string formattedUnconfirmedFiat
property string formattedFrozen property string formattedFrozen
@ -18,12 +20,14 @@ Frame {
property string formattedLightningBalanceFiat property string formattedLightningBalanceFiat
function setBalances() { function setBalances() {
root.formattedBalance = Config.formatSats(Daemon.currentWallet.confirmedBalance) root.formattedTotalBalance = Config.formatSats(Daemon.currentWallet.totalBalance)
root.formattedOnchainBalance = Config.formatSats(Daemon.currentWallet.confirmedBalance)
root.formattedUnconfirmed = Config.formatSats(Daemon.currentWallet.unconfirmedBalance) root.formattedUnconfirmed = Config.formatSats(Daemon.currentWallet.unconfirmedBalance)
root.formattedFrozen = Config.formatSats(Daemon.currentWallet.frozenBalance) root.formattedFrozen = Config.formatSats(Daemon.currentWallet.frozenBalance)
root.formattedLightningBalance = Config.formatSats(Daemon.currentWallet.lightningBalance) root.formattedLightningBalance = Config.formatSats(Daemon.currentWallet.lightningBalance)
if (Daemon.fx.enabled) { if (Daemon.fx.enabled) {
root.formattedBalanceFiat = Daemon.fx.fiatValue(Daemon.currentWallet.confirmedBalance, false) root.formattedTotalBalanceFiat = Daemon.fx.fiatValue(Daemon.currentWallet.totalBalance, false)
root.formattedOnchainBalanceFiat = Daemon.fx.fiatValue(Daemon.currentWallet.confirmedBalance, false)
root.formattedUnconfirmedFiat = Daemon.fx.fiatValue(Daemon.currentWallet.unconfirmedBalance, false) root.formattedUnconfirmedFiat = Daemon.fx.fiatValue(Daemon.currentWallet.unconfirmedBalance, false)
root.formattedFrozenFiat = Daemon.fx.fiatValue(Daemon.currentWallet.frozenBalance, false) root.formattedFrozenFiat = Daemon.fx.fiatValue(Daemon.currentWallet.frozenBalance, false)
root.formattedLightningBalanceFiat = Daemon.fx.fiatValue(Daemon.currentWallet.lightningBalance, false) root.formattedLightningBalanceFiat = Daemon.fx.fiatValue(Daemon.currentWallet.lightningBalance, false)
@ -32,11 +36,26 @@ Frame {
GridLayout { GridLayout {
id: layout id: layout
columns: 2 columns: 2
Label {
font.pixelSize: constants.fontSizeXLarge
text: qsTr('Balance')
color: Material.accentColor
Layout.columnSpan: 2
Layout.alignment: Qt.AlignHCenter
}
Rectangle {
color: Material.accentColor
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.preferredHeight: 1
}
Label { Label {
font.pixelSize: constants.fontSizeXLarge font.pixelSize: constants.fontSizeXLarge
text: qsTr('Balance:') text: qsTr('Total:')
color: Material.accentColor color: Material.accentColor
Layout.alignment: Qt.AlignRight | Qt.AlignTop Layout.alignment: Qt.AlignRight | Qt.AlignTop
} }
@ -47,7 +66,7 @@ Frame {
Label { Label {
font.pixelSize: constants.fontSizeXLarge font.pixelSize: constants.fontSizeXLarge
font.family: FixedFont font.family: FixedFont
text: formattedBalance text: formattedTotalBalance
} }
Label { Label {
font.pixelSize: constants.fontSizeXLarge font.pixelSize: constants.fontSizeXLarge
@ -60,13 +79,43 @@ Frame {
visible: Daemon.fx.enabled visible: Daemon.fx.enabled
font.pixelSize: constants.fontSizeSmall font.pixelSize: constants.fontSizeSmall
color: constants.mutedForeground color: constants.mutedForeground
text: root.formattedBalanceFiat + ' ' + Daemon.fx.fiatCurrency text: root.formattedTotalBalanceFiat + ' ' + Daemon.fx.fiatCurrency
}
}
Label {
font.pixelSize: constants.fontSizeMedium
text: qsTr('On-chain:')
color: Material.accentColor
Layout.alignment: Qt.AlignRight | Qt.AlignTop
}
ColumnLayout {
spacing: 0
RowLayout {
Label {
font.pixelSize: constants.fontSizeMedium
font.family: FixedFont
text: formattedOnchainBalance
}
Label {
font.pixelSize: constants.fontSizeMedium
color: Material.accentColor
text: Config.baseUnit
}
}
Label {
visible: Daemon.fx.enabled
font.pixelSize: constants.fontSizeSmall
color: constants.mutedForeground
text: root.formattedOnchainBalanceFiat + ' ' + Daemon.fx.fiatCurrency
} }
} }
Label { Label {
visible: Daemon.currentWallet.unconfirmedBalance.satsInt > 0 visible: Daemon.currentWallet.unconfirmedBalance.satsInt > 0
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeMedium
text: qsTr('Unconfirmed:') text: qsTr('Unconfirmed:')
color: Material.accentColor color: Material.accentColor
Layout.alignment: Qt.AlignRight | Qt.AlignTop Layout.alignment: Qt.AlignRight | Qt.AlignTop
@ -76,12 +125,12 @@ Frame {
spacing: 0 spacing: 0
RowLayout { RowLayout {
Label { Label {
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeMedium
font.family: FixedFont font.family: FixedFont
text: formattedUnconfirmed text: formattedUnconfirmed
} }
Label { Label {
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeMedium
color: Material.accentColor color: Material.accentColor
text: Config.baseUnit text: Config.baseUnit
} }
@ -96,7 +145,7 @@ Frame {
Label { Label {
visible: Daemon.currentWallet.frozenBalance.satsInt > 0 visible: Daemon.currentWallet.frozenBalance.satsInt > 0
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeMedium
text: qsTr('Frozen:') text: qsTr('Frozen:')
color: Material.accentColor color: Material.accentColor
Layout.alignment: Qt.AlignRight | Qt.AlignTop Layout.alignment: Qt.AlignRight | Qt.AlignTop
@ -107,12 +156,12 @@ Frame {
RowLayout { RowLayout {
Label { Label {
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeMedium
font.family: FixedFont font.family: FixedFont
text: root.formattedFrozen text: root.formattedFrozen
} }
Label { Label {
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeMedium
color: Material.accentColor color: Material.accentColor
text: Config.baseUnit text: Config.baseUnit
} }
@ -127,7 +176,7 @@ Frame {
Label { Label {
visible: Daemon.currentWallet.isLightning visible: Daemon.currentWallet.isLightning
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeMedium
text: qsTr('Lightning:') text: qsTr('Lightning:')
color: Material.accentColor color: Material.accentColor
Layout.alignment: Qt.AlignRight | Qt.AlignTop Layout.alignment: Qt.AlignRight | Qt.AlignTop
@ -138,12 +187,12 @@ Frame {
RowLayout { RowLayout {
Label { Label {
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeMedium
font.family: FixedFont font.family: FixedFont
text: formattedLightningBalance text: formattedLightningBalance
} }
Label { Label {
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeMedium
color: Material.accentColor color: Material.accentColor
text: Config.baseUnit text: Config.baseUnit
} }

6
electrum/gui/qml/qewallet.py

@ -366,6 +366,12 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
self._lightningbalance = QEAmount(amount_sat=int(self.wallet.lnworker.get_balance())) self._lightningbalance = QEAmount(amount_sat=int(self.wallet.lnworker.get_balance()))
return self._lightningbalance return self._lightningbalance
@pyqtProperty(QEAmount, notify=balanceChanged)
def totalBalance(self):
total = self.confirmedBalance.satsInt + self.lightningBalance.satsInt
self._totalBalance = QEAmount(amount_sat=total)
return self._totalBalance
@pyqtProperty(QEAmount, notify=balanceChanged) @pyqtProperty(QEAmount, notify=balanceChanged)
def lightningCanSend(self): def lightningCanSend(self):
if not self.isLightning: if not self.isLightning:

Loading…
Cancel
Save