Browse Source

qml: make zero balance visible in balance details. Disable open channel button if there is no confirmed balance

master
ThomasV 3 years ago
parent
commit
da802d20ad
  1. 20
      electrum/gui/qml/components/BalanceDetails.qml
  2. 3
      electrum/gui/qml/components/Channels.qml

20
electrum/gui/qml/components/BalanceDetails.qml

@ -92,50 +92,46 @@ Pane {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
visible: Daemon.currentWallet visible: Daemon.currentWallet
columns: 3 columns: 3
Item { Item {
visible: !Daemon.currentWallet.totalBalance.isEmpty
Layout.preferredWidth: 1; Layout.preferredHeight: 1 Layout.preferredWidth: 1; Layout.preferredHeight: 1
} }
Label { Label {
visible: !Daemon.currentWallet.totalBalance.isEmpty
text: qsTr('Total') text: qsTr('Total')
} }
FormattedAmount { FormattedAmount {
visible: !Daemon.currentWallet.totalBalance.isEmpty
amount: Daemon.currentWallet.totalBalance amount: Daemon.currentWallet.totalBalance
} }
Rectangle { Rectangle {
visible: !Daemon.currentWallet.lightningBalance.isEmpty visible: Daemon.currentWallet.isLightning
Layout.preferredWidth: constants.iconSizeXSmall Layout.preferredWidth: constants.iconSizeXSmall
Layout.preferredHeight: constants.iconSizeXSmall Layout.preferredHeight: constants.iconSizeXSmall
color: constants.colorPiechartLightning color: constants.colorPiechartLightning
} }
Label { Label {
visible: !Daemon.currentWallet.lightningBalance.isEmpty visible: Daemon.currentWallet.isLightning
text: qsTr('Lightning') text: qsTr('Lightning')
} }
FormattedAmount { FormattedAmount {
visible: Daemon.currentWallet.isLightning
amount: Daemon.currentWallet.lightningBalance amount: Daemon.currentWallet.lightningBalance
visible: !Daemon.currentWallet.lightningBalance.isEmpty
} }
Rectangle { Rectangle {
visible: !Daemon.currentWallet.lightningBalance.isEmpty || !Daemon.currentWallet.frozenBalance.isEmpty visible: Daemon.currentWallet.isLightning || !Daemon.currentWallet.frozenBalance.isEmpty
Layout.preferredWidth: constants.iconSizeXSmall Layout.preferredWidth: constants.iconSizeXSmall
Layout.preferredHeight: constants.iconSizeXSmall Layout.preferredHeight: constants.iconSizeXSmall
color: constants.colorPiechartOnchain color: constants.colorPiechartOnchain
} }
Label { Label {
visible: !Daemon.currentWallet.lightningBalance.isEmpty || !Daemon.currentWallet.frozenBalance.isEmpty visible: Daemon.currentWallet.isLightning || !Daemon.currentWallet.frozenBalance.isEmpty
text: qsTr('On-chain') text: qsTr('On-chain')
} }
FormattedAmount { FormattedAmount {
visible: Daemon.currentWallet.isLightning || !Daemon.currentWallet.frozenBalance.isEmpty
amount: Daemon.currentWallet.confirmedBalance amount: Daemon.currentWallet.confirmedBalance
visible: !Daemon.currentWallet.lightningBalance.isEmpty || !Daemon.currentWallet.frozenBalance.isEmpty
} }
Rectangle { Rectangle {
@ -163,7 +159,8 @@ Pane {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredWidth: 1 Layout.preferredWidth: 1
text: qsTr('Lightning swap'); text: qsTr('Lightning swap');
visible: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0 visible: Daemon.currentWallet.isLightning
enabled: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0
icon.source: Qt.resolvedUrl('../../icons/update.png') icon.source: Qt.resolvedUrl('../../icons/update.png')
onClicked: { onClicked: {
var swaphelper = app.swaphelper.createObject(app) var swaphelper = app.swaphelper.createObject(app)
@ -181,6 +178,7 @@ Pane {
Layout.preferredWidth: 1 Layout.preferredWidth: 1
text: qsTr('Open Channel') text: qsTr('Open Channel')
visible: Daemon.currentWallet.isLightning visible: Daemon.currentWallet.isLightning
enabled: Daemon.currentWallet.confirmedBalance.satInt > 0
onClicked: { onClicked: {
var dialog = openChannelDialog.createObject(rootItem) var dialog = openChannelDialog.createObject(rootItem)
dialog.open() dialog.open()

3
electrum/gui/qml/components/Channels.qml

@ -123,7 +123,7 @@ Pane {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredWidth: 1 Layout.preferredWidth: 1
text: qsTr('Swap'); text: qsTr('Swap');
visible: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0 enabled: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0
icon.source: Qt.resolvedUrl('../../icons/update.png') icon.source: Qt.resolvedUrl('../../icons/update.png')
onClicked: { onClicked: {
var swaphelper = app.swaphelper.createObject(app) var swaphelper = app.swaphelper.createObject(app)
@ -139,6 +139,7 @@ Pane {
FlatButton { FlatButton {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredWidth: 1 Layout.preferredWidth: 1
enabled: Daemon.currentWallet.confirmedBalance.satInt > 0
text: qsTr('Open Channel') text: qsTr('Open Channel')
onClicked: { onClicked: {
var dialog = openChannelDialog.createObject(root) var dialog = openChannelDialog.createObject(root)

Loading…
Cancel
Save