From f5372ca15d9b2f10e92cddbef9c299530eb1e7d3 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 12 Apr 2017 15:03:11 -0700 Subject: [PATCH] Show remove mission from vehicle even if on Video --- src/FlightDisplay/FlightDisplayView.qml | 73 +++++++++++++++++++--- src/FlightDisplay/FlightDisplayViewMap.qml | 57 +---------------- 2 files changed, 67 insertions(+), 63 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 4ba379f36..f3b3c05ae 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -96,6 +96,16 @@ QGCView { onResumeMissionReady: guidedActionsController.confirmAction(guidedActionsController.actionResumeMissionReady) } + GeoFenceController { + id: flyGeoFenceController + Component.onCompleted: start(false /* editMode */) + } + + RallyPointController { + id: flyRallyPointController + Component.onCompleted: start(false /* editMode */) + } + MessageDialog { id: px4JoystickSupport text: qsTr("Joystick support requires MAVLink MANUAL_CONTROL support. ") + @@ -123,6 +133,49 @@ QGCView { } } + // The following code is used to track vehicle states such that we prompt to remove mission from vehicle when mission completes + + property bool vehicleArmed: _activeVehicle ? _activeVehicle.armed : true // true here prevents pop up from showing during shutdown + property bool vehicleWasArmed: false + property bool vehicleInMissionFlightMode: _activeVehicle ? (_activeVehicle.flightMode === _activeVehicle.missionFlightMode) : false + property bool promptForMissionRemove: false + + onVehicleArmedChanged: { + if (vehicleArmed) { + if (!promptForMissionRemove) { + promptForMissionRemove = vehicleInMissionFlightMode + vehicleWasArmed = true + } + } else { + if (promptForMissionRemove && (flyMissionController.containsItems || flyGeoFenceController.containsItems || flyRallyPointController.containsItems)) { + root.showDialog(removeMissionDialogComponent, qsTr("Flight complete"), showDialogDefaultWidth, StandardButton.No | StandardButton.Yes) + } + promptForMissionRemove = false + } + } + + onVehicleInMissionFlightModeChanged: { + if (!promptForMissionRemove && vehicleArmed) { + promptForMissionRemove = true + } + } + + Component { + id: removeMissionDialogComponent + + QGCViewMessage { + message: qsTr("Do you want to remove the mission from the vehicle?") + + function accept() { + flyMissionController.removeAllFromVehicle() + flyGeoFenceController.removeAllFromVehicle() + flyRallyPointController.removeAllFromVehicle() + hideDialog() + + } + } + } + QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true } QGCViewPanel { @@ -157,14 +210,16 @@ QGCView { } ] FlightDisplayViewMap { - id: _flightMap - anchors.fill: parent - missionController: flyMissionController - guidedActionsController: _guidedController - flightWidgets: flightDisplayViewWidgets - rightPanelWidth: ScreenTools.defaultFontPixelHeight * 9 - qgcView: root - scaleState: (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode" + id: _flightMap + anchors.fill: parent + missionController: flyMissionController + geoFenceController: flyGeoFenceController + rallyPointController: flyRallyPointController + guidedActionsController: _guidedController + flightWidgets: flightDisplayViewWidgets + rightPanelWidth: ScreenTools.defaultFontPixelHeight * 9 + qgcView: root + scaleState: (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode" } } @@ -356,7 +411,7 @@ QGCView { buttonVisible: [ _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true, _guidedController.smartShotsAvailable ] buttonEnabled: [ _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable, _anySmartShotAvailable ] - property bool _anyActionAvailable: _guidedController.showEmergenyStop || _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort + property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort property bool _anySmartShotAvailable: _guidedController.showOrbit property var _actionModel: [ { diff --git a/src/FlightDisplay/FlightDisplayViewMap.qml b/src/FlightDisplay/FlightDisplayViewMap.qml index 84f52ab5a..2a6243f10 100644 --- a/src/FlightDisplay/FlightDisplayViewMap.qml +++ b/src/FlightDisplay/FlightDisplayViewMap.qml @@ -33,6 +33,8 @@ FlightMap { property alias scaleState: mapScale.state property var missionController + property var geoFenceController + property var rallyPointController property var guidedActionsController property var flightWidgets property var rightPanelWidth @@ -137,59 +139,6 @@ FlightMap { } } - GeoFenceController { - id: geoFenceController - Component.onCompleted: start(false /* editMode */) - } - - RallyPointController { - id: rallyPointController - Component.onCompleted: start(false /* editMode */) - } - - // The following code is used to track vehicle states such that we prompt to remove mission from vehicle when mission completes - - property bool vehicleArmed: _activeVehicle ? _activeVehicle.armed : false - property bool vehicleWasArmed: false - property bool vehicleInMissionFlightMode: _activeVehicle ? (_activeVehicle.flightMode === _activeVehicle.missionFlightMode) : false - property bool promptForMissionRemove: false - - onVehicleArmedChanged: { - if (vehicleArmed) { - if (!promptForMissionRemove) { - promptForMissionRemove = vehicleInMissionFlightMode - vehicleWasArmed = true - } - } else { - if (promptForMissionRemove && (missionController.containsItems || geoFenceController.containsItems || rallyPointController.containsItems)) { - qgcView.showDialog(removeMissionDialogComponent, qsTr("Flight complete"), showDialogDefaultWidth, StandardButton.No | StandardButton.Yes) - } - promptForMissionRemove = false - } - } - - onVehicleInMissionFlightModeChanged: { - if (!promptForMissionRemove && vehicleArmed) { - promptForMissionRemove = true - } - } - - Component { - id: removeMissionDialogComponent - - QGCViewMessage { - message: qsTr("Do you want to remove the mission from the vehicle?") - - function accept() { - missionController.removeAllFromVehicle() - geoFenceController.removeAllFromVehicle() - rallyPointController.removeAllFromVehicle() - hideDialog() - - } - } - } - ExclusiveGroup { id: _mapTypeButtonsExclusiveGroup } @@ -239,7 +188,7 @@ FlightMap { delegate: MissionItemMapVisual { map: flightMap - onClicked: guidedActionsController.confirmAction(guidedActionsController.actionSetWaypoint, object.sequenceNumber) + onClicked: guidedActionsController.confirmAction(guidedActionsController.actionSetWaypoint, Math.max(object.sequenceNumber, 1)) } } -- 2.22.0