Hide 'unlocked balance' when no funds are available

This commit is contained in:
Sander Ferdinand 2017-11-23 15:28:52 +01:00 committed by moneromooo-monero
parent 2e89f86b9f
commit dc445edaae
2 changed files with 21 additions and 0 deletions

View file

@ -36,6 +36,8 @@ Rectangle {
id: panel id: panel
property alias unlockedBalanceText: unlockedBalanceText.text property alias unlockedBalanceText: unlockedBalanceText.text
property alias unlockedBalanceVisible: unlockedBalanceText.visible
property alias unlockedBalanceLabelVisible: unlockedBalanceLabel.visible
property alias balanceLabelText: balanceLabel.text property alias balanceLabelText: balanceLabel.text
property alias balanceText: balanceText.text property alias balanceText: balanceText.text
property alias networkStatus : networkStatus property alias networkStatus : networkStatus
@ -176,6 +178,7 @@ Rectangle {
Text { Text {
id: unlockedBalanceText id: unlockedBalanceText
visible: false
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 20 anchors.leftMargin: 20
anchors.top: parent.top anchors.top: parent.top
@ -196,6 +199,7 @@ Rectangle {
Label { Label {
id: unlockedBalanceLabel id: unlockedBalanceLabel
visible: false
text: qsTr("Unlocked balance") + translationManager.emptyString text: qsTr("Unlocked balance") + translationManager.emptyString
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 20 anchors.leftMargin: 20

View file

@ -381,6 +381,23 @@ ApplicationWindow {
function onWalletUpdate() { function onWalletUpdate() {
console.log(">>> wallet updated") console.log(">>> wallet updated")
updateBalance(); updateBalance();
var unlockedBalance = walletManager.displayAmount(currentWallet.unlockedBalance);
var unlockedBalanceFloat = parseFloat(unlockedBalance);
if(unlockedBalanceFloat === 0){
// no available funds; hide the 'unlocked balance' label
leftPanel.unlockedBalanceVisible = false
leftPanel.unlockedBalanceLabelVisible = false
} else {
leftPanel.unlockedBalanceVisible = true
leftPanel.unlockedBalanceLabelVisible = true
leftPanel.unlockedBalanceText.text = unlockedBalance
}
// showing middlePanel unlockedBalance regardless
middlePanel.unlockedBalanceText = leftPanel.unlockedBalanceText = unlockedBalance;
middlePanel.balanceText = leftPanel.balanceText = walletManager.displayAmount(currentWallet.balance);
// Update history if new block found since last update // Update history if new block found since last update
if(foundNewBlock) { if(foundNewBlock) {
foundNewBlock = false; foundNewBlock = false;