mobile/DC-download: select reasonable connection after rescanning

This seems to make more sense than to not select anything (which was the
previous behavior).
If the same connection is still available, select it again. Otherwise
pick the top connection (which is the right thing to do if the user has
just plugged in a USB device and refreshes the list -- that device will
show up as top entry).

Based on a suggestion by Christof Arnosti <charno@charno.ch>

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-03-16 09:42:46 -07:00
parent 2abfd16a10
commit ccd024f0ee

View file

@ -366,7 +366,14 @@ Kirigami.Page {
text: qsTr("Rescan")
enabled: manager.btEnabled
onClicked: {
// refresh both USB and BT/BLE and make sure a reasonable entry is selected
var current = comboConnection.currentText
manager.rescanConnections()
// check if the same entry is still available; if not pick the first entry
var idx = comboConnection.find(current)
if (idx === -1)
idx = 0
comboConnection.currentIndex = idx
}
}