From: Matt Corallo Date: Tue, 13 Dec 2011 19:00:21 +0000 (-0500) Subject: Fix status bar not displaying Alerts. X-Git-Tag: v0.4.0-unstable~226^2^2 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=7ca47cece7854a4efb4a8dcb68b93edbde1a76fb Fix status bar not displaying Alerts. --- diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 4aaad6b..dd326a6 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -91,6 +91,8 @@ void UIThreadCall(boost::function0 fn) void MainFrameRepaint() { + if(guiref) + QMetaObject::invokeMethod(guiref, "refreshStatusBar", Qt::QueuedConnection); } void InitMessage(const std::string &message) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index bdc9821..60c7528 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -2,6 +2,7 @@ * Qt4 bitcoin GUI. * * W.J. van der Laan 2011 + * The Bitcoin Developers 2011 */ #include "bitcoingui.h" #include "transactiontablemodel.h" @@ -417,15 +418,31 @@ void BitcoinGUI::setNumBlocks(int count) if(count < total) { - progressBarLabel->setVisible(true); - progressBar->setVisible(true); - progressBar->setMaximum(total - initTotal); - progressBar->setValue(count - initTotal); + if (clientModel->getStatusBarWarnings() == "") + { + progressBarLabel->setVisible(true); + progressBarLabel->setText(tr("Synchronizing with network...")); + progressBar->setVisible(true); + progressBar->setMaximum(total - initTotal); + progressBar->setValue(count - initTotal); + } + else + { + progressBarLabel->setText(clientModel->getStatusBarWarnings()); + progressBarLabel->setVisible(true); + progressBar->setVisible(false); + } tooltip = tr("Downloaded %1 of %2 blocks of transaction history.").arg(count).arg(total); } else { - progressBarLabel->setVisible(false); + if (clientModel->getStatusBarWarnings() == "") + progressBarLabel->setVisible(false); + else + { + progressBarLabel->setText(clientModel->getStatusBarWarnings()); + progressBarLabel->setVisible(true); + } progressBar->setVisible(false); tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count); } @@ -474,6 +491,19 @@ void BitcoinGUI::setNumBlocks(int count) progressBar->setToolTip(tooltip); } +void BitcoinGUI::refreshStatusBar() +{ + /* Might display multiple times in the case of multiple alerts + static QString prevStatusBar; + QString newStatusBar = clientModel->getStatusBarWarnings(); + if (prevStatusBar != newStatusBar) + { + prevStatusBar = newStatusBar; + error(tr("Network Alert"), newStatusBar); + }*/ + setNumBlocks(clientModel->getNumBlocks()); +} + void BitcoinGUI::error(const QString &title, const QString &message) { // Report errors from network/worker thread diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index d01ab59..ecb356d 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -108,6 +108,8 @@ public slots: @see WalletModel::EncryptionStatus */ void setEncryptionStatus(int status); + /** Set the status bar text if there are any warnings (removes sync progress bar if applicable) */ + void refreshStatusBar(); /** Notify the user of an error in the network or transaction handling code. */ void error(const QString &title, const QString &message); diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 2ed3ce5..5a0b4aa 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -72,6 +72,11 @@ int ClientModel::getNumBlocksOfPeers() const return GetNumBlocksOfPeers(); } +QString ClientModel::getStatusBarWarnings() const +{ + return QString::fromStdString(GetWarnings("statusbar")); +} + OptionsModel *ClientModel::getOptionsModel() { return optionsModel; diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index b4054b5..5a12c4f 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -33,6 +33,8 @@ public: bool inInitialBlockDownload() const; //! Return conservative estimate of total number of blocks, or 0 if unknown int getNumBlocksOfPeers() const; + //! Return warnings to be displayed in status bar + QString getStatusBarWarnings() const; QString formatFullVersion() const;