Reset device field in DownloadFromDCWidget according to dive computer

Fixes minor interface inconsistency: The device field in the
download-from-dive-computer widget is disabled when selecting
a non-serial-transport dive computer. In contrast, post-download
the field was reset to enabled for all dive computers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2017-11-01 08:01:23 +01:00 committed by Dirk Hohndel
parent 31e11bc4e8
commit d23bd46a1b
2 changed files with 19 additions and 13 deletions

View file

@ -258,18 +258,7 @@ void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString &vendor)
void DownloadFromDCWidget::on_product_currentIndexChanged(const QString &product)
{
// Set up the DC descriptor
dc_descriptor_t *descriptor = NULL;
descriptor = descriptorLookup[ui.vendor->currentText() + product];
// call dc_descriptor_get_transport to see if the dc_transport_t is DC_TRANSPORT_SERIAL
if (dc_descriptor_get_transport(descriptor) == DC_TRANSPORT_SERIAL) {
// if the dc_transport_t is DC_TRANSPORT_SERIAL, then enable the device node box.
ui.device->setEnabled(true);
} else {
// otherwise disable the device node box
ui.device->setEnabled(false);
}
updateDeviceEnabled();
}
void DownloadFromDCWidget::on_search_clicked()
@ -489,6 +478,22 @@ void DownloadFromDCWidget::on_ok_clicked()
accept();
}
void DownloadFromDCWidget::updateDeviceEnabled()
{
// Set up the DC descriptor
dc_descriptor_t *descriptor = NULL;
descriptor = descriptorLookup[ui.vendor->currentText() + ui.product->currentText()];
// call dc_descriptor_get_transport to see if the dc_transport_t is DC_TRANSPORT_SERIAL
if (dc_descriptor_get_transport(descriptor) == DC_TRANSPORT_SERIAL) {
// if the dc_transport_t is DC_TRANSPORT_SERIAL, then enable the device node box.
ui.device->setEnabled(true);
} else {
// otherwise disable the device node box
ui.device->setEnabled(false);
}
}
void DownloadFromDCWidget::markChildrenAsDisabled()
{
ui.device->setEnabled(false);
@ -511,7 +516,7 @@ void DownloadFromDCWidget::markChildrenAsDisabled()
void DownloadFromDCWidget::markChildrenAsEnabled()
{
ui.device->setEnabled(true);
updateDeviceEnabled();
ui.vendor->setEnabled(true);
ui.product->setEnabled(true);
ui.forceDownload->setEnabled(true);

View file

@ -58,6 +58,7 @@ slots:
private:
void markChildrenAsDisabled();
void markChildrenAsEnabled();
void updateDeviceEnabled();
Ui::DownloadFromDiveComputer ui;
DownloadThread thread;