mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-03 15:43:09 +00:00
Detect errors while downloading from libdivecomputer
Show them in the progress bar and offer to retry. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
eac2642f8e
commit
303badd5ce
1 changed files with 22 additions and 6 deletions
|
@ -87,7 +87,12 @@ void DownloadFromDCWidget::runDialog()
|
||||||
|
|
||||||
void DownloadFromDCWidget::updateProgressBar()
|
void DownloadFromDCWidget::updateProgressBar()
|
||||||
{
|
{
|
||||||
|
if (*progress_bar_text != '\0') {
|
||||||
|
ui.progressBar->setFormat(progress_bar_text);
|
||||||
|
} else {
|
||||||
|
ui.progressBar->setFormat("%p%");
|
||||||
ui.progressBar->setValue(progress_bar_fraction *100);
|
ui.progressBar->setValue(progress_bar_fraction *100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadFromDCWidget::updateState(states state)
|
void DownloadFromDCWidget::updateState(states state)
|
||||||
|
@ -126,19 +131,30 @@ void DownloadFromDCWidget::updateState(states state)
|
||||||
markChildrenAsEnabled();
|
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) {
|
else if (currentState == DOWNLOADING && state == DONE) {
|
||||||
timer->stop();
|
timer->stop();
|
||||||
|
if (QString(progress_bar_text).contains("error", Qt::CaseInsensitive)) {
|
||||||
|
updateProgressBar();
|
||||||
|
markChildrenAsEnabled();
|
||||||
|
progress_bar_text = "";
|
||||||
|
ui.ok->setText(tr("Retry"));
|
||||||
|
} else {
|
||||||
ui.progressBar->setValue(100);
|
ui.progressBar->setValue(100);
|
||||||
markChildrenAsEnabled();
|
markChildrenAsEnabled();
|
||||||
ui.ok->setText(tr("OK"));
|
ui.ok->setText(tr("OK"));
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DOWNLOAD is started.
|
// DOWNLOAD is started.
|
||||||
else if (state == DOWNLOADING) {
|
else if (state == DOWNLOADING) {
|
||||||
timer->start();
|
timer->start();
|
||||||
ui.progressBar->setValue(0);
|
ui.progressBar->setValue(0);
|
||||||
|
updateProgressBar();
|
||||||
ui.progressBar->show();
|
ui.progressBar->show();
|
||||||
markChildrenAsDisabled();
|
markChildrenAsDisabled();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue