Commit 42c52402 authored by DonLakeFlyer's avatar DonLakeFlyer

Allow editing of disconnected port

parent 07805f16
...@@ -59,26 +59,41 @@ Item { ...@@ -59,26 +59,41 @@ Item {
id: commPortCombo id: commPortCombo
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: _secondColumn width: _secondColumn
model: QGroundControl.linkManager.serialPortStrings
visible: QGroundControl.linkManager.serialPortStrings.length > 0 visible: QGroundControl.linkManager.serialPortStrings.length > 0
onActivated: { onActivated: {
if (index != -1) { if (index != -1) {
if (index >= QGroundControl.linkManager.serialPortStrings.length) {
// This item was adding at the end, must use added text as name
subEditConfig.portName = commPortCombo.textAt(index)
} else {
subEditConfig.portName = QGroundControl.linkManager.serialPorts[index] subEditConfig.portName = QGroundControl.linkManager.serialPorts[index]
} }
} }
}
Component.onCompleted: { Component.onCompleted: {
if(subEditConfig != null) { var index
if(subEditConfig.portDisplayName === "" && QGroundControl.linkManager.serialPorts.length > 0) var serialPorts = [ ]
for (var i=0; i<QGroundControl.linkManager.serialPortStrings.length; i++) {
serialPorts.push(QGroundControl.linkManager.serialPortStrings[i])
}
if (subEditConfig != null) {
if (subEditConfig.portDisplayName === "" && QGroundControl.linkManager.serialPorts.length > 0) {
subEditConfig.portName = QGroundControl.linkManager.serialPorts[0] subEditConfig.portName = QGroundControl.linkManager.serialPorts[0]
var index = commPortCombo.find(subEditConfig.portDisplayName) }
index = serialPorts.indexOf(subEditConfig.portDisplayName)
if (index === -1) { if (index === -1) {
console.warn(qsTr("Serial Port not present"), subEditConfig.portName) serialPorts.push(subEditConfig.portName)
} else { index = serialPorts.indexOf(subEditConfig.portName)
commPortCombo.currentIndex = index
} }
} else { } else {
commPortCombo.currentIndex = 0 index = 0
} }
commPortCombo.model = serialPorts
commPortCombo.currentIndex = index
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment