From a01e56a67d9d34fd1f69d42c3afc3a081efde356 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 11 Aug 2015 15:52:28 +0300 Subject: [PATCH] show masternode sync status in GUI --- src/qt/bitcoingui.cpp | 49 ++++++++++++++++++++++++++++++++++-------- src/qt/clientmodel.cpp | 9 +++++++- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 4640e1f15..ee698a469 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -197,10 +197,10 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) : // Progress bar and label for blocks download progressBarLabel = new QLabel(); - progressBarLabel->setVisible(false); + progressBarLabel->setVisible(true); progressBar = new GUIUtil::ProgressBar(); progressBar->setAlignment(Qt::AlignCenter); - progressBar->setVisible(false); + progressBar->setVisible(true); // Override style sheet for progress bar for styles that have a segmented progress bar, // as they make the text unreadable (workaround for issue #1071) @@ -755,18 +755,49 @@ void BitcoinGUI::setNumBlocks(int count) tooltip = tr("Processed %n blocks of transaction history.", "", count); // Set icon state: spinning if catching up, tick otherwise - if(secs < 25*60) // 90*60 for bitcoin but we are 4x times faster +// if(secs < 25*60) // 90*60 for bitcoin but we are 4x times faster + if(masternodeSync.IsBlockchainSynced()) { tooltip = tr("Up to date") + QString(".
") + tooltip; - labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); + static int prevAttempt = -1; + static int prevAssets = -1; + static int progress = 0; + if(masternodeSync.RequestedMasternodeAttempt != prevAttempt || masternodeSync.RequestedMasternodeAssets != prevAssets) + { + labelBlocksIcon->setPixmap(QIcon(QString( + ":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0'))) + .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); + spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES; + prevAttempt = masternodeSync.RequestedMasternodeAttempt + 1; + prevAssets = masternodeSync.RequestedMasternodeAssets; + if(prevAttempt <= 4) progress = prevAttempt + (prevAssets - 1) * 4; + progressBar->setValue(progress); + } + switch (masternodeSync.RequestedMasternodeAssets) { + case MASTERNODE_SYNC_SPORKS: + progressBar->setMaximum(4 * 4); + progressBarLabel->setText(tr("Synchronizing sporks...")); + break; + case MASTERNODE_SYNC_LIST: + progressBarLabel->setText(tr("Synchronizing masternodes...")); + break; + case MASTERNODE_SYNC_MNW: + progressBarLabel->setText(tr("Synchronizing masternode winners...")); + break; + case MASTERNODE_SYNC_BUDGET: + progressBarLabel->setText(tr("Synchronizing budgets...")); + break; + case MASTERNODE_SYNC_FINISHED: #ifdef ENABLE_WALLET - if(walletFrame) - walletFrame->showOutOfSyncWarning(false); + if(walletFrame) + walletFrame->showOutOfSyncWarning(false); #endif // ENABLE_WALLET - - progressBarLabel->setVisible(false); - progressBar->setVisible(false); + progressBarLabel->setVisible(false); + progressBar->setVisible(false); + labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); + break; + } } else { diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index e335f2953..299d147cb 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -16,6 +16,7 @@ #include "net.h" #include "ui_interface.h" #include "masternodeman.h" +#include "masternode-sync.h" #include "util.h" #include @@ -123,13 +124,19 @@ void ClientModel::updateTimer() // Periodically check and update with a timer. int newNumBlocks = getNumBlocks(); + static int prevAttempt = -1; + static int prevAssets = -1; + // check for changed number of blocks we have, number of blocks peers claim to have, reindexing state and importing state if (cachedNumBlocks != newNumBlocks || - cachedReindexing != fReindex || cachedImporting != fImporting) + cachedReindexing != fReindex || cachedImporting != fImporting || + masternodeSync.RequestedMasternodeAttempt != prevAttempt || masternodeSync.RequestedMasternodeAssets != prevAssets) { cachedNumBlocks = newNumBlocks; cachedReindexing = fReindex; cachedImporting = fImporting; + prevAttempt = masternodeSync.RequestedMasternodeAttempt; + prevAssets = masternodeSync.RequestedMasternodeAssets; emit numBlocksChanged(newNumBlocks); }