From 25bee36fcc06f52761f07ec3957c9a8663c6b39e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 4 Jul 2019 13:49:37 +0900 Subject: [PATCH] Desktop: update BT selection when picking remembered dive computer When switching to a BT dive computer, the device selection dialog is opened, when switching away from BT, the device address is set. Fixes #2139 Signed-off-by: Dirk Hohndel --- desktop-widgets/downloadfromdivecomputer.cpp | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index f948097b2..7c6101845 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -131,6 +131,27 @@ int DownloadFromDCWidget::deviceIndex(QString deviceText) } // DC button slots +// we need two versions as one of the helper functions used is only available if +// Bluetooth support is enabled +#ifdef BT_SUPPORT +#define DCBUTTON(num) \ +void DownloadFromDCWidget::DC##num##Clicked() \ +{ \ + ui.vendor->setCurrentIndex(ui.vendor->findText(qPrefDiveComputer::vendor##num())); \ + productModel.setStringList(productList[qPrefDiveComputer::vendor##num()]); \ + ui.product->setCurrentIndex(ui.product->findText(qPrefDiveComputer::product##num())); \ + ui.bluetoothMode->setChecked(isBluetoothAddress(qPrefDiveComputer::device##num())); \ + if (ui.device->currentIndex() == -1) \ + ui.device->setCurrentIndex(deviceIndex(qPrefDiveComputer::device##num())); \ + if (QSysInfo::kernelType() == "darwin") { \ + /* it makes no sense that this would be needed on macOS but not Linux */ \ + QCoreApplication::processEvents(); \ + ui.vendor->update(); \ + ui.product->update(); \ + ui.device->update(); \ + } \ +} +#else #define DCBUTTON(num) \ void DownloadFromDCWidget::DC##num##Clicked() \ { \ @@ -146,6 +167,9 @@ void DownloadFromDCWidget::DC##num##Clicked() \ ui.device->update(); \ } \ } +#endif + + DCBUTTON(1) DCBUTTON(2)