From c504c080972dda1e7e9a3c3ec092a39db7027da5 Mon Sep 17 00:00:00 2001 From: Jocke Date: Sun, 30 Sep 2018 17:43:59 +0200 Subject: 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 --- mobile-widgets/qml/DownloadFromDiveComputer.qml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'mobile-widgets') 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) + } } } -- cgit v1.2.3-70-g09d2