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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-07-04 13:49:37 +09:00 committed by bstoeger
parent eefaae35b3
commit 25bee36fcc

View file

@ -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)