QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FlyViewMissionCompleteDialog.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4import QtQuick.Layouts
5
6import QGroundControl
7import QGroundControl.Controls
8
9/// Dialog which shows up when a flight completes. Prompts the user for things like whether they should remove the plan from the vehicle.
10Item {
11 id: missionCompleteDialogHelper
12 visible: false
13
14 property var missionController
15 property var geoFenceController
16 property var rallyPointController
17
18 // The following code is used to track vehicle states for showing the mission complete dialog
19 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
20 property bool _vehicleArmed: _activeVehicle ? _activeVehicle.armed : true // true here prevents pop up from showing during shutdown
21 property bool _vehicleWasArmed: false
22 property bool _vehicleInMissionFlightMode: _activeVehicle ? (_activeVehicle.flightMode === _activeVehicle.missionFlightMode) : false
23 property bool _vehicleWasInMissionFlightMode: false
24 property bool _showMissionCompleteDialog: _vehicleWasArmed && _vehicleWasInMissionFlightMode &&
25 (missionController.containsItems || geoFenceController.containsItems || rallyPointController.containsItems ||
26 (_activeVehicle ? _activeVehicle.cameraTriggerPoints.count !== 0 : false))
27
28 on_VehicleArmedChanged: {
29 if (_vehicleArmed) {
30 _vehicleWasArmed = true
31 _vehicleWasInMissionFlightMode = _vehicleInMissionFlightMode
32 } else {
33 if (_showMissionCompleteDialog) {
34 missionCompleteDialogFactory.open()
35 }
36 _vehicleWasArmed = false
37 _vehicleWasInMissionFlightMode = false
38 }
39 }
40
41 on_VehicleInMissionFlightModeChanged: {
42 if (_vehicleInMissionFlightMode && _vehicleArmed) {
43 _vehicleWasInMissionFlightMode = true
44 }
45 }
46
47 QGCPopupDialogFactory {
48 id: missionCompleteDialogFactory
49
50 dialogComponent: missionCompleteDialogComponent
51 }
52
53 Component {
54 id: missionCompleteDialogComponent
55
56 QGCPopupDialog {
57 id: missionCompleteDialog
58 title: qsTr("Flight Plan complete")
59 buttons: Dialog.Close
60
61 property var activeVehicleCopy: _activeVehicle
62 onActiveVehicleCopyChanged:
63 if (!activeVehicleCopy) {
64 missionCompleteDialog.close()
65 }
66
67 ColumnLayout {
68 id: column
69 width: 40 * ScreenTools.defaultFontPixelWidth
70 spacing: ScreenTools.defaultFontPixelHeight
71
72 QGCLabel {
73 Layout.fillWidth: true
74 text: qsTr("%1 Images Taken").arg(_activeVehicle.cameraTriggerPoints.count)
75 horizontalAlignment: Text.AlignHCenter
76 visible: _activeVehicle.cameraTriggerPoints.count !== 0
77 }
78
79 QGCButton {
80 Layout.fillWidth: true
81 text: qsTr("Remove plan from vehicle")
82 visible: !_activeVehicle.communicationLost// && !_activeVehicle.apmFirmware // ArduPilot has a bug somewhere with mission clear
83 onClicked: {
84 _planController.removeAllFromVehicle()
85 missionCompleteDialog.close()
86 }
87 }
88
89 QGCButton {
90 Layout.fillWidth: true
91 Layout.alignment: Qt.AlignHCenter
92 text: qsTr("Leave plan on vehicle")
93 onClicked: missionCompleteDialog.close()
94
95 }
96
97 Rectangle {
98 Layout.fillWidth: true
99 color: qgcPal.text
100 height: 1
101 }
102
103 ColumnLayout {
104 Layout.fillWidth: true
105 spacing: ScreenTools.defaultFontPixelHeight
106 visible: !_activeVehicle.communicationLost && globals.guidedControllerFlyView.showResumeMission
107
108 QGCButton {
109 Layout.fillWidth: true
110 Layout.alignment: Qt.AlignHCenter
111 text: qsTr("Resume Mission From Waypoint %1").arg(globals.guidedControllerFlyView._resumeMissionIndex)
112
113 onClicked: {
114 globals.guidedControllerFlyView.executeAction(globals.guidedControllerFlyView.actionResumeMission, null, null)
115 missionCompleteDialog.close()
116 }
117 }
118
119 QGCLabel {
120 Layout.fillWidth: true
121 wrapMode: Text.WordWrap
122 text: qsTr("Resume Mission will rebuild the current mission from the last flown waypoint and upload it to the vehicle for the next flight.")
123 }
124 }
125
126 QGCLabel {
127 Layout.fillWidth: true
128 wrapMode: Text.WordWrap
129 color: qgcPal.warningText
130 text: qsTr("If you are changing batteries for Resume Mission do not disconnect from the vehicle.")
131 visible: globals.guidedControllerFlyView.showResumeMission
132 }
133 }
134 }
135 }
136}