From 6131875987b2f8f0067424b6983a470b6292e7bf Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Tue, 4 Feb 2020 16:18:25 -0500 Subject: [PATCH] Add option to enforce the use (and passing) the checklist before being allowed to arm. --- src/FlightDisplay/FlightDisplayView.qml | 8 +++++--- src/Settings/App.SettingsGroup.json | 7 +++++++ src/Settings/AppSettings.cc | 1 + src/Settings/AppSettings.h | 1 + src/ui/preferences/GeneralSettings.qml | 16 +++++++++++++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 382bda229..3faa8c846 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -49,6 +49,8 @@ Item { property var _rallyPointController: _planController.rallyPointController property bool _isPipVisible: QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_PIPVisibleKey, true) : false property bool _useChecklist: QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length + property bool _enforceChecklist: _useChecklist && QGroundControl.settingsManager.appSettings.enforceChecklist.rawValue + property bool _canArm: activeVehicle ? (_useChecklist ? (_enforceChecklist ? activeVehicle.checkListState === Vehicle.CheckListPassed : true) : true) : false property real _margins: ScreenTools.defaultFontPixelWidth / 2 property real _pipSize: mainWindow.width * 0.2 property alias _guidedController: guidedActionsController @@ -595,7 +597,7 @@ Item { name: _guidedController.takeoffTitle, iconSource: "/res/takeoff.svg", buttonVisible: _guidedController.showTakeoff || !_guidedController.showLand, - buttonEnabled: _guidedController.showTakeoff, + buttonEnabled: _guidedController.showTakeoff && _canArm, action: _guidedController.actionTakeoff }, { @@ -623,7 +625,7 @@ Item { name: qsTr("Action"), iconSource: "/res/action.svg", buttonVisible: !_guidedController.showPause, - buttonEnabled: _anyActionAvailable, + buttonEnabled: _anyActionAvailable && _canArm, action: -1 } ] @@ -657,7 +659,7 @@ Item { z: _flightVideoPipControl.z + 1 onShowStartMissionChanged: { - if (showStartMission) { + if (showStartMission && _canArm) { confirmAction(actionStartMission) } } diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index 18eae1e6a..945ec5245 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -138,6 +138,13 @@ "type": "bool", "defaultValue": false }, +{ + "name": "enforceChecklist", + "shortDescription": "Preflight checklist must pass before arming", + "longDescription": "If this option is enabled the preflight checklist must pass before arming.", + "type": "bool", + "defaultValue": false +}, { "name": "appFontPointSize", "shortDescription": "Application font size", diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index 278ee95c3..67e199dbb 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -85,6 +85,7 @@ DECLARE_SETTINGSFACT(AppSettings, showLargeCompass) DECLARE_SETTINGSFACT(AppSettings, savePath) DECLARE_SETTINGSFACT(AppSettings, autoLoadMissions) DECLARE_SETTINGSFACT(AppSettings, useChecklist) +DECLARE_SETTINGSFACT(AppSettings, enforceChecklist) DECLARE_SETTINGSFACT(AppSettings, mapboxToken) DECLARE_SETTINGSFACT(AppSettings, esriToken) DECLARE_SETTINGSFACT(AppSettings, defaultFirmwareType) diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index b81d0b495..de4fa9049 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -46,6 +46,7 @@ public: DEFINE_SETTINGFACT(savePath) DEFINE_SETTINGFACT(autoLoadMissions) DEFINE_SETTINGFACT(useChecklist) + DEFINE_SETTINGFACT(enforceChecklist) DEFINE_SETTINGFACT(mapboxToken) DEFINE_SETTINGFACT(esriToken) DEFINE_SETTINGFACT(defaultFirmwareType) diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index e223024bb..7014a7a09 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -475,13 +475,23 @@ Rectangle { spacing: _margins FactCheckBox { - text: qsTr("Use Preflight Checklist") - fact: _useChecklist - visible: _useChecklist.visible && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length + id: useCheckList + text: qsTr("Use Preflight Checklist") + fact: _useChecklist + visible: _useChecklist.visible && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length property Fact _useChecklist: QGroundControl.settingsManager.appSettings.useChecklist } + FactCheckBox { + text: qsTr("Enforce Preflight Checklist") + fact: _enforceChecklist + enabled: QGroundControl.settingsManager.appSettings.useChecklist.value + visible: useCheckList.visible && _enforceChecklist.visible && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length + + property Fact _enforceChecklist: QGroundControl.settingsManager.appSettings.enforceChecklist + } + FactCheckBox { text: qsTr("Keep Map Centered On Vehicle") fact: _keepMapCenteredOnVehicle -- 2.22.0