changed progressbar text to "~n blocks remaining"
[novacoin.git] / src / qt / bitcoingui.cpp
index 7bce128..319a2f9 100644 (file)
@@ -376,7 +376,7 @@ void BitcoinGUI::createTrayIcon()
     trayIcon = new QSystemTrayIcon(this);
     trayIconMenu = new QMenu(this);
     trayIcon->setContextMenu(trayIconMenu);
-    trayIcon->setToolTip("Bitcoin client");
+    trayIcon->setToolTip(tr("Bitcoin client"));
     trayIcon->setIcon(QIcon(":/icons/toolbar"));
     connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
             this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
@@ -451,20 +451,33 @@ void BitcoinGUI::setNumConnections(int count)
 
 void BitcoinGUI::setNumBlocks(int count)
 {
-    if(!clientModel)
+    // don't show / hide progressBar and it's label if we have no connection(s) to the network
+    if (!clientModel || clientModel->getNumConnections() == 0)
+    {
+        progressBarLabel->setVisible(false);
+        progressBar->setVisible(false);
+
         return;
-    int total = clientModel->getNumBlocksOfPeers();
+    }
+
+    int nTotal = clientModel->getNumBlocksOfPeers();
     QString tooltip;
 
-    if(count < total)
+    if(count < nTotal)
     {
+        int nCurMax = nTotal - count;
+        int nOnePercentCurMax = nCurMax / 100;
+        int nPercentageDone = (count / (nTotal / 100));
+
         if (clientModel->getStatusBarWarnings() == "")
         {
             progressBarLabel->setVisible(true);
             progressBarLabel->setText(tr("Synchronizing with network..."));
             progressBar->setVisible(true);
-            progressBar->setMaximum(total);
-            progressBar->setValue(count);
+            progressBar->setFormat(tr("~%m blocks remaining"));
+            progressBar->setAlignment(Qt::AlignCenter);
+            progressBar->setMaximum(nCurMax);
+            progressBar->setValue(nOnePercentCurMax * nPercentageDone);
         }
         else
         {
@@ -472,7 +485,7 @@ void BitcoinGUI::setNumBlocks(int count)
             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 (%3% done).").arg(count).arg(nTotal).arg(nPercentageDone);
     }
     else
     {