diff --git a/src/AutoPilotPlugins/AutoPilotPlugin.cc b/src/AutoPilotPlugins/AutoPilotPlugin.cc index 731e43dd9b4998beb3ec996ae930279d755690d6..6107fd4551bded99871d1979c2ce16527213e38c 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 e612030d697ed89b8d78f357a38d57983280d585..66728f885bfd6b0e0030ef9277828149bf8c11d1 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 fb1c3cc8aad9bb55e2085268af7356331e497bd1..253853b58d50f75a965eba855a21a150dd658194 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 28eb585ed78c92a8556dc145587ae26ce406b037..f452467ab7955e319c2aabb4779ad496bbc65914 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 9bfb18b52ec0184b893b0c3512b66c22a8b8c248..cb4a7dc2ff12ecedb00cb1905f3bc24646a9a83d 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 }