From 4dcc9210a91541a3060e1f8da212db5cacecb870 Mon Sep 17 00:00:00 2001 From: jme <32236882+notrege@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:05:08 +0000 Subject: [PATCH] Avoid unnecessary bluetooth device address scanning. When switching from a non-bluetooth computer to a bluetooh computer an unnecessary bluetooth scan may be forced. This patch will avoid the scan if the bluetooth device address is known. Signed-off-by: jme <32236882+notrege@users.noreply.github.com> --- desktop-widgets/downloadfromdivecomputer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index c1fc34684..122fa2056 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -150,6 +150,7 @@ int DownloadFromDCWidget::deviceIndex(QString deviceText) void DownloadFromDCWidget::DC##num##Clicked() \ { \ ui.vendor->setCurrentIndex(ui.vendor->findText(qPrefDiveComputer::vendor##num())); \ + ui.device->setCurrentText(qPrefDiveComputer::device##num()); \ productModel.setStringList(productList[qPrefDiveComputer::vendor##num()]); \ ui.product->setCurrentIndex(ui.product->findText(qPrefDiveComputer::product##num())); \ bool isBluetoothDevice = isBluetoothAddress(qPrefDiveComputer::device##num()); \ @@ -634,10 +635,13 @@ void DownloadFromDCWidget::enableBluetoothMode(int state) { ui.chooseBluetoothDevice->setEnabled(state == Qt::Checked); - if (state == Qt::Checked) - selectRemoteBluetoothDevice(); - else - ui.device->setCurrentIndex(-1); + if (state == Qt::Checked) { + if (ui.device->currentText().isEmpty()) { + selectRemoteBluetoothDevice(); + } else { + ui.device->setCurrentIndex(-1); + } + } } #endif