diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-01-27 12:47:40 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-27 12:47:40 -0800 |
commit | 303badd5ceae56185ec8ffee0b8489c5a598babe (patch) | |
tree | 3797a279331f9e717d3298c4d1f5ebe944d21456 /qt-ui/downloadfromdivecomputer.cpp | |
parent | eac2642f8ea8ea8df7062564e69bfa3b789275ba (diff) | |
download | subsurface-303badd5ceae56185ec8ffee0b8489c5a598babe.tar.gz |
Detect errors while downloading from libdivecomputer
Show them in the progress bar and offer to retry.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index daef87437..70ec28a5b 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -87,7 +87,12 @@ void DownloadFromDCWidget::runDialog() void DownloadFromDCWidget::updateProgressBar() { - ui.progressBar->setValue(progress_bar_fraction *100); + if (*progress_bar_text != '\0') { + ui.progressBar->setFormat(progress_bar_text); + } else { + ui.progressBar->setFormat("%p%"); + ui.progressBar->setValue(progress_bar_fraction *100); + } } void DownloadFromDCWidget::updateState(states state) @@ -126,19 +131,30 @@ void DownloadFromDCWidget::updateState(states state) markChildrenAsEnabled(); } - // DOWNLOAD is finally done, close the dialog and go back to the main window + // DOWNLOAD is finally done, but we don't know if there was an error as libdivecomputer doesn't pass + // that information on to us + // so check the progressBar text and if no error was reported, close the dialog and go back to the main window + // otherwise treat this as if the download was cancelled else if (currentState == DOWNLOADING && state == DONE) { timer->stop(); - ui.progressBar->setValue(100); - markChildrenAsEnabled(); - ui.ok->setText(tr("OK")); - accept(); + if (QString(progress_bar_text).contains("error", Qt::CaseInsensitive)) { + updateProgressBar(); + markChildrenAsEnabled(); + progress_bar_text = ""; + ui.ok->setText(tr("Retry")); + } else { + ui.progressBar->setValue(100); + markChildrenAsEnabled(); + ui.ok->setText(tr("OK")); + accept(); + } } // DOWNLOAD is started. else if (state == DOWNLOADING) { timer->start(); ui.progressBar->setValue(0); + updateProgressBar(); ui.progressBar->show(); markChildrenAsDisabled(); } |