Unverified Commit c4ff7197 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #6275 from DonLakeFlyer/SerialEdit

Serial comm link: Allow editing of disconnected port
parents d2a1bb6f a5ddd1e3
......@@ -25,7 +25,7 @@ public:
PowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Overrides from VehicleComponent
virtual QStringList setupCompleteChangedTriggerList(void) const;
QStringList setupCompleteChangedTriggerList(void) const override;
// Overrides from VehicleComponent
QString name (void) const override;
......
......@@ -59,26 +59,41 @@ Item {
id: commPortCombo
anchors.verticalCenter: parent.verticalCenter
width: _secondColumn
model: QGroundControl.linkManager.serialPortStrings
visible: QGroundControl.linkManager.serialPortStrings.length > 0
onActivated: {
if (index != -1) {
subEditConfig.portName = QGroundControl.linkManager.serialPorts[index]
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]
}
}
}
Component.onCompleted: {
if(subEditConfig != null) {
if(subEditConfig.portDisplayName === "" && QGroundControl.linkManager.serialPorts.length > 0)
var index
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]
var index = commPortCombo.find(subEditConfig.portDisplayName)
}
index = serialPorts.indexOf(subEditConfig.portDisplayName)
if (index === -1) {
console.warn(qsTr("Serial Port not present"), subEditConfig.portName)
} else {
commPortCombo.currentIndex = index
serialPorts.push(subEditConfig.portName)
index = serialPorts.indexOf(subEditConfig.portName)
}
} 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