Merge #13966: gui: When private key is disabled, only show watch-only balance
82d6c5aad
gui: Show watch-only eye instead of HD disabled (Chun Kuan Lee)fe1ff5026
Hide spendable label if priveate key is disabled (Chun Kuan Lee) Pull request description: If a wallet is in private key disabled mode, the spendable balance is always zero, it does not have to show on GUI. Show the watch-only balance at normal balance column if a wallet is in that mode.  Tree-SHA512: 8b535427d26d3f8e61081f50e4773bd25656be042d378fd34cf647e9a0065cb4dfb67a8ab9fb4fbf5f196390df8cb983ebf2f0fa8a6503b7c046c56bec87ba72
This commit is contained in:
commit
ed12fd83ca
3 changed files with 25 additions and 17 deletions
|
@ -1089,10 +1089,10 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::setHDStatus(int hdEnabled)
|
void BitcoinGUI::setHDStatus(bool privkeyDisabled, int hdEnabled)
|
||||||
{
|
{
|
||||||
labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
|
labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(privkeyDisabled ? ":/icons/eye" : hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
|
||||||
labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
|
labelWalletHDStatusIcon->setToolTip(privkeyDisabled ? tr("Private key <b>disabled</b>") : hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
|
||||||
|
|
||||||
// eventually disable the QLabel to set its opacity to 50%
|
// eventually disable the QLabel to set its opacity to 50%
|
||||||
labelWalletHDStatusIcon->setEnabled(hdEnabled);
|
labelWalletHDStatusIcon->setEnabled(hdEnabled);
|
||||||
|
@ -1138,7 +1138,7 @@ void BitcoinGUI::updateWalletStatus()
|
||||||
}
|
}
|
||||||
WalletModel * const walletModel = walletView->getWalletModel();
|
WalletModel * const walletModel = walletView->getWalletModel();
|
||||||
setEncryptionStatus(walletModel->getEncryptionStatus());
|
setEncryptionStatus(walletModel->getEncryptionStatus());
|
||||||
setHDStatus(walletModel->wallet().hdEnabled());
|
setHDStatus(walletModel->privateKeysDisabled(), walletModel->wallet().hdEnabled());
|
||||||
}
|
}
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ private:
|
||||||
@param[in] hdEnabled current hd enabled status
|
@param[in] hdEnabled current hd enabled status
|
||||||
@see WalletModel::EncryptionStatus
|
@see WalletModel::EncryptionStatus
|
||||||
*/
|
*/
|
||||||
void setHDStatus(int hdEnabled);
|
void setHDStatus(bool privkeyDisabled, int hdEnabled);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
|
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
|
||||||
|
|
|
@ -161,6 +161,12 @@ 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(unit, balances.balance, false, BitcoinUnits::separatorAlways));
|
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balances.balance, false, BitcoinUnits::separatorAlways));
|
||||||
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, false, BitcoinUnits::separatorAlways));
|
||||||
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_balance, false, BitcoinUnits::separatorAlways));
|
||||||
|
@ -169,7 +175,7 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
|
||||||
ui->labelWatchPending->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelWatchPending->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
||||||
ui->labelWatchImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelWatchImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
||||||
ui->labelWatchTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelWatchTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
||||||
|
}
|
||||||
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
|
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
|
||||||
// for the non-mining users
|
// for the non-mining users
|
||||||
bool showImmature = balances.immature_balance != 0;
|
bool showImmature = balances.immature_balance != 0;
|
||||||
|
@ -178,7 +184,7 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
|
||||||
// for symmetry reasons also show immature label when the watch-only one is shown
|
// for symmetry reasons also show immature label when the watch-only one is shown
|
||||||
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
|
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
|
||||||
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
|
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
|
||||||
ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance
|
ui->labelWatchImmature->setVisible(!walletModel->privateKeysDisabled() && showWatchOnlyImmature); // show watch-only immature balance
|
||||||
}
|
}
|
||||||
|
|
||||||
// show/hide watch-only labels
|
// show/hide watch-only labels
|
||||||
|
@ -231,8 +237,10 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
||||||
|
|
||||||
connect(model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &OverviewPage::updateDisplayUnit);
|
connect(model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &OverviewPage::updateDisplayUnit);
|
||||||
|
|
||||||
updateWatchOnlyLabels(wallet.haveWatchOnly());
|
updateWatchOnlyLabels(wallet.haveWatchOnly() && !model->privateKeysDisabled());
|
||||||
connect(model, &WalletModel::notifyWatchonlyChanged, this, &OverviewPage::updateWatchOnlyLabels);
|
connect(model, &WalletModel::notifyWatchonlyChanged, [this](bool showWatchOnly) {
|
||||||
|
updateWatchOnlyLabels(showWatchOnly && !walletModel->privateKeysDisabled());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the display unit, to not use the default ("BTC")
|
// update the display unit, to not use the default ("BTC")
|
||||||
|
|
Loading…
Add table
Reference in a new issue