Desktop UI: reset cloud storage progress 'percentage'

The fake percentage needs to at least start at 0 for every cloud interaction.
Yes, the file global variable is ugly. So sue me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-06-18 01:46:49 -07:00
parent 2b01ab7d50
commit 6afe6baa14

View file

@ -66,16 +66,17 @@
QProgressDialog *progressDialog = NULL; QProgressDialog *progressDialog = NULL;
bool progressDialogCanceled = false; bool progressDialogCanceled = false;
static int progressCounter = 0;
extern "C" int updateProgress(const char *text) extern "C" int updateProgress(const char *text)
{ {
static int progress = 0;
if (verbose) if (verbose)
qDebug() << "git storage:" << text; qDebug() << "git storage:" << text;
if (progressDialog) { if (progressDialog) {
progressDialog->setLabelText(text); progressDialog->setLabelText(text);
progressDialog->setValue(++progress); progressDialog->setValue(++progressCounter);
if (progress == 100) if (progressCounter == 100)
progress = 0; // yes this is silly, but we really don't know how long it will take progressCounter = 0; // yes this is silly, but we really don't know how long it will take
} }
qApp->processEvents(); qApp->processEvents();
return progressDialogCanceled; return progressDialogCanceled;
@ -2018,6 +2019,7 @@ void MainWindow::showProgressBar()
progressDialog->setWindowModality(Qt::WindowModal); progressDialog->setWindowModality(Qt::WindowModal);
progressDialog->setMinimumDuration(0); progressDialog->setMinimumDuration(0);
progressDialogCanceled = false; progressDialogCanceled = false;
progressCounter = 0;
connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelCloudStorageOperation())); connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelCloudStorageOperation()));
} }