aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorCozz Lovan <cozzlovan@yahoo.com>2014-05-23 18:04:09 +0200
committerCozz Lovan <cozzlovan@yahoo.com>2014-06-03 15:21:47 +0200
commit06a91d9698762fe56fca3bd33484bddc9f020405 (patch)
tree5d494bb3f766e17f0abf1ee94b6c904cdf41b179 /src/qt
parent4c097f9669a28420da74b159a4d61e509da80d33 (diff)
VerifyDB progress
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/bitcoingui.cpp27
-rw-r--r--src/qt/bitcoingui.h5
-rw-r--r--src/qt/clientmodel.cpp10
-rw-r--r--src/qt/clientmodel.h3
-rw-r--r--src/qt/splashscreen.cpp2
5 files changed, 47 insertions, 0 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 68ae8b4668..3469f990ac 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -40,6 +40,7 @@
#include <QMessageBox>
#include <QMimeData>
#include <QProgressBar>
+#include <QProgressDialog>
#include <QSettings>
#include <QStackedWidget>
#include <QStatusBar>
@@ -409,6 +410,9 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
// Receive and report messages from client model
connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
+ // Show progress dialog
+ connect(clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
+
rpcConsole->setClientModel(clientModel);
#ifdef ENABLE_WALLET
if(walletFrame)
@@ -949,6 +953,29 @@ void BitcoinGUI::detectShutdown()
}
}
+void BitcoinGUI::showProgress(const QString &title, int nProgress)
+{
+ if (nProgress == 0)
+ {
+ progressDialog = new QProgressDialog(title, "", 0, 100);
+ progressDialog->setWindowModality(Qt::ApplicationModal);
+ progressDialog->setMinimumDuration(0);
+ progressDialog->setCancelButton(0);
+ progressDialog->setAutoClose(false);
+ progressDialog->setValue(0);
+ }
+ else if (nProgress == 100)
+ {
+ if (progressDialog)
+ {
+ progressDialog->close();
+ progressDialog->deleteLater();
+ }
+ }
+ else if (progressDialog)
+ progressDialog->setValue(nProgress);
+}
+
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
{
bool modal = (style & CClientUIInterface::MODAL);
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index b4675b95ac..275fa35f39 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -26,6 +26,7 @@ QT_BEGIN_NAMESPACE
class QAction;
class QLabel;
class QProgressBar;
+class QProgressDialog;
QT_END_NAMESPACE
/**
@@ -73,6 +74,7 @@ private:
QLabel *labelBlocksIcon;
QLabel *progressBarLabel;
QProgressBar *progressBar;
+ QProgressDialog *progressDialog;
QMenuBar *appMenuBar;
QAction *overviewAction;
@@ -191,6 +193,9 @@ private slots:
/** called by a timer to check if fRequestShutdown has been set **/
void detectShutdown();
+
+ /** Show progress dialog e.g. for verifychain */
+ void showProgress(const QString &title, int nProgress);
};
#endif // BITCOINGUI_H
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index ce773e0f82..656c8bd113 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -206,6 +206,14 @@ QString ClientModel::formatClientStartupTime() const
}
// Handlers for core signals
+static void ShowProgress(ClientModel *clientmodel, const std::string &title, int nProgress)
+{
+ // emits signal "showProgress"
+ QMetaObject::invokeMethod(clientmodel, "showProgress", Qt::QueuedConnection,
+ Q_ARG(QString, QString::fromStdString(title)),
+ Q_ARG(int, nProgress));
+}
+
static void NotifyBlocksChanged(ClientModel *clientmodel)
{
// This notification is too frequent. Don't trigger a signal.
@@ -230,6 +238,7 @@ static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, Ch
void ClientModel::subscribeToCoreSignals()
{
// Connect signals to client
+ uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
uiInterface.NotifyBlocksChanged.connect(boost::bind(NotifyBlocksChanged, this));
uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1));
uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2));
@@ -238,6 +247,7 @@ void ClientModel::subscribeToCoreSignals()
void ClientModel::unsubscribeFromCoreSignals()
{
// Disconnect signals from client
+ uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
uiInterface.NotifyBlocksChanged.disconnect(boost::bind(NotifyBlocksChanged, this));
uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1));
uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2));
diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h
index c18d30178b..9c9a35b654 100644
--- a/src/qt/clientmodel.h
+++ b/src/qt/clientmodel.h
@@ -95,6 +95,9 @@ signals:
//! Fired when a message should be reported to the user
void message(const QString &title, const QString &message, unsigned int style);
+ // Show progress dialog e.g. for verifychain
+ void showProgress(const QString &title, int nProgress);
+
public slots:
void updateTimer();
void updateNumConnections(int numConnections);
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index 7c79b0efd0..1162e2d87f 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -129,6 +129,7 @@ void SplashScreen::subscribeToCoreSignals()
{
// Connect signals to client
uiInterface.InitMessage.connect(boost::bind(InitMessage, this, _1));
+ uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
#ifdef ENABLE_WALLET
uiInterface.LoadWallet.connect(boost::bind(ConnectWallet, this, _1));
#endif
@@ -138,6 +139,7 @@ void SplashScreen::unsubscribeFromCoreSignals()
{
// Disconnect signals from client
uiInterface.InitMessage.disconnect(boost::bind(InitMessage, this, _1));
+ uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
#ifdef ENABLE_WALLET
if(pwalletMain)
pwalletMain->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));