Changeset View
Changeset View
Standalone View
Standalone View
src/qt/overviewpage.cpp
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | |||||
OverviewPage::~OverviewPage() { | OverviewPage::~OverviewPage() { | ||||
delete ui; | delete ui; | ||||
} | } | ||||
void OverviewPage::setBalance(const interfaces::WalletBalances &balances) { | void OverviewPage::setBalance(const interfaces::WalletBalances &balances) { | ||||
int unit = walletModel->getOptionsModel()->getDisplayUnit(); | int unit = walletModel->getOptionsModel()->getDisplayUnit(); | ||||
m_balances = balances; | m_balances = balances; | ||||
if (walletModel->privateKeysDisabled()) { | |||||
ui->labelBalance->setText( | |||||
BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance, | |||||
false, BitcoinUnits::separatorAlways)); | |||||
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit( | |||||
unit, balances.unconfirmed_watch_only_balance, false, | |||||
BitcoinUnits::separatorAlways)); | |||||
ui->labelImmature->setText(BitcoinUnits::formatWithUnit( | |||||
unit, balances.immature_watch_only_balance, false, | |||||
BitcoinUnits::separatorAlways)); | |||||
ui->labelTotal->setText(BitcoinUnits::formatWithUnit( | |||||
unit, | |||||
balances.watch_only_balance + | |||||
balances.unconfirmed_watch_only_balance + | |||||
balances.immature_watch_only_balance, | |||||
false, BitcoinUnits::separatorAlways)); | |||||
} else { | |||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit( | ui->labelBalance->setText(BitcoinUnits::formatWithUnit( | ||||
unit, balances.balance, false, BitcoinUnits::separatorAlways)); | unit, balances.balance, false, BitcoinUnits::separatorAlways)); | ||||
ui->labelUnconfirmed->setText( | ui->labelUnconfirmed->setText( | ||||
BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, false, | BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, | ||||
false, BitcoinUnits::separatorAlways)); | |||||
ui->labelImmature->setText( | |||||
BitcoinUnits::formatWithUnit(unit, balances.immature_balance, false, | |||||
BitcoinUnits::separatorAlways)); | BitcoinUnits::separatorAlways)); | ||||
ui->labelImmature->setText(BitcoinUnits::formatWithUnit( | |||||
unit, balances.immature_balance, false, BitcoinUnits::separatorAlways)); | |||||
ui->labelTotal->setText(BitcoinUnits::formatWithUnit( | ui->labelTotal->setText(BitcoinUnits::formatWithUnit( | ||||
unit, | unit, | ||||
balances.balance + balances.unconfirmed_balance + | balances.balance + balances.unconfirmed_balance + | ||||
balances.immature_balance, | balances.immature_balance, | ||||
false, BitcoinUnits::separatorAlways)); | false, BitcoinUnits::separatorAlways)); | ||||
ui->labelWatchAvailable->setText( | ui->labelWatchAvailable->setText( | ||||
BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance, false, | BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance, | ||||
BitcoinUnits::separatorAlways)); | false, BitcoinUnits::separatorAlways)); | ||||
ui->labelWatchPending->setText(BitcoinUnits::formatWithUnit( | ui->labelWatchPending->setText(BitcoinUnits::formatWithUnit( | ||||
unit, balances.unconfirmed_watch_only_balance, false, | unit, balances.unconfirmed_watch_only_balance, false, | ||||
BitcoinUnits::separatorAlways)); | BitcoinUnits::separatorAlways)); | ||||
ui->labelWatchImmature->setText( | ui->labelWatchImmature->setText(BitcoinUnits::formatWithUnit( | ||||
BitcoinUnits::formatWithUnit(unit, balances.immature_watch_only_balance, | unit, balances.immature_watch_only_balance, false, | ||||
false, BitcoinUnits::separatorAlways)); | BitcoinUnits::separatorAlways)); | ||||
ui->labelWatchTotal->setText(BitcoinUnits::formatWithUnit( | ui->labelWatchTotal->setText(BitcoinUnits::formatWithUnit( | ||||
unit, | unit, | ||||
balances.watch_only_balance + balances.unconfirmed_watch_only_balance + | balances.watch_only_balance + | ||||
balances.unconfirmed_watch_only_balance + | |||||
balances.immature_watch_only_balance, | balances.immature_watch_only_balance, | ||||
false, BitcoinUnits::separatorAlways)); | false, BitcoinUnits::separatorAlways)); | ||||
} | |||||
// only show immature (newly mined) balance if it's non-zero, so as not to | // only show immature (newly mined) balance if it's non-zero, so as not to | ||||
// complicate things for the non-mining users | // complicate things for the non-mining users | ||||
bool showImmature = balances.immature_balance != Amount::zero(); | bool showImmature = balances.immature_balance != Amount::zero(); | ||||
bool showWatchOnlyImmature = | bool showWatchOnlyImmature = | ||||
balances.immature_watch_only_balance != Amount::zero(); | balances.immature_watch_only_balance != Amount::zero(); | ||||
// for symmetry reasons also show immature label when the watch-only one is | // for symmetry reasons also show immature label when the watch-only one is | ||||
// shown | // shown | ||||
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature); | ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature); | ||||
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature); | ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature); | ||||
ui->labelWatchImmature->setVisible( | // show watch-only immature balance | ||||
showWatchOnlyImmature); // show watch-only immature balance | ui->labelWatchImmature->setVisible(!walletModel->privateKeysDisabled() && | ||||
showWatchOnlyImmature); | |||||
} | } | ||||
// show/hide watch-only labels | // show/hide watch-only labels | ||||
void OverviewPage::updateWatchOnlyLabels(bool showWatchOnly) { | void OverviewPage::updateWatchOnlyLabels(bool showWatchOnly) { | ||||
// show spendable label (only when watch-only is active) | // show spendable label (only when watch-only is active) | ||||
ui->labelSpendable->setVisible(showWatchOnly); | ui->labelSpendable->setVisible(showWatchOnly); | ||||
// show watch-only label | // show watch-only label | ||||
ui->labelWatchonly->setVisible(showWatchOnly); | ui->labelWatchonly->setVisible(showWatchOnly); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (model && model->getOptionsModel()) { | ||||
interfaces::WalletBalances balances = wallet.getBalances(); | interfaces::WalletBalances balances = wallet.getBalances(); | ||||
setBalance(balances); | setBalance(balances); | ||||
connect(model, &WalletModel::balanceChanged, this, | connect(model, &WalletModel::balanceChanged, this, | ||||
&OverviewPage::setBalance); | &OverviewPage::setBalance); | ||||
connect(model->getOptionsModel(), &OptionsModel::displayUnitChanged, | connect(model->getOptionsModel(), &OptionsModel::displayUnitChanged, | ||||
this, &OverviewPage::updateDisplayUnit); | this, &OverviewPage::updateDisplayUnit); | ||||
updateWatchOnlyLabels(wallet.haveWatchOnly()); | updateWatchOnlyLabels(wallet.haveWatchOnly() && | ||||
connect(model, &WalletModel::notifyWatchonlyChanged, this, | !model->privateKeysDisabled()); | ||||
&OverviewPage::updateWatchOnlyLabels); | connect(model, &WalletModel::notifyWatchonlyChanged, | ||||
[this](bool showWatchOnly) { | |||||
updateWatchOnlyLabels(showWatchOnly && | |||||
!walletModel->privateKeysDisabled()); | |||||
}); | |||||
} | } | ||||
// update the display unit, to not use the default ("BCH") | // update the display unit, to not use the default ("BCH") | ||||
updateDisplayUnit(); | updateDisplayUnit(); | ||||
} | } | ||||
void OverviewPage::updateDisplayUnit() { | void OverviewPage::updateDisplayUnit() { | ||||
if (walletModel && walletModel->getOptionsModel()) { | if (walletModel && walletModel->getOptionsModel()) { | ||||
Show All 20 Lines |