mobile: delay combobox selection for download.

Set index of comboboxes in Download screen when the page
becomes visible instead of when it is created.

The pages is created before QBluetoothDeviceDiscoveryAgent on iOS and desktop,
therefore combobox indexes cannot be set during page creation.

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-06-04 18:37:43 +02:00 committed by Dirk Hohndel
parent 36b9e5e31e
commit 03f30f6281

View file

@ -67,12 +67,11 @@ Kirigami.Page {
}
columns: 2
Controls.Label { text: qsTr(" Vendor name: ") }
property var vendoridx: downloadThread.data().getDetectedVendorIndex()
Controls.ComboBox {
id: comboVendor
Layout.fillWidth: true
model: vendorList
currentIndex: parent.vendoridx
currentIndex: -1
delegate: Controls.ItemDelegate {
width: comboVendor.width
contentItem: Text {
@ -100,10 +99,9 @@ Kirigami.Page {
Controls.Label { text: qsTr(" Dive Computer:") }
Controls.ComboBox {
id: comboProduct
property var productidx: downloadThread.data().getDetectedProductIndex(comboVendor.currentText)
Layout.fillWidth: true
model: null
currentIndex: productidx
currentIndex: -1
delegate: Controls.ItemDelegate {
width: comboProduct.width
contentItem: Text {
@ -305,5 +303,13 @@ Kirigami.Page {
}
}
}
onVisibleChanged: {
if (visible) {
comboVendor.currentIndex = downloadThread.data().getDetectedVendorIndex()
comboProduct.currentIndex = downloadThread.data().getDetectedProductIndex(comboVendor.currentText)
comboDevice.currentIndex = downloadThread.data().getMatchingAddress(comboVendor.currentText, comboProduct.currentText)
}
}
}
}