From 559547b7e6459b4af6902e802fc344bf0ccdea0f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 20 Mar 2020 14:00:16 -0700 Subject: mobile/DCdownload: try harder to get the right elements selected The number of possible sequences of events when the user is connecting a USB device is rather surprising. These changes try to ensure that in every case we get USB connection information we do in fact show the correct (or best guess) connection. See #2686 Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/DownloadFromDiveComputer.qml | 10 ++++++++++ mobile-widgets/qml/main.qml | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/DownloadFromDiveComputer.qml b/mobile-widgets/qml/DownloadFromDiveComputer.qml index dfe254143..4fbeb525b 100644 --- a/mobile-widgets/qml/DownloadFromDiveComputer.qml +++ b/mobile-widgets/qml/DownloadFromDiveComputer.qml @@ -157,6 +157,16 @@ Kirigami.Page { verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } + onCountChanged: { + // ensure that pick the first entry once we have any + // entries in the connection list + if (count === 0) + currentIndex = -1 + else if (currentIndex === -1) + currentIndex = 0 + + } + onCurrentTextChanged: { var curVendor var curProduct diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index ea9321ab5..acf24849d 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -820,13 +820,21 @@ if you have network connectivity and want to sync your data to cloud storage."), downloadFromDc.dcImportModel.clearTable() if (vendor !== undefined && product !== undefined && connection !== undefined) { downloadFromDc.setupUSB = true - /* set up the correct values on the download page */ - if (vendor !== -1) + // set up the correct values on the download page + // setting the currentIndex to -1, first, helps to ensure + // that the comboBox does get updated in the UI + if (vendor !== -1) { + downloadFromDc.vendor = -1 downloadFromDc.vendor = vendor - if (product !== -1) + } + if (product !== -1) { + downloadFromDc.product = -1 downloadFromDc.product = product - if (connection !== -1) + } + if (connection !== -1) { + downloadFromDc.connection = -1 downloadFromDc.connection = connection + } } else { downloadFromDc.setupUSB = false } -- cgit v1.2.3-70-g09d2