diff options
author | Jocke <j.bygdell@gmail.com> | 2018-09-30 17:43:59 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-01 06:32:41 -0700 |
commit | c504c080972dda1e7e9a3c3ec092a39db7027da5 (patch) | |
tree | fdda80c4eea2ad1ce23aa8b4b99baf56616e0a7b /mobile-widgets | |
parent | 9b199602c601f37869c64486bdc4713f9814e49f (diff) | |
download | subsurface-c504c080972dda1e7e9a3c3ec092a39db7027da5.tar.gz |
Mobile download from DC: improve selection logic
Improve the logic when auto selecting a DC for download.
Some USB cables only supply vendor information but we can select the correct
model if we have downloaded from it before.
For BT/BLE our discovery process adds the device name to the address, so we need to keep that in mind when we try to match against what we seen before.
When we have a positive match for a DC we have seen before we deactivate the
corresponding button of our saved DCs.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qml/DownloadFromDiveComputer.qml | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/mobile-widgets/qml/DownloadFromDiveComputer.qml b/mobile-widgets/qml/DownloadFromDiveComputer.qml index a963d82c6..3d6649226 100644 --- a/mobile-widgets/qml/DownloadFromDiveComputer.qml +++ b/mobile-widgets/qml/DownloadFromDiveComputer.qml @@ -179,6 +179,20 @@ Kirigami.Page { else manager.DC_bluetoothMode = false manager.DC_devName = currentText + dc1.enabled = dc2.enabled = dc3.enabled = dc4.enabled = true + for (var i = 1; i < 5; i++) { + if (comboProduct.currentIndex === -1 && currentText === "FTDI"){ + if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.device" + i).toUpperCase() === currentText){ + rememberedDCsGrid.setDC(eval("PrefDiveComputer.vendor" + i), eval("PrefDiveComputer.product" + i), ("PrefDiveComputer.device" + i)) + } + }else if (comboProduct.currentIndex !== -1 && currentText === "FTDI") { + if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.product" + i) === comboProduct.currentText && eval("PrefDiveComputer.device" + i).toUpperCase() === currentText){ + eval("dc"+ i + ".enabled = false") + } + }else if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.product" + i) === comboProduct.currentText && eval("PrefDiveComputer.product" + i) +" " + eval("PrefDiveComputer.device" + i).toUpperCase() === currentText){ + eval("dc"+ i + ".enabled = false") + } + } } } } @@ -380,9 +394,12 @@ Kirigami.Page { onVisibleChanged: { comboVendor.currentIndex = comboProduct.currentIndex = comboConnection.currentIndex = -1 - if (visible && PrefDiveComputer.vendor !== "" ) { - rememberedDCsGrid.setDC(PrefDiveComputer.vendor1, PrefDiveComputer.product1, PrefDiveComputer.device1) - dc1.enabled = false + dc1.enabled = dc2.enabled = dc3.enabled = dc4.enabled = true + if (visible) { + comboVendor.currentIndex = manager.getDetectedVendorIndex() + comboProduct.currentIndex = manager.getDetectedProductIndex(comboVendor.currentText) + comboConnection.currentIndex = manager.getMatchingAddress(comboVendor.currentText, comboProduct.currentText) + } } } |