On initial block chain download, show a progress bar
[novacoin.git] / src / qt / bitcoingui.cpp
index 96afa41..2dfcd40 100644 (file)
@@ -36,6 +36,7 @@
 #include <QSortFilterProxyModel>
 #include <QClipboard>
 #include <QMessageBox>
+#include <QProgressBar>
 
 #include <QDebug>
 
@@ -124,10 +125,19 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
     labelTransactions->setMinimumWidth(130);
     labelTransactions->setToolTip(tr("Number of transactions in your wallet"));
 
+    // Progress bar for blocks download
+    progressBarLabel = new QLabel(tr("Downloading initial data..."));
+    progressBarLabel->setVisible(false);
+    progressBar = new QProgressBar();
+    progressBar->setToolTip(tr("Initial block chain download in progress"));
+    progressBar->setVisible(false);
+
+    statusBar()->addWidget(progressBarLabel);
+    statusBar()->addWidget(progressBar);
     statusBar()->addPermanentWidget(labelConnections);
     statusBar()->addPermanentWidget(labelBlocks);
     statusBar()->addPermanentWidget(labelTransactions);
-     
+
     // Action bindings
     connect(button_new, SIGNAL(clicked()), this, SLOT(newAddressClicked()));
     connect(button_clipboard, SIGNAL(clicked()), this, SLOT(copyClipboardClicked()));
@@ -145,7 +155,7 @@ void BitcoinGUI::createActions()
     addressbook->setToolTip(tr("Edit the list of stored addresses and labels"));
     about = new QAction(QIcon(":/icons/bitcoin"), tr("&About"), this);
     about->setToolTip(tr("Show information about Bitcoin"));
-    receivingAddresses = new QAction(QIcon(":/icons/receiving-addresses"), tr("Your &Receiving Addresses..."), this);
+    receivingAddresses = new QAction(QIcon(":/icons/receiving_addresses"), tr("Your &Receiving Addresses..."), this);
     receivingAddresses->setToolTip(tr("Show the list of receiving addresses and edit their labels"));
     options = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
     options->setToolTip(tr("Modify configuration options for bitcoin"));
@@ -348,11 +358,11 @@ void BitcoinGUI::setNumConnections(int count)
     QString icon;
     switch(count)
     {
-    case 0: icon = ":/icons/connect0"; break;
-    case 1: icon = ":/icons/connect1"; break;
-    case 2: icon = ":/icons/connect2"; break;
-    case 3: icon = ":/icons/connect3"; break;
-    default: icon = ":/icons/connect4"; break;
+    case 0: icon = ":/icons/connect_0"; break;
+    case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
+    case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
+    case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
+    default: icon = ":/icons/connect_4"; break;
     }
     labelConnections->setTextFormat(Qt::RichText);
     labelConnections->setText("<img src=\""+icon+"\"> " + QLocale::system().toString(count)+" "+tr("connection(s)", "", count));
@@ -360,6 +370,20 @@ void BitcoinGUI::setNumConnections(int count)
 
 void BitcoinGUI::setNumBlocks(int count)
 {
+    int total = model->getTotalBlocksEstimate();
+    if(count < total)
+    {
+        progressBarLabel->setVisible(true);
+        progressBar->setVisible(true);
+        progressBar->setMaximum(total);
+        progressBar->setValue(count);
+    }
+    else
+    {
+        progressBarLabel->setVisible(false);
+        progressBar->setVisible(false);
+    }
+
     labelBlocks->setText(QLocale::system().toString(count)+" "+tr("block(s)", "", count));
 }
 
@@ -429,7 +453,7 @@ void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
 
 void BitcoinGUI::transactionDetails(const QModelIndex& idx)
 {
-    /* A transaction is doubleclicked */
+    // A transaction is doubleclicked
     TransactionDescDialog dlg(idx);
     dlg.exec();
 }
@@ -441,9 +465,10 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int
                     .data(Qt::EditRole).toULongLong();
     qint64 debit = ttm->index(start, TransactionTableModel::Debit, parent)
                     .data(Qt::EditRole).toULongLong();
-    if((credit+debit)>0)
+    if((credit+debit)>0 && !model->inInitialBlockDownload())
     {
-        /* On incoming transaction, make an info balloon */
+        // On incoming transaction, make an info balloon
+        // Unless the initial block download is in progress, to prevent balloon-spam
         QString date = ttm->index(start, TransactionTableModel::Date, parent)
                         .data().toString();
         QString description = ttm->index(start, TransactionTableModel::Description, parent)