From 0c384ff02e946234275aeb8b37e1837d6b5e79db Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Thu, 4 Jan 2018 12:03:51 -0800 Subject: [PATCH] Fix AutoPilotPlugin::setupCompleteChanged signalling --- src/AutoPilotPlugins/AutoPilotPlugin.cc | 11 +++++++++++ src/AutoPilotPlugins/AutoPilotPlugin.h | 2 +- src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h | 2 ++ src/VehicleSetup/VehicleComponent.h | 2 +- src/VehicleSetup/VehicleSummary.qml | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/AutoPilotPlugins/AutoPilotPlugin.cc b/src/AutoPilotPlugins/AutoPilotPlugin.cc index 731e43d..6107fd4 100644 --- a/src/AutoPilotPlugins/AutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/AutoPilotPlugin.cc @@ -61,6 +61,17 @@ bool AutoPilotPlugin::setupComplete(void) void AutoPilotPlugin::parametersReadyPreChecks(void) { _recalcSetupComplete(); + + // Connect signals in order to keep setupComplete up to date + foreach(const QVariant componentVariant, vehicleComponents()) { + VehicleComponent* component = qobject_cast(qvariant_cast(componentVariant)); + if (component) { + connect(component, &VehicleComponent::setupCompleteChanged, this, &AutoPilotPlugin::_recalcSetupComplete); + } else { + qWarning() << "AutoPilotPlugin::_recalcSetupComplete Incorrectly typed VehicleComponent"; + } + } + if (!_setupComplete) { qgcApp()->showMessage(tr("One or more vehicle components require setup prior to flight.")); diff --git a/src/AutoPilotPlugins/AutoPilotPlugin.h b/src/AutoPilotPlugins/AutoPilotPlugin.h index e612030..66728f8 100644 --- a/src/AutoPilotPlugins/AutoPilotPlugin.h +++ b/src/AutoPilotPlugins/AutoPilotPlugin.h @@ -66,7 +66,7 @@ protected: FirmwarePlugin* _firmwarePlugin; bool _setupComplete; -private: +private slots: void _recalcSetupComplete(void); }; diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h index fb1c3cc..253853b 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h @@ -44,6 +44,7 @@ public: const QVariantList& vehicleComponents(void) override; void parametersReadyPreChecks(void) override; QString prerequisiteSetup(VehicleComponent* component) const override; + protected: bool _incorrectParameterVersion; ///< true: parameter version incorrect, setup not allowed PX4AirframeLoader* _airframeFacts; @@ -58,6 +59,7 @@ protected: MotorComponent* _motorComponent; PX4TuningComponent* _tuningComponent; SyslinkComponent* _syslinkComponent; + private: QVariantList _components; }; diff --git a/src/VehicleSetup/VehicleComponent.h b/src/VehicleSetup/VehicleComponent.h index 28eb585..f452467 100644 --- a/src/VehicleSetup/VehicleComponent.h +++ b/src/VehicleSetup/VehicleComponent.h @@ -56,7 +56,7 @@ public: virtual void addSummaryQmlComponent(QQmlContext* context, QQuickItem* parent); /// @brief Returns an list of parameter names for which a change should cause the setupCompleteChanged - /// signal to be emitted. Last element is signalled by NULL. + /// signal to be emitted. virtual QStringList setupCompleteChangedTriggerList(void) const = 0; /// Should be called after the component is created (but not in constructor) to setup the diff --git a/src/VehicleSetup/VehicleSummary.qml b/src/VehicleSetup/VehicleSummary.qml index 9bfb18b..cb4a7dc 100644 --- a/src/VehicleSetup/VehicleSummary.qml +++ b/src/VehicleSetup/VehicleSummary.qml @@ -86,6 +86,7 @@ Rectangle { text: setupComplete ? qsTr("Below you will find a summary of the settings for your vehicle. To the left are the setup menus for each component.") : qsTr("WARNING: Your vehicle requires setup prior to flight. Please resolve the items marked in red using the menu on the left.") + property bool setupComplete: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.autopilot.setupComplete : false }