aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/downloadfromdivecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk>2013-08-25 10:01:59 -0300
committerGravatar Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>2013-08-29 19:20:34 -0300
commitab649e21ba07c9f572d61350b9217609f44f7f04 (patch)
tree5df89b10cd925e9e6023dfc8cbea363fabdeb3be /qt-ui/downloadfromdivecomputer.cpp
parentdb44045cfea21510415ef53b27895cc0770312a7 (diff)
downloadsubsurface-ab649e21ba07c9f572d61350b9217609f44f7f04.tar.gz
fix DownloadDialog behavior
The DownloadDialog behavior was broken in a way it allows the user to make changes on the dialog while the download is happening. Also, clicking on "Cancel" breaks/hangs the UI sometimes, as libdivingcomputer doesn't always cancels the download right away. That's a bug that still needs to be fixed. Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index 65e7a16e2..7514c9482 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -65,7 +65,11 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) :
void DownloadFromDCWidget::runDialog()
{
+ // Since the DownloadDialog is only
+ // created once, we need to do put some starting code here
ui->progressBar->hide();
+ markChildrenAsEnabled();
+
exec();
}
@@ -138,7 +142,11 @@ void DownloadFromDCWidget::on_cancel_clicked()
thread->deleteLater();
thread = 0;
}
- close();
+
+ // Confusing, but if the user press cancel during a download
+ // he probably want to cancel the download, not to close the window.
+ if (!downloading)
+ close();
}
void DownloadFromDCWidget::on_ok_clicked()
@@ -146,6 +154,7 @@ void DownloadFromDCWidget::on_ok_clicked()
if (downloading)
return;
+ markChildrenAsDisabled();
ui->progressBar->setValue(0);
ui->progressBar->show();
@@ -156,6 +165,7 @@ void DownloadFromDCWidget::on_ok_clicked()
data.devname = strdup(ui->device->text().toUtf8().data());
data.vendor = strdup(ui->vendor->currentText().toUtf8().data());
data.product = strdup(ui->product->currentText().toUtf8().data());
+
data.descriptor = descriptorLookup[ui->vendor->currentText() + ui->product->currentText()];
data.force_download = ui->forceDownload->isChecked();
data.deviceid = data.diveid = 0;
@@ -177,6 +187,36 @@ bool DownloadFromDCWidget::preferDownloaded()
return ui->preferDownloaded->isChecked();
}
+void DownloadFromDCWidget::reject()
+{
+ // we don't want the download window being able to close
+ // while we're still downloading.
+ if (!downloading)
+ QDialog::reject();
+}
+
+void DownloadFromDCWidget::markChildrenAsDisabled()
+{
+ ui->device->setDisabled(true);
+ ui->vendor->setDisabled(true);
+ ui->product->setDisabled(true);
+ ui->forceDownload->setDisabled(true);
+ ui->preferDownloaded->setDisabled(true);
+ ui->ok->setDisabled(true);
+ ui->search->setDisabled(true);
+}
+
+void DownloadFromDCWidget::markChildrenAsEnabled()
+{
+ ui->device->setDisabled(false);
+ ui->vendor->setDisabled(false);
+ ui->product->setDisabled(false);
+ ui->forceDownload->setDisabled(false);
+ ui->preferDownloaded->setDisabled(false);
+ ui->ok->setDisabled(false);
+ ui->search->setDisabled(false);
+}
+
DownloadThread::DownloadThread(device_data_t* data): data(data)
{
}