From 4e8d599d858eeb8f192ff41585c3b8a21926c53a Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Wed, 19 Feb 2020 00:32:29 -0700 Subject: [PATCH] Fixed interactions between PreFlightCheckList and the FlightView --- src/FlightDisplay/FlightDisplayView.qml | 41 +++++++++++++++++-- src/FlightDisplay/GuidedActionsController.qml | 10 +++-- src/FlightDisplay/PreFlightCheckList.qml | 20 +++++---- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 3faa8c846..c62ceece4 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -50,7 +50,7 @@ Item { 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 bool _checklistComplete: activeVehicle && (activeVehicle.checkListState === Vehicle.CheckListPassed) property real _margins: ScreenTools.defaultFontPixelWidth / 2 property real _pipSize: mainWindow.width * 0.2 property alias _guidedController: guidedActionsController @@ -70,6 +70,26 @@ Item { readonly property string _mainIsMapKey: "MainFlyWindowIsMap" readonly property string _PIPVisibleKey: "IsPIPVisible" + onVisibleChanged: { + if (activeVehicle && !_checklistComplete && _enforceChecklist) { + checklistPopupTimer.restart() + } + } + + Timer { + id: checklistPopupTimer + interval: 1000 + repeat: false + onTriggered: { + if (visible && !_checklistComplete) { + checklistDropPanel.open() + } + else { + checklistDropPanel.close() + } + } + } + function setStates() { QGroundControl.saveBoolGlobalSetting(_mainIsMapKey, mainIsMap) if(mainIsMap) { @@ -597,7 +617,7 @@ Item { name: _guidedController.takeoffTitle, iconSource: "/res/takeoff.svg", buttonVisible: _guidedController.showTakeoff || !_guidedController.showLand, - buttonEnabled: _guidedController.showTakeoff && _canArm, + buttonEnabled: _guidedController.showTakeoff, action: _guidedController.actionTakeoff }, { @@ -625,7 +645,7 @@ Item { name: qsTr("Action"), iconSource: "/res/action.svg", buttonVisible: !_guidedController.showPause, - buttonEnabled: _anyActionAvailable && _canArm, + buttonEnabled: _anyActionAvailable, action: -1 } ] @@ -659,7 +679,7 @@ Item { z: _flightVideoPipControl.z + 1 onShowStartMissionChanged: { - if (showStartMission && _canArm) { + if (showStartMission) { confirmAction(actionStartMission) } } @@ -778,10 +798,23 @@ Item { color: Qt.rgba(0,0,0,0) clip: true } + Loader { id: checkList anchors.centerIn: parent } + + property alias checkListItem: checkList.item + + Connections { + target: checkList.item + onAllChecksPassedChanged: { + if (target.allChecksPassed) + { + checklistPopupTimer.restart() + } + } + } } } diff --git a/src/FlightDisplay/GuidedActionsController.qml b/src/FlightDisplay/GuidedActionsController.qml index 0f9dda66c..b3027d360 100644 --- a/src/FlightDisplay/GuidedActionsController.qml +++ b/src/FlightDisplay/GuidedActionsController.qml @@ -96,13 +96,17 @@ Item { readonly property int actionVtolTransitionToMRFlight: 21 readonly property int actionROI: 22 + 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 bool showEmergenyStop: _guidedActionsEnabled && !_hideEmergenyStop && _vehicleArmed && _vehicleFlying - property bool showArm: _guidedActionsEnabled && !_vehicleArmed + property bool showArm: _guidedActionsEnabled && !_vehicleArmed && _canArm property bool showDisarm: _guidedActionsEnabled && _vehicleArmed && !_vehicleFlying property bool showRTL: _guidedActionsEnabled && _vehicleArmed && activeVehicle.guidedModeSupported && _vehicleFlying && !_vehicleInRTLMode - property bool showTakeoff: _guidedActionsEnabled && activeVehicle.takeoffVehicleSupported && !_vehicleFlying + property bool showTakeoff: _guidedActionsEnabled && activeVehicle.takeoffVehicleSupported && !_vehicleFlying && _canArm property bool showLand: _guidedActionsEnabled && activeVehicle.guidedModeSupported && _vehicleArmed && !activeVehicle.fixedWing && !_vehicleInLandMode - property bool showStartMission: _guidedActionsEnabled && _missionAvailable && !_missionActive && !_vehicleFlying + property bool showStartMission: _guidedActionsEnabled && _missionAvailable && !_missionActive && !_vehicleFlying && _canArm property bool showContinueMission: _guidedActionsEnabled && _missionAvailable && !_missionActive && _vehicleArmed && _vehicleFlying && (_currentMissionIndex < _missionItemCount - 1) property bool showPause: _guidedActionsEnabled && _vehicleArmed && activeVehicle.pauseVehicleSupported && _vehicleFlying && !_vehiclePaused && !_fixedWingOnApproach property bool showChangeAlt: _guidedActionsEnabled && _vehicleFlying && activeVehicle.guidedModeSupported && _vehicleArmed && !_missionActive diff --git a/src/FlightDisplay/PreFlightCheckList.qml b/src/FlightDisplay/PreFlightCheckList.qml index 5acebb0b9..af5c2b7d2 100644 --- a/src/FlightDisplay/PreFlightCheckList.qml +++ b/src/FlightDisplay/PreFlightCheckList.qml @@ -30,7 +30,15 @@ Rectangle { source: "/checklists/DefaultChecklist.qml" } - property bool _passed: false + property bool allChecksPassed: false + + onAllChecksPassedChanged: { + if (allChecksPassed) { + activeVehicle.checkListState = Vehicle.CheckListPassed + } else { + activeVehicle.checkListState = Vehicle.CheckListFailed + } + } function _handleGroupPassedChanged(index, passed) { if (passed) { @@ -53,7 +61,7 @@ Rectangle { break } } - _passed = allPassed; + allChecksPassed = allPassed; } //-- Pick a checklist model that matches the current airframe type (if any) @@ -85,12 +93,6 @@ Rectangle { if(activeVehicle) { if(visible) { _updateModel() - } else { - if(modelContainer.item.model.isPassed()) { - activeVehicle.checkListState = Vehicle.CheckListPassed - } else { - activeVehicle.checkListState = Vehicle.CheckListFailed - } } } } @@ -139,7 +141,7 @@ Rectangle { height: 1.75 * ScreenTools.defaultFontPixelHeight QGCLabel { - text: qsTr("Pre-Flight Checklist %1").arg(_passed ? qsTr("(passed)") : "") + text: qsTr("Pre-Flight Checklist %1").arg(allChecksPassed ? qsTr("(passed)") : "") anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter font.pointSize: ScreenTools.mediumFontPointSize -- 2.22.0