Desktop: Disable 'search' button if the vendor does not support it.

Disable the 'search dive computer' ([...]]) button in the 'Import from
dive computer' window if searching is not supported by the currently
selected vendor.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2023-02-27 18:41:46 +13:00 committed by Robert C. Helling
parent b9b47092c1
commit ffc9502535

View file

@ -19,6 +19,11 @@
#include <QTimer> #include <QTimer>
#include <QUndoStack> #include <QUndoStack>
static bool is_vendor_searchable(QString vendor)
{
return vendor == "Uemis" || vendor == "Garmin";
}
DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent) : QDialog(parent, QFlag(0)), DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent) : QDialog(parent, QFlag(0)),
downloading(false), downloading(false),
previousLast(0), previousLast(0),
@ -51,6 +56,7 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent) : QDialog(parent, QF
ui.selectAllButton->setEnabled(false); ui.selectAllButton->setEnabled(false);
ui.unselectAllButton->setEnabled(false); ui.unselectAllButton->setEnabled(false);
ui.vendor->setModel(&vendorModel); ui.vendor->setModel(&vendorModel);
ui.search->setEnabled(is_vendor_searchable(ui.vendor->currentText()));
ui.product->setModel(&productModel); ui.product->setModel(&productModel);
progress_bar_text = ""; progress_bar_text = "";
@ -319,6 +325,7 @@ void DownloadFromDCWidget::on_vendor_currentTextChanged(const QString &vendor)
descriptor = descriptorLookup.value(ui.vendor->currentText().toLower() + ui.product->currentText().toLower()); descriptor = descriptorLookup.value(ui.vendor->currentText().toLower() + ui.product->currentText().toLower());
transport = dc_descriptor_get_transports(descriptor); transport = dc_descriptor_get_transports(descriptor);
fill_device_list(transport); fill_device_list(transport);
ui.search->setEnabled(is_vendor_searchable(vendor));
} }
void DownloadFromDCWidget::on_product_currentTextChanged(const QString &) void DownloadFromDCWidget::on_product_currentTextChanged(const QString &)
@ -342,7 +349,7 @@ void DownloadFromDCWidget::on_device_currentTextChanged(const QString &device)
void DownloadFromDCWidget::on_search_clicked() void DownloadFromDCWidget::on_search_clicked()
{ {
if (ui.vendor->currentText() == "Uemis" || ui.vendor->currentText() == "Garmin") { if (is_vendor_searchable(ui.vendor->currentText())) {
QString dialogTitle = ui.vendor->currentText() == "Uemis" ? QString dialogTitle = ui.vendor->currentText() == "Uemis" ?
tr("Find Uemis dive computer") : tr("Find Garmin dive computer"); tr("Find Uemis dive computer") : tr("Find Garmin dive computer");
QString dirName = QFileDialog::getExistingDirectory(this, QString dirName = QFileDialog::getExistingDirectory(this,