1919#include " gridcoin/voting/fwd.h"
2020
2121#include < QAbstractItemDelegate>
22+ #include < QApplication>
2223#include < QPainter>
24+ #include < QStatusTipEvent>
2325
2426#define DECORATION_SIZE 40
2527
@@ -196,8 +198,16 @@ int OverviewPage::getNumTransactionsForView()
196198 // Compute the maximum number of transactions the transaction list widget
197199 // can hold without overflowing.
198200 const size_t itemHeight = txdelegate->height () + ui->listTransactions ->spacing ();
199- const size_t contentsHeight = ui->listTransactions ->height ();
200- const int numItems = contentsHeight / itemHeight;
201+
202+ // We have to use the frame here because when the listTransactions is hidden, the recentTransactionsNoResult
203+ // takes up the space and would cause the calculation to be off.
204+ const size_t contentsHeight = std::max (ui->recentTransactionsFrame ->height () - ui->recentTransLabel ->height (), 0 );
205+
206+ LogPrint (BCLog::LogFlags::QT, " INFO: %s: contentsHeight = %u, itemHeight = %u" ,
207+ __func__, contentsHeight, itemHeight);
208+
209+ // take one off so that there is not a "half-visible one" there, ensure not below 0.
210+ const int numItems = std::max ((int ) (contentsHeight / itemHeight) - 1 , 0 );
201211
202212 return numItems;
203213}
@@ -262,12 +272,13 @@ void OverviewPage::setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBa
262272 currentStake = stake;
263273 currentUnconfirmedBalance = unconfirmedBalance;
264274 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));
275+ ui->headerBalanceLabel ->setText (BitcoinUnits::formatOverviewRounded (balance, m_privacy));
276+ ui->balanceLabel ->setText (BitcoinUnits::formatWithPrivacy (unit, balance, m_privacy));
277+ ui->stakeLabel ->setText (BitcoinUnits::formatWithPrivacy (unit, stake, m_privacy));
278+ ui->unconfirmedLabel ->setText (BitcoinUnits::formatWithPrivacy (unit, unconfirmedBalance, m_privacy));
279+ ui->immatureLabel ->setText (BitcoinUnits::formatWithPrivacy (unit, immatureBalance, m_privacy));
280+ ui->totalLabel ->setText (BitcoinUnits::formatWithPrivacy (unit, balance + stake + unconfirmedBalance + immatureBalance,
281+ m_privacy));
271282
272283 // only show immature (newly mined) balance if it's non-zero, so as not to complicate things
273284 // for the non-mining users
@@ -289,14 +300,45 @@ void OverviewPage::setDifficulty(double difficulty, double net_weight)
289300
290301void OverviewPage::setCoinWeight (double coin_weight)
291302{
292- ui->coinWeightLabel ->setText (QString::number (coin_weight, ' f' , 2 ));
303+ QString text;
304+
305+ if (m_privacy) {
306+ text = QString (" #.##" );
307+ } else {
308+ text = QString::number (coin_weight, ' f' , 2 );
309+ }
310+
311+ ui->coinWeightLabel ->setText (text);
293312}
294313
295314void OverviewPage::setCurrentPollTitle (const QString& title)
296315{
297316 ui->currentPollsTitleLabel ->setText (title);
298317}
299318
319+ void OverviewPage::setPrivacy (bool privacy)
320+ {
321+ m_privacy = privacy;
322+ if (currentBalance != -1 ) {
323+ setBalance (currentBalance, currentStake, currentUnconfirmedBalance, currentImmatureBalance);
324+ }
325+
326+ ui->listTransactions ->setVisible (!m_privacy);
327+ if (researcherModel) researcherModel->setMaskAccrual (m_privacy);
328+
329+ LogPrint (BCLog::LogFlags::QT, " INFO: %s: m_privacy = %u" , __func__, m_privacy);
330+
331+ const QString status_tip = m_privacy ? tr (" Privacy mode activated for the Overview screen. To unmask the values, uncheck "
332+ " Settings->Mask values." ) : " " ;
333+
334+ updateTransactions ();
335+ updatePendingAccrual ();
336+
337+ setStatusTip (status_tip);
338+ QStatusTipEvent event (status_tip);
339+ QApplication::sendEvent (this , &event);
340+ }
341+
300342void OverviewPage::setResearcherModel (ResearcherModel *researcherModel)
301343{
302344 this ->researcherModel = researcherModel;
@@ -324,7 +366,13 @@ void OverviewPage::setWalletModel(WalletModel *model)
324366 filter->setDynamicSortFilter (true );
325367 filter->setSortRole (Qt::EditRole);
326368 filter->setShowInactive (false );
327- filter->setLimit (getNumTransactionsForView ());
369+
370+ int num_transactions_for_view = getNumTransactionsForView ();
371+ filter->setLimit (num_transactions_for_view);
372+
373+ LogPrint (BCLog::LogFlags::QT, " INFO: %s: num_transactions_for_view = %i, getLimit() = %i" ,
374+ __func__, num_transactions_for_view, filter->getLimit ());
375+
328376 filter->sort (TransactionTableModel::Status, Qt::DescendingOrder);
329377 ui->listTransactions ->setModel (filter.get ());
330378 ui->listTransactions ->setModelColumn (TransactionTableModel::ToAddress);
@@ -337,6 +385,12 @@ void OverviewPage::setWalletModel(WalletModel *model)
337385
338386 connect (model->getOptionsModel (), &OptionsModel::LimitTxnDisplayChanged, this , &OverviewPage::updateTransactions);
339387 connect (model, &WalletModel::transactionUpdated, this , &OverviewPage::updateTransactions);
388+
389+ // Set the privacy state for the overview screen from the optionsModel for init.
390+ setPrivacy (model->getOptionsModel ()->getMaskValues ());
391+
392+ // Connect the privacy mode setting to the options dialog.
393+ connect (walletModel->getOptionsModel (), &OptionsModel::MaskValuesChanged, this , & OverviewPage::setPrivacy);
340394 }
341395
342396 // update the display unit, to not use the default ("BTC")
0 commit comments