Skip to content

Commit 1adcd47

Browse files
committed
Mission item editor changes
1 parent c3decca commit 1adcd47

File tree

6 files changed

+189
-183
lines changed

6 files changed

+189
-183
lines changed

src/MissionManager/MissionController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class MissionController : public PlanElementController
183183

184184
/// Sets a new current mission item (PlanView).
185185
/// @param sequenceNumber - index for new item, -1 to clear current item
186+
/// @param force - true: reset internals even if specified item is already selected
186187
Q_INVOKABLE void setCurrentPlanViewSeqNum(int sequenceNumber, bool force);
187188

188189
enum SendToVehiclePreCheckState {

src/MissionManager/MissionSettingsItem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class MissionSettingsItem : public ComplexMissionItem
7272
bool isStandaloneCoordinate (void) const final { return false; }
7373
bool specifiesCoordinate (void) const final;
7474
bool specifiesAltitudeOnly (void) const final { return false; }
75-
QString commandDescription (void) const final { return tr("Mission Start"); }
75+
QString commandDescription (void) const final { return tr("Initial Mission Settings"); }
7676
QString commandName (void) const final { return tr("Mission Start"); }
7777
QString abbreviation (void) const final;
7878
QGeoCoordinate coordinate (void) const final { return _plannedHomePositionCoordinate; } // Includes altitude

src/QmlControls/MissionItemEditor.qml

Lines changed: 116 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@ import QtQml
55
import QtQuick.Layouts
66

77
import QGroundControl
8-
9-
108
import QGroundControl.Controls
119
import QGroundControl.FactControls
1210

13-
14-
1511
/// Mission item edit control
1612
Rectangle {
1713
id: _root
18-
height: editorLoader.y + editorLoader.height + _innerMargin
19-
color: qgcPal.missionItemEditor
14+
height: mainLayout.height
15+
color: "transparent"
2016
radius: _radius
2117
border.width: _readyForSave ? 0 : 2
2218
border.color: qgcPal.warningText
@@ -26,7 +22,6 @@ Rectangle {
2622
property var missionItem ///< MissionItem associated with this editor
2723
property bool readOnly: false ///< true: read only view, false: full editing view
2824

29-
signal clicked
3025
signal remove
3126
signal selectNextNotReadyItem
3227

@@ -42,140 +37,124 @@ Rectangle {
4237
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
4338
readonly property real _innerMargin: 2
4439
readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2
45-
readonly property real _hamburgerSize: commandPicker.height * 0.75
46-
readonly property real _trashSize: commandPicker.height * 0.75
40+
readonly property real _hamburgerSize: ScreenTools.defaultFontPixelHeight
41+
readonly property real _trashSize: ScreenTools.defaultFontPixelHeight
4742
readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
4843

4944
QGCPalette {
5045
id: qgcPal
5146
colorGroupEnabled: enabled
5247
}
5348

54-
FocusScope {
55-
id: currentItemScope
56-
anchors.fill: parent
57-
58-
MouseArea {
59-
anchors.fill: parent
60-
onClicked: {
61-
if (mainWindow.allowViewSwitch()) {
62-
currentItemScope.focus = true
63-
_root.clicked()
64-
}
65-
}
66-
}
67-
}
68-
69-
Component {
70-
id: editPositionDialog
71-
72-
EditPositionDialog {
73-
coordinate: missionItem.isSurveyItem ? missionItem.centerCoordinate : missionItem.coordinate
74-
onCoordinateChanged: missionItem.isSurveyItem ? missionItem.centerCoordinate = coordinate : missionItem.coordinate = coordinate
75-
}
76-
}
77-
78-
Row {
79-
id: topRowLayout
49+
Column {
50+
id: mainLayout
8051
anchors.margins: _margin
8152
anchors.left: parent.left
82-
anchors.top: parent.top
83-
spacing: _margin
53+
width: parent.width - (_margin * 2)
54+
spacing: ScreenTools.defaultFontPixelHeight / 2
8455

85-
Rectangle {
86-
id: notReadyForSaveIndicator
87-
anchors.verticalCenter: parent.verticalCenter
88-
width: _hamburgerSize
89-
height: width
90-
border.width: 1
91-
border.color: qgcPal.warningText
92-
color: "white"
93-
radius: width / 2
94-
visible: !_readyForSave
56+
Loader {
57+
id: editorLoader
58+
source: missionItem.editorQml
59+
asynchronous: true
9560

96-
QGCLabel {
97-
id: readyForSaveLabel
98-
anchors.centerIn: parent
99-
//: Indicator in Plan view to show mission item is not ready for save/send
100-
text: qsTr("?")
101-
color: qgcPal.warningText
102-
font.pointSize: ScreenTools.smallFontPointSize
103-
}
61+
property var masterController: _masterController
62+
property real availableWidth: parent.width
63+
property var editorRoot: _root
10464
}
10565

106-
QGCColoredImage {
107-
id: deleteButton
108-
anchors.verticalCenter: parent.verticalCenter
109-
height: _hamburgerSize
110-
width: height
111-
sourceSize.height: height
112-
fillMode: Image.PreserveAspectFit
113-
mipmap: true
114-
smooth: true
115-
color: qgcPal.text
116-
visible: missionItem.sequenceNumber !== 0
117-
source: "/res/TrashDelete.svg"
118-
119-
QGCMouseArea {
120-
fillItem: parent
121-
onClicked: remove()
122-
}
66+
Rectangle {
67+
id: separator
68+
width: parent.width
69+
height: 1
70+
color: "transparent"
12371
}
12472

125-
Item {
126-
id: commandPicker
127-
anchors.verticalCenter: parent.verticalCenter
128-
height: ScreenTools.implicitComboBoxHeight
129-
width: innerLayout.width
130-
visible: !commandLabel.visible
131-
132-
RowLayout {
133-
id: innerLayout
134-
anchors.verticalCenter: parent.verticalCenter
135-
spacing: _padding
136-
137-
property real _padding: ScreenTools.comboBoxPadding
138-
139-
QGCLabel { text: missionItem.commandName }
140-
141-
QGCColoredImage {
142-
height: ScreenTools.defaultFontPixelWidth
143-
width: height
144-
fillMode: Image.PreserveAspectFit
145-
smooth: true
146-
antialiasing: true
147-
color: qgcPal.text
148-
source: "/qmlimages/arrow-down.png"
73+
RowLayout {
74+
id: bottomRowLayout
75+
width: parent.width
76+
spacing: ScreenTools.defaultFontPixelWidth
77+
78+
Rectangle {
79+
id: notReadyForSaveIndicator
80+
Layout.preferredWidth: visible ? _hamburgerSize : 0
81+
Layout.preferredHeight: _hamburgerSize
82+
border.width: 1
83+
border.color: qgcPal.warningText
84+
color: "white"
85+
radius: width / 2
86+
visible: !_readyForSave
87+
88+
QGCLabel {
89+
id: readyForSaveLabel
90+
anchors.centerIn: parent
91+
//: Indicator in Plan view to show mission item is not ready for save/send
92+
text: qsTr("?")
93+
color: qgcPal.warningText
94+
font.pointSize: ScreenTools.smallFontPointSize
14995
}
15096
}
15197

152-
QGCMouseArea {
153-
fillItem: parent
154-
onClicked: commandDialog.createObject(mainWindow).open()
98+
QGCColoredImage {
99+
id: deleteButton
100+
Layout.preferredWidth: visible ? _hamburgerSize : 0
101+
Layout.preferredHeight: _hamburgerSize
102+
Layout.fillHeight: true
103+
source: "/res/TrashDelete.svg"
104+
sourceSize.height: _hamburgerSize
105+
fillMode: Image.PreserveAspectFit
106+
mipmap: true
107+
smooth: true
108+
color: qgcPal.text
109+
visible: missionItem.sequenceNumber !== 0
110+
111+
QGCMouseArea {
112+
fillItem: parent
113+
onClicked: remove()
114+
}
155115
}
156116

157-
Component {
158-
id: commandDialog
117+
QGCLabel {
118+
Layout.fillWidth: true
119+
horizontalAlignment: Text.AlignHCenter
120+
verticalAlignment: Text.AlignVCenter
121+
text: missionItem.commandDescription
122+
wrapMode: Text.WordWrap
123+
font.pointSize: ScreenTools.smallFontPointSize
124+
}
159125

160-
MissionCommandDialog {
161-
vehicle: masterController.controllerVehicle
162-
missionItem: _root.missionItem
163-
map: _root.map
164-
// FIXME: Disabling fly through commands doesn't work since you may need to change from an RTL to something else
165-
flyThroughCommandsAllowed: true //_missionController.flyThroughCommandsAllowed
126+
QGCColoredImage {
127+
id: hamburger
128+
Layout.alignment: Qt.AlignRight
129+
Layout.preferredWidth: visible ? _hamburgerSize : 0
130+
Layout.preferredHeight: _hamburgerSize
131+
sourceSize.height: _hamburgerSize
132+
source: "qrc:/qmlimages/Hamburger.svg"
133+
color: qgcPal.text
134+
visible: missionItem.sequenceNumber !== 0
135+
136+
QGCMouseArea {
137+
fillItem: hamburger
138+
139+
onClicked: (position) => {
140+
currentItemScope.focus = true
141+
position = Qt.point(position.x, position.y)
142+
// For some strange reason using mainWindow in mapToItem doesn't work, so we use globals.parent instead which also gets us mainWindow
143+
position = mapToItem(globals.parent, position)
144+
var dropPanel = hamburgerMenuDropPanelComponent.createObject(mainWindow, { clickRect: Qt.rect(position.x, position.y, 0, 0) })
145+
dropPanel.open()
146+
}
166147
}
167148
}
168149
}
150+
}
151+
152+
Component {
153+
id: editPositionDialog
169154

170-
QGCLabel {
171-
id: commandLabel
172-
anchors.verticalCenter: parent.verticalCenter
173-
width: commandPicker.width
174-
height: commandPicker.height
175-
visible: !missionItem.isCurrentItem || !missionItem.isSimpleItem || _waypointsOnlyMode || missionItem.isTakeoffItem
176-
verticalAlignment: Text.AlignVCenter
177-
text: missionItem.commandName
178-
color: _outerTextColor
155+
EditPositionDialog {
156+
coordinate: missionItem.isSurveyItem ? missionItem.centerCoordinate : missionItem.coordinate
157+
onCoordinateChanged: missionItem.isSurveyItem ? missionItem.centerCoordinate = coordinate : missionItem.coordinate = coordinate
179158
}
180159
}
181160

@@ -222,6 +201,27 @@ Rectangle {
222201
}
223202
}
224203

204+
QGCButton {
205+
Layout.fillWidth: true
206+
text: qsTr("Change command...")
207+
onClicked: {
208+
commandDialog.createObject(mainWindow).open()
209+
hamburgerMenuDropPanel.close()
210+
}
211+
212+
Component {
213+
id: commandDialog
214+
215+
MissionCommandDialog {
216+
vehicle: masterController.controllerVehicle
217+
missionItem: _root.missionItem
218+
map: _root.map
219+
// FIXME: Disabling fly through commands doesn't work since you may need to change from an RTL to something else
220+
flyThroughCommandsAllowed: true //_missionController.flyThroughCommandsAllowed
221+
}
222+
}
223+
}
224+
225225
Rectangle {
226226
Layout.fillWidth: true
227227
Layout.preferredHeight: 1
@@ -260,43 +260,4 @@ Rectangle {
260260
}
261261
}
262262
}
263-
264-
265-
QGCColoredImage {
266-
id: hamburger
267-
anchors.margins: _margin
268-
anchors.right: parent.right
269-
anchors.verticalCenter: topRowLayout.verticalCenter
270-
width: _hamburgerSize
271-
height: _hamburgerSize
272-
sourceSize.height: _hamburgerSize
273-
source: "qrc:/qmlimages/Hamburger.svg"
274-
visible: missionItem.isCurrentItem && missionItem.sequenceNumber !== 0
275-
color: qgcPal.text
276-
277-
QGCMouseArea {
278-
fillItem: hamburger
279-
onClicked: (position) => {
280-
currentItemScope.focus = true
281-
position = Qt.point(position.x, position.y)
282-
// For some strange reason using mainWindow in mapToItem doesn't work, so we use globals.parent instead which also gets us mainWindow
283-
position = mapToItem(globals.parent, position)
284-
var dropPanel = hamburgerMenuDropPanelComponent.createObject(mainWindow, { clickRect: Qt.rect(position.x, position.y, 0, 0) })
285-
dropPanel.open()
286-
}
287-
}
288-
}
289-
290-
Loader {
291-
id: editorLoader
292-
anchors.margins: _innerMargin
293-
anchors.left: parent.left
294-
anchors.top: topRowLayout.bottom
295-
source: missionItem.editorQml
296-
asynchronous: true
297-
298-
property var masterController: _masterController
299-
property real availableWidth: _root.width - (anchors.margins * 2) ///< How wide the editor should be
300-
property var editorRoot: _root
301-
}
302263
} // Rectangle

src/QmlControls/MissionSettingsEditor.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Rectangle {
1616
id: valuesRect
1717
width: availableWidth
1818
height: valuesColumn.height + (_margin * 2)
19-
color: qgcPal.windowShadeDark
19+
color: "transparent"
2020
radius: _radius
2121

2222
property var _masterControler: masterController

0 commit comments

Comments
 (0)