Browse Source

removed relative progressbar display and moved re-worked network detection code to setNumBlocks()

0.8
Philip Kaufmann 13 years ago
parent
commit
068ed1e838
  1. 27
      src/qt/bitcoingui.cpp

27
src/qt/bitcoingui.cpp

@ -332,12 +332,8 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
setNumConnections(clientModel->getNumConnections()); setNumConnections(clientModel->getNumConnections());
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
// don't display the sync. message, if we are not connected to the network
if (clientModel->getNumConnections() > 0)
{
setNumBlocks(clientModel->getNumBlocks()); setNumBlocks(clientModel->getNumBlocks());
connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int))); connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
}
// Report errors from network/worker thread // Report errors from network/worker thread
connect(clientModel, SIGNAL(error(QString,QString)), this, SLOT(error(QString,QString))); connect(clientModel, SIGNAL(error(QString,QString)), this, SLOT(error(QString,QString)));
@ -455,10 +451,16 @@ void BitcoinGUI::setNumConnections(int count)
void BitcoinGUI::setNumBlocks(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; return;
}
int nTotal = clientModel->getNumBlocksOfPeers(); int nTotal = clientModel->getNumBlocksOfPeers();
int nInitTotal = clientModel->getNumBlocksAtStartup();
int nPercentageLeft = 100 - (count / (nTotal / 100)); int nPercentageLeft = 100 - (count / (nTotal / 100));
QString tooltip; QString tooltip;
@ -467,25 +469,14 @@ void BitcoinGUI::setNumBlocks(int count)
if (clientModel->getStatusBarWarnings() == "") if (clientModel->getStatusBarWarnings() == "")
{ {
progressBarLabel->setVisible(true); progressBarLabel->setVisible(true);
progressBarLabel->setText(tr("Synchronizing with network..."));
progressBar->setVisible(true); progressBar->setVisible(true);
progressBar->setFormat(tr("%v of %m blocks (%p%)")); progressBar->setFormat(tr("%v of %m blocks (%p%)"));
progressBar->setAlignment(Qt::AlignCenter); progressBar->setAlignment(Qt::AlignCenter);
// display absolute bar if the difference between count and nTotal is > 10%
if (nPercentageLeft > 10)
{
progressBarLabel->setText(tr("Synchronizing with network... (abs. display)"));
progressBar->setMaximum(nTotal); progressBar->setMaximum(nTotal);
progressBar->setValue(count); progressBar->setValue(count);
} }
else else
{
progressBarLabel->setText(tr("Synchronizing with network... (rel. display)"));
progressBar->setMaximum(nTotal - nInitTotal);
progressBar->setValue(count - nInitTotal);
}
}
else
{ {
progressBarLabel->setText(clientModel->getStatusBarWarnings()); progressBarLabel->setText(clientModel->getStatusBarWarnings());
progressBarLabel->setVisible(true); progressBarLabel->setVisible(true);

Loading…
Cancel
Save