From 42c52402392ddb30c74dc2d988469de2d680edde Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 28 Mar 2018 14:29:39 -0700 Subject: [PATCH 1/2] Allow editing of disconnected port --- src/ui/preferences/SerialSettings.qml | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/ui/preferences/SerialSettings.qml b/src/ui/preferences/SerialSettings.qml index 8438549..0b9ba0f 100644 --- a/src/ui/preferences/SerialSettings.qml +++ b/src/ui/preferences/SerialSettings.qml @@ -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 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 } } } From a5ddd1e3b43a828e25740f4ce3b2d90805d6c45d Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Thu, 29 Mar 2018 10:54:41 -0700 Subject: [PATCH 2/2] Fix virtual versus override --- src/AutoPilotPlugins/PX4/PowerComponent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.h b/src/AutoPilotPlugins/PX4/PowerComponent.h index 9be937d..6ea7897 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.h +++ b/src/AutoPilotPlugins/PX4/PowerComponent.h @@ -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;