|
19 | 19 | #include "gridcoin/voting/fwd.h" |
20 | 20 |
|
21 | 21 | #include <QAbstractItemDelegate> |
| 22 | +#include <QApplication> |
22 | 23 | #include <QPainter> |
| 24 | +#include <QStatusTipEvent> |
23 | 25 |
|
24 | 26 | #define DECORATION_SIZE 40 |
25 | 27 |
|
@@ -262,12 +264,13 @@ void OverviewPage::setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBa |
262 | 264 | currentStake = stake; |
263 | 265 | currentUnconfirmedBalance = unconfirmedBalance; |
264 | 266 | currentImmatureBalance = immatureBalance; |
265 | | - ui->headerBalanceLabel->setText(BitcoinUnits::formatOverviewRounded(balance)); |
266 | | - ui->balanceLabel->setText(BitcoinUnits::formatWithUnit(unit, balance)); |
267 | | - ui->stakeLabel->setText(BitcoinUnits::formatWithUnit(unit, stake)); |
268 | | - ui->unconfirmedLabel->setText(BitcoinUnits::formatWithUnit(unit, unconfirmedBalance)); |
269 | | - ui->immatureLabel->setText(BitcoinUnits::formatWithUnit(unit, immatureBalance)); |
270 | | - ui->totalLabel->setText(BitcoinUnits::formatWithUnit(unit, balance + stake + unconfirmedBalance + immatureBalance)); |
| 267 | + ui->headerBalanceLabel->setText(BitcoinUnits::formatOverviewRounded(balance, m_privacy)); |
| 268 | + ui->balanceLabel->setText(BitcoinUnits::formatWithPrivacy(unit, balance, m_privacy)); |
| 269 | + ui->stakeLabel->setText(BitcoinUnits::formatWithPrivacy(unit, stake, m_privacy)); |
| 270 | + ui->unconfirmedLabel->setText(BitcoinUnits::formatWithPrivacy(unit, unconfirmedBalance, m_privacy)); |
| 271 | + ui->immatureLabel->setText(BitcoinUnits::formatWithPrivacy(unit, immatureBalance, m_privacy)); |
| 272 | + ui->totalLabel->setText(BitcoinUnits::formatWithPrivacy(unit, balance + stake + unconfirmedBalance + immatureBalance, |
| 273 | + m_privacy)); |
271 | 274 |
|
272 | 275 | // only show immature (newly mined) balance if it's non-zero, so as not to complicate things |
273 | 276 | // for the non-mining users |
@@ -297,6 +300,27 @@ void OverviewPage::setCurrentPollTitle(const QString& title) |
297 | 300 | ui->currentPollsTitleLabel->setText(title); |
298 | 301 | } |
299 | 302 |
|
| 303 | +void OverviewPage::setPrivacy(bool privacy) |
| 304 | +{ |
| 305 | + m_privacy = privacy; |
| 306 | + if (currentBalance != -1) { |
| 307 | + setBalance(currentBalance, currentStake, currentUnconfirmedBalance, currentImmatureBalance); |
| 308 | + } |
| 309 | + |
| 310 | + ui->listTransactions->setVisible(!m_privacy); |
| 311 | + ui->coinWeightTextLabel->setVisible(!m_privacy); |
| 312 | + ui->coinWeightLabel->setVisible(!m_privacy); |
| 313 | + |
| 314 | + const QString status_tip = m_privacy ? tr("Privacy mode activated for the Overview screen. To unmask the values, uncheck " |
| 315 | + "Settings->Mask values.") : ""; |
| 316 | + |
| 317 | + updateTransactions(); |
| 318 | + |
| 319 | + setStatusTip(status_tip); |
| 320 | + QStatusTipEvent event(status_tip); |
| 321 | + QApplication::sendEvent(this, &event); |
| 322 | +} |
| 323 | + |
300 | 324 | void OverviewPage::setResearcherModel(ResearcherModel *researcherModel) |
301 | 325 | { |
302 | 326 | this->researcherModel = researcherModel; |
@@ -337,6 +361,12 @@ void OverviewPage::setWalletModel(WalletModel *model) |
337 | 361 |
|
338 | 362 | connect(model->getOptionsModel(), &OptionsModel::LimitTxnDisplayChanged, this, &OverviewPage::updateTransactions); |
339 | 363 | connect(model, &WalletModel::transactionUpdated, this, &OverviewPage::updateTransactions); |
| 364 | + |
| 365 | + // Set the privacy state for the overview screen from the optionsModel for init. |
| 366 | + setPrivacy(model->getOptionsModel()->getMaskValues()); |
| 367 | + |
| 368 | + // Connect the privacy mode setting to the options dialog. |
| 369 | + connect(walletModel->getOptionsModel(), &OptionsModel::MaskValuesChanged, this, & OverviewPage::setPrivacy); |
340 | 370 | } |
341 | 371 |
|
342 | 372 | // update the display unit, to not use the default ("BTC") |
|
0 commit comments