QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PlanInfoEditor.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.FactControls
8
9Rectangle {
10 id: _root
11
12 required property var planMasterController
13 required property var missionController
14 required property var editorMap
15
16 property var _controllerVehicle: planMasterController.controllerVehicle
17 property var _visualItems: missionController.visualItems
18 property bool _noMissionItemsAdded: _visualItems ? _visualItems.count <= 1 : true
19 property var _settingsItem: _visualItems && _visualItems.count > 0 ? _visualItems.get(0) : null
20 property bool _multipleFirmware: !QGroundControl.singleFirmwareSupport
21 property bool _multipleVehicleTypes: !QGroundControl.singleVehicleSupport
22 property bool _allowFWVehicleTypeSelection: _noMissionItemsAdded && !globals.activeVehicle
23 property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
24 property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 16
25
26 width: parent ? parent.width : 0
27 height: mainColumn.height + ScreenTools.defaultFontPixelHeight
28 color: qgcPal.windowShadeDark
29
30 QGCPalette { id: qgcPal; colorGroupEnabled: _root.enabled }
31
32 ColumnLayout {
33 id: mainColumn
34 anchors.left: parent.left
35 anchors.right: parent.right
36 anchors.verticalCenter: parent.verticalCenter
37 anchors.margins: ScreenTools.defaultFontPixelWidth
38 spacing: ScreenTools.defaultFontPixelHeight * 0.25
39
40 ColumnLayout {
41 Layout.fillWidth: true
42 spacing: 0
43
44 QGCLabel {
45 text: qsTr("Plan File")
46 }
47
48 QGCTextField {
49 id: planNameField
50 placeholderText: qsTr("Untitled")
51 Layout.fillWidth: true
52
53 Component.onCompleted: text = _root.planMasterController.currentPlanFileName
54
55 Connections {
56 target: _root.planMasterController
57 function onCurrentPlanFileNameChanged() {
58 if (!planNameField.activeFocus) {
59 planNameField.text = _root.planMasterController.currentPlanFileName
60 }
61 }
62 }
63
64 onEditingFinished: _root.planMasterController.currentPlanFileName = text
65 }
66 }
67
68 // ── Vehicle Info ──
69 SectionHeader {
70 id: vehicleInfoSectionHeader
71 Layout.fillWidth: true
72 text: qsTr("Vehicle Info")
73 visible: !_root._waypointsOnlyMode && (_root._multipleFirmware || _root._multipleVehicleTypes)
74 }
75
76 RowLayout {
77 Layout.fillWidth: true
78 spacing: ScreenTools.defaultFontPixelWidth
79 visible: vehicleInfoSectionHeader.visible && vehicleInfoSectionHeader.checked
80
81 FactComboBox {
82 objectName: "planInfo_firmwareCombo"
83 fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareClass
84 indexModel: false
85 Layout.fillWidth: true
86 visible: _root._multipleFirmware && _root._allowFWVehicleTypeSelection
87 }
88 QGCLabel {
89 objectName: "planInfo_firmwareLabel"
90 text: _root._controllerVehicle ? _root._controllerVehicle.firmwareTypeString : ""
91 Layout.fillWidth: true
92 visible: _root._multipleFirmware && !_root._allowFWVehicleTypeSelection
93 }
94
95 FactComboBox {
96 objectName: "planInfo_vehicleTypeCombo"
97 fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleClass
98 indexModel: false
99 Layout.fillWidth: true
100 visible: _root._multipleVehicleTypes && _root._allowFWVehicleTypeSelection
101 }
102 QGCLabel {
103 objectName: "planInfo_vehicleTypeLabel"
104 text: _root._controllerVehicle ? _root._controllerVehicle.vehicleTypeString : ""
105 Layout.fillWidth: true
106 visible: _root._multipleVehicleTypes && !_root._allowFWVehicleTypeSelection
107 }
108 }
109
110 // ── Expected Home Position ──
111 SectionHeader {
112 id: plannedHomePositionSection
113 Layout.fillWidth: true
114 text: qsTr("Expected Home Position")
115 }
116
117 // Prompt to click map to set/move home position
118 ColumnLayout {
119 Layout.fillWidth: true
120 Layout.topMargin: ScreenTools.defaultFontPixelWidth / 2
121 spacing: ScreenTools.defaultFontPixelWidth / 2
122 visible: plannedHomePositionSection.checked && _root.planMasterController.showCreateFromTemplate
123
124 Image {
125 source: "qrc:///qmlimages/MapHome.svg"
126 Layout.alignment: Qt.AlignHCenter
127 Layout.preferredWidth: ScreenTools.defaultFontPixelHeight * 2
128 Layout.preferredHeight: Layout.preferredWidth
129 fillMode: Image.PreserveAspectFit
130 }
131
132 QGCLabel {
133 Layout.fillWidth: true
134 wrapMode: Text.WordWrap
135 horizontalAlignment: Text.AlignHCenter
136 text: qsTr("Click in map to set position")
137 visible: !_root.missionController.homePositionSet
138 }
139
140 QGCLabel {
141 Layout.fillWidth: true
142 wrapMode: Text.WordWrap
143 horizontalAlignment: Text.AlignHCenter
144 text: qsTr("Drag to move home position. Click to set new position.")
145 visible: _root.missionController.homePositionSet
146 }
147 }
148
149 // Normal home position controls (shown only when home is set)
150 GridLayout {
151 Layout.fillWidth: true
152 columnSpacing: ScreenTools.defaultFontPixelWidth
153 columns: 2
154 visible: plannedHomePositionSection.checked && _root.missionController.homePositionSet
155
156 QGCLabel {
157 text: qsTr("Altitude (AMSL)")
158 font.pointSize: ScreenTools.smallFontPointSize
159 }
160 FactTextField {
161 fact: _root._settingsItem ? _root._settingsItem.plannedHomePositionAltitude : null
162 Layout.fillWidth: true
163 font.pointSize: ScreenTools.smallFontPointSize
164 visible: _root._settingsItem && _root._settingsItem.terrainQueryFailed
165 }
166 QGCLabel {
167 text: _root._settingsItem ? _root._settingsItem.plannedHomePositionAltitude.valueString + " " + _root._settingsItem.plannedHomePositionAltitude.units : ""
168 Layout.fillWidth: true
169 font.pointSize: ScreenTools.smallFontPointSize
170 visible: !_root._settingsItem || !_root._settingsItem.terrainQueryFailed
171 }
172 }
173
174 QGCLabel {
175 Layout.fillWidth: true
176 wrapMode: Text.WordWrap
177 font.pointSize: ScreenTools.smallFontPointSize
178 text: qsTr("Actual position/alt set by vehicle at flight time.")
179 horizontalAlignment: Text.AlignHCenter
180 visible: plannedHomePositionSection.checked && _root.missionController.homePositionSet
181 }
182
183 // ── Plan Templates ──
184 SectionHeader {
185 id: planTemplateSectionHeader
186 objectName: "planInfo_templatesSection"
187 Layout.fillWidth: true
188 text: qsTr("Plan Templates")
189 visible: _root.planMasterController.showCreateFromTemplate
190 }
191
192 ColumnLayout {
193 objectName: "planInfo_templatesColumn"
194 Layout.fillWidth: true
195 spacing: ScreenTools.defaultFontPixelHeight / 2
196 visible: planTemplateSectionHeader.visible && planTemplateSectionHeader.checked
197 enabled: _root.missionController.homePositionSet
198 opacity: enabled ? 1.0 : 0.5
199
200 Repeater {
201 model: _root.planMasterController.planCreators
202
203 QGCButton {
204 objectName: "planCreator_" + object.name
205 Layout.fillWidth: true
206 text: object.name
207 onClicked: {
208 if (object.blankPlan) {
209 _root.planMasterController.userSelectedManualCreation = true
210 } else {
211 object.createPlan(_root.editorMap.center)
212 }
213 }
214 }
215 }
216 }
217 }
218}