Desktop/remember DCs: insert the remember connection into dropdown

This still doesn't do the right thing for BT/BLE connections on a Mac, but it
should work on Linux and possibly Mac.

We definitely need to figure out how to get the Mac to successfully connect back
to a BT/BLE device.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-09-24 07:04:21 -07:00 committed by Jan Mulder
parent 02fc78570e
commit ebb3fc8a0c
2 changed files with 13 additions and 1 deletions

View file

@ -121,6 +121,17 @@ void DownloadFromDCWidget::showRememberedDCs()
SETUPDC(4) SETUPDC(4)
} }
int DownloadFromDCWidget::deviceIndex(QString deviceText)
{
int rv = ui.device->findText(deviceText);
if (rv == -1) {
// we need to insert the device text into the model
ui.device->addItem(deviceText);
rv = ui.device->findText(deviceText);
}
return rv;
}
// DC button slots // DC button slots
#define DCBUTTON(num) \ #define DCBUTTON(num) \
void DownloadFromDCWidget::DC##num##Clicked() \ void DownloadFromDCWidget::DC##num##Clicked() \
@ -128,7 +139,7 @@ void DownloadFromDCWidget::DC##num##Clicked() \
ui.vendor->setCurrentIndex(ui.vendor->findText(qPrefDiveComputer::vendor##num())); \ ui.vendor->setCurrentIndex(ui.vendor->findText(qPrefDiveComputer::vendor##num())); \
productModel.setStringList(productList[qPrefDiveComputer::vendor##num()]); \ productModel.setStringList(productList[qPrefDiveComputer::vendor##num()]); \
ui.product->setCurrentIndex(ui.product->findText(qPrefDiveComputer::product##num())); \ ui.product->setCurrentIndex(ui.product->findText(qPrefDiveComputer::product##num())); \
ui.device->setCurrentIndex(ui.device->findText(qPrefDiveComputer::device##num())); \ ui.device->setCurrentIndex(deviceIndex(qPrefDiveComputer::device##num())); \
if (QSysInfo::kernelType() == "darwin") { \ if (QSysInfo::kernelType() == "darwin") { \
/* it makes no sense that this would be needed on macOS but not Linux */ \ /* it makes no sense that this would be needed on macOS but not Linux */ \
QCoreApplication::processEvents(); \ QCoreApplication::processEvents(); \

View file

@ -54,6 +54,7 @@ slots:
void DC2Clicked(); void DC2Clicked();
void DC3Clicked(); void DC3Clicked();
void DC4Clicked(); void DC4Clicked();
int deviceIndex(QString deviceText);
#if defined(BT_SUPPORT) #if defined(BT_SUPPORT)
void enableBluetoothMode(int state); void enableBluetoothMode(int state);