SimpleItemEditor.qml 13.8 KB
Newer Older
1 2 3 4
import QtQuick                      2.11
import QtQuick.Controls             2.4
import QtQuick.Controls.Styles      1.4
import QtQuick.Layouts              1.11
5

6
import QGroundControl               1.0
7 8 9 10 11 12 13 14
import QGroundControl.ScreenTools   1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.Controls      1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0

// Editor for Simple mission items
Rectangle {
15
    width:  availableWidth
16
    height: editorColumn.height + (_margin * 2)
17 18 19
    color:  qgcPal.windowShadeDark
    radius: _radius

20 21
    property bool _specifiesAltitude:       missionItem.specifiesAltitude
    property real _margin:                  ScreenTools.defaultFontPixelHeight / 2
22 23
    property bool _supportsTerrainFrame:    missionItem.masterController.supportsTerrain
    property var  _controllerVehicle:       missionItem.masterController.controllerVehicle
24

25
    property string _altModeRelativeHelpText:       qsTr("Altitude relative to launch altitude")
26 27
    property string _altModeAbsoluteHelpText:       qsTr("Altitude above mean sea level")
    property string _altModeAboveTerrainHelpText:   qsTr("Altitude above terrain\nActual AMSL altitude: %1 %2").arg(missionItem.amslAltAboveTerrain.valueString).arg(missionItem.amslAltAboveTerrain.units)
28 29 30
    property string _altModeTerrainFrameHelpText:   qsTr("Using terrain reference frame")

    function updateAltitudeModeText() {
31
        if (missionItem.altitudeMode === QGroundControl.AltitudeModeRelative) {
32 33
            altModeLabel.text = qsTr("Altitude")
            altModeHelp.text = _altModeRelativeHelpText
34
        } else if (missionItem.altitudeMode === QGroundControl.AltitudeModeAbsolute) {
35 36
            altModeLabel.text = qsTr("Above Mean Sea Level")
            altModeHelp.text = _altModeAbsoluteHelpText
37
        } else if (missionItem.altitudeMode === QGroundControl.AltitudeModeAboveTerrain) {
38 39
            altModeLabel.text = qsTr("Above Terrain")
            altModeHelp.text = Qt.binding(function() { return _altModeAboveTerrainHelpText })
40
        } else if (missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame) {
41 42 43 44 45
            altModeLabel.text = qsTr("Terrain Frame")
            altModeHelp.text = _altModeTerrainFrameHelpText
        } else {
            altModeLabel.text = qsTr("Internal Error")
            altModeHelp.text = ""
DonLakeFlyer's avatar
DonLakeFlyer committed
46
        }
47
    }
48

49 50 51 52 53 54 55
    Component.onCompleted: updateAltitudeModeText()

    Connections {
        target:                 missionItem
        onAltitudeModeChanged:  updateAltitudeModeText()
    }

56
    Column {
57
        id:                 editorColumn
58 59 60 61
        anchors.margins:    _margin
        anchors.left:       parent.left
        anchors.right:      parent.right
        anchors.top:        parent.top
62 63 64 65 66 67 68 69 70 71
        spacing:            _margin

        QGCLabel {
            width:          parent.width
            wrapMode:       Text.WordWrap
            font.pointSize: ScreenTools.smallFontPointSize
            text:           missionItem.rawEdit ?
                                qsTr("Provides advanced access to all commands/parameters. Be very careful!") :
                                missionItem.commandDescription
        }
72

73 74 75 76
        ColumnLayout {
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin
77
            visible:            missionItem.isTakeoffItem && missionItem.wizardMode // Hack special case for takeoff item
78

79
            QGCLabel {
80
                text:               qsTr("Move '%1' Takeoff to the %2 location.").arg(_controllerVehicle.vtol ? qsTr("V") : qsTr("T")).arg(_controllerVehicle.vtol ? qsTr("desired") : qsTr("climbout"))
81 82
                Layout.fillWidth:   true
                wrapMode:           Text.WordWrap
83
                visible:            !initialClickLabel.visible
84 85
            }

86
            QGCLabel {
87
                text:               qsTr("Ensure clear of obstacles and into the wind.")
88 89
                Layout.fillWidth:   true
                wrapMode:           Text.WordWrap
90
                visible:            !initialClickLabel.visible
91
            }
92

93
            QGCButton {
DoinLakeFlyer's avatar
DoinLakeFlyer committed
94
                text:               qsTr("Done")
95
                Layout.fillWidth:   true
96
                visible:            !initialClickLabel.visible
97 98
                onClicked: {
                    missionItem.wizardMode = false
DoinLakeFlyer's avatar
DoinLakeFlyer committed
99 100
                    // Trial of no auto select next item
                    //editorRoot.selectNextNotReadyItem()
101 102
                }
            }
103 104 105 106 107 108 109 110 111 112

            QGCLabel {
                id:                 initialClickLabel
                text:               missionItem.launchTakeoffAtSameLocation ?
                                        qsTr("Click in map to set planned Takeoff location.") :
                                        qsTr("Click in map to set planned Launch location.")
                Layout.fillWidth:   true
                wrapMode:           Text.WordWrap
                visible:            missionItem.isTakeoffItem && !missionItem.launchCoordinate.isValid
            }
113 114
        }

115 116 117 118 119 120 121 122 123 124
        Column {
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin
            visible:            !missionItem.wizardMode

            GridLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                columns:        2
125

126 127
                Repeater {
                    model: missionItem.comboboxFacts
128

129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
                    QGCLabel {
                        text:           object.name
                        visible:        object.name !== ""
                        Layout.column:  0
                        Layout.row:     index
                    }
                }

                Repeater {
                    model: missionItem.comboboxFacts

                    FactComboBox {
                        indexModel:         false
                        model:              object.enumStrings
                        fact:               object
                        font.pointSize:     ScreenTools.smallFontPointSize
                        Layout.column:      1
                        Layout.row:         index
                        Layout.fillWidth:   true
                    }
                }
            }
151

152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
            Rectangle {
                anchors.left:   parent.left
                anchors.right:  parent.right
                height:         altColumn.y + altColumn.height + _margin
                color:          qgcPal.windowShade
                visible:        _specifiesAltitude

                Column {
                    id:                 altColumn
                    anchors.margins:    _margin
                    anchors.top:        parent.top
                    anchors.left:       parent.left
                    anchors.right:      parent.right
                    spacing:            _margin

167 168 169 170 171 172 173 174
                    QGCLabel {
                        width:          parent.width
                        wrapMode:       Text.WordWrap
                        font.pointSize: ScreenTools.smallFontPointSize
                        text:           qsTr("Altitude below specifies the approximate altitude of the ground. Normally 0 for landing back at original launch location.")
                        visible:        missionItem.isLandCommand
                    }

175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
                    Item {
                        width:  altHamburger.x + altHamburger.width
                        height: altModeLabel.height

                        QGCLabel { id: altModeLabel }

                        QGCColoredImage {
                            id:                     altHamburger
                            anchors.leftMargin:     ScreenTools.defaultFontPixelWidth / 4
                            anchors.left:           altModeLabel.right
                            anchors.verticalCenter: altModeLabel.verticalCenter
                            width:                  ScreenTools.defaultFontPixelHeight / 2
                            height:                 width
                            sourceSize.height:      height
                            source:                 "/res/DropArrow.svg"
                            color:                  qgcPal.text
191 192
                        }

193 194 195
                        QGCMouseArea {
                            anchors.fill:   parent
                            onClicked:      altHamburgerMenu.popup()
196 197
                        }

198 199 200 201
                        QGCMenu {
                            id: altHamburgerMenu

                            QGCMenuItem {
202
                                text:           qsTr("Altitude Relative To Launch")
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
                                checkable:      true
                                checked:        missionItem.altitudeMode === QGroundControl.AltitudeModeRelative
                                onTriggered:    missionItem.altitudeMode = QGroundControl.AltitudeModeRelative
                            }

                            QGCMenuItem {
                                text:           qsTr("Altitude Above Mean Sea Level")
                                checkable:      true
                                checked:        missionItem.altitudeMode === QGroundControl.AltitudeModeAbsolute
                                visible:        QGroundControl.corePlugin.options.showMissionAbsoluteAltitude
                                onTriggered:    missionItem.altitudeMode = QGroundControl.AltitudeModeAbsolute
                            }

                            QGCMenuItem {
                                text:           qsTr("Altitude Above Terrain")
                                checkable:      true
                                checked:        missionItem.altitudeMode === QGroundControl.AltitudeModeAboveTerrain
                                onTriggered:    missionItem.altitudeMode = QGroundControl.AltitudeModeAboveTerrain
                                visible:        missionItem.specifiesCoordinate
                            }

                            QGCMenuItem {
                                text:           qsTr("Terrain Frame")
                                checkable:      true
                                checked:        missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame
228
                                visible:        _supportsTerrainFrame && (missionItem.specifiesCoordinate || missionItem.specifiesAltitudeOnly)
229 230
                                onTriggered:    missionItem.altitudeMode = QGroundControl.AltitudeModeTerrainFrame
                            }
231
                        }
DonLakeFlyer's avatar
DonLakeFlyer committed
232
                    }
233

234 235 236 237 238 239 240
                    AltitudeFactTextField {
                        id:                 altField
                        fact:               missionItem.altitude
                        altitudeMode:       missionItem.altitudeMode
                        anchors.left:       parent.left
                        anchors.right:      parent.right
                    }
241

242 243 244 245 246 247 248
                    QGCLabel {
                        id:                 altModeHelp
                        wrapMode:           Text.WordWrap
                        font.pointSize:     ScreenTools.smallFontPointSize
                        anchors.left:       parent.left
                        anchors.right:      parent.right
                    }
249
                }
250 251
            }

252 253 254 255 256 257 258 259
            GridLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                flow:           GridLayout.TopToBottom
                rows:           missionItem.textFieldFacts.count +
                                missionItem.nanFacts.count +
                                (missionItem.speedSection.available ? 1 : 0)
                columns:        2
260

261 262
                Repeater {
                    model: missionItem.textFieldFacts
263

264 265
                    QGCLabel { text: object.name }
                }
266

267 268
                Repeater {
                    model: missionItem.nanFacts
269

270 271 272 273 274
                    QGCCheckBox {
                        text:           object.name
                        checked:        !isNaN(object.rawValue)
                        onClicked:      object.rawValue = checked ? 0 : NaN
                    }
275 276
                }

277 278 279 280 281 282 283
                QGCCheckBox {
                    id:         flightSpeedCheckbox
                    text:       qsTr("Flight Speed")
                    checked:    missionItem.speedSection.specifyFlightSpeed
                    onClicked:  missionItem.speedSection.specifyFlightSpeed = checked
                    visible:    missionItem.speedSection.available
                }
284

285

286 287
                Repeater {
                    model: missionItem.textFieldFacts
288

289 290 291 292 293 294
                    FactTextField {
                        showUnits:          true
                        fact:               object
                        Layout.fillWidth:   true
                        enabled:            !object.readOnly
                    }
295 296
                }

297 298 299 300 301 302 303 304 305 306
                Repeater {
                    model: missionItem.nanFacts

                    FactTextField {
                        showUnits:          true
                        fact:               object
                        Layout.fillWidth:   true
                        enabled:            !isNaN(object.rawValue)
                    }
                }
307 308

                FactTextField {
309
                    fact:               missionItem.speedSection.flightSpeed
310
                    Layout.fillWidth:   true
311 312
                    enabled:            flightSpeedCheckbox.checked
                    visible:            missionItem.speedSection.available
313 314 315
                }
            }

316 317 318
            CameraSection {
                checked:    missionItem.cameraSection.settingsSpecified
                visible:    missionItem.cameraSection.available
319 320
            }
        }
321 322
    }
}