Merge pull request #700 from TheBlueMatt/qtalertfix

Fix status bar not displaying Alerts.
This commit is contained in:
Gavin Andresen 2011-12-13 12:56:26 -08:00
commit b12fc3e112
5 changed files with 46 additions and 5 deletions

View File

@ -91,6 +91,8 @@ void UIThreadCall(boost::function0<void> fn)
void MainFrameRepaint() void MainFrameRepaint()
{ {
if(guiref)
QMetaObject::invokeMethod(guiref, "refreshStatusBar", Qt::QueuedConnection);
} }
void InitMessage(const std::string &message) void InitMessage(const std::string &message)

View File

@ -2,6 +2,7 @@
* Qt4 bitcoin GUI. * Qt4 bitcoin GUI.
* *
* W.J. van der Laan 2011 * W.J. van der Laan 2011
* The Bitcoin Developers 2011
*/ */
#include "bitcoingui.h" #include "bitcoingui.h"
#include "transactiontablemodel.h" #include "transactiontablemodel.h"
@ -416,16 +417,32 @@ void BitcoinGUI::setNumBlocks(int count)
QString tooltip; QString tooltip;
if(count < total) if(count < total)
{
if (clientModel->getStatusBarWarnings() == "")
{ {
progressBarLabel->setVisible(true); progressBarLabel->setVisible(true);
progressBarLabel->setText(tr("Synchronizing with network..."));
progressBar->setVisible(true); progressBar->setVisible(true);
progressBar->setMaximum(total - initTotal); progressBar->setMaximum(total - initTotal);
progressBar->setValue(count - 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); tooltip = tr("Downloaded %1 of %2 blocks of transaction history.").arg(count).arg(total);
} }
else else
{ {
if (clientModel->getStatusBarWarnings() == "")
progressBarLabel->setVisible(false); progressBarLabel->setVisible(false);
else
{
progressBarLabel->setText(clientModel->getStatusBarWarnings());
progressBarLabel->setVisible(true);
}
progressBar->setVisible(false); progressBar->setVisible(false);
tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count); tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
} }
@ -474,6 +491,19 @@ void BitcoinGUI::setNumBlocks(int count)
progressBar->setToolTip(tooltip); 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) void BitcoinGUI::error(const QString &title, const QString &message)
{ {
// Report errors from network/worker thread // Report errors from network/worker thread

View File

@ -108,6 +108,8 @@ public slots:
@see WalletModel::EncryptionStatus @see WalletModel::EncryptionStatus
*/ */
void setEncryptionStatus(int status); 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. */ /** Notify the user of an error in the network or transaction handling code. */
void error(const QString &title, const QString &message); void error(const QString &title, const QString &message);

View File

@ -72,6 +72,11 @@ int ClientModel::getNumBlocksOfPeers() const
return GetNumBlocksOfPeers(); return GetNumBlocksOfPeers();
} }
QString ClientModel::getStatusBarWarnings() const
{
return QString::fromStdString(GetWarnings("statusbar"));
}
OptionsModel *ClientModel::getOptionsModel() OptionsModel *ClientModel::getOptionsModel()
{ {
return optionsModel; return optionsModel;

View File

@ -33,6 +33,8 @@ public:
bool inInitialBlockDownload() const; bool inInitialBlockDownload() const;
//! Return conservative estimate of total number of blocks, or 0 if unknown //! Return conservative estimate of total number of blocks, or 0 if unknown
int getNumBlocksOfPeers() const; int getNumBlocksOfPeers() const;
//! Return warnings to be displayed in status bar
QString getStatusBarWarnings() const;
QString formatFullVersion() const; QString formatFullVersion() const;