SimpleItemEditor.qml 10.4 KB
Newer Older
1 2
import QtQuick                  2.3
import QtQuick.Controls         1.2
3
import QtQuick.Controls.Styles  1.4
4
import QtQuick.Dialogs          1.2
5
import QtQuick.Layouts          1.2
6

7
import QGroundControl               1.0
8 9 10 11 12 13 14 15
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 {
16
    width:  availableWidth
Don Gagne's avatar
Don Gagne committed
17
    height: valuesColumn.height + (_margin * 2)
18 19 20
    color:  qgcPal.windowShadeDark
    radius: _radius

21 22 23 24
    property bool _specifiesAltitude:       missionItem.specifiesAltitude
    property real _margin:                  ScreenTools.defaultFontPixelHeight / 2
    property bool _supportsTerrainFrame:    missionItem

25 26 27
    property string _altModeRelativeHelpText:       qsTr("Altitude relative to home altitude")
    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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    Column {
        id:                 valuesColumn
        anchors.margins:    _margin
        anchors.left:       parent.left
        anchors.right:      parent.right
        anchors.top:        parent.top
        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
        }

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

            Repeater {
                model: missionItem.comboboxFacts

                QGCLabel {
                    text:           object.name
83
                    visible:        object.name !== ""
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
                    Layout.column:  0
                    Layout.row:     index
                }
            }

            Repeater {
                model: missionItem.comboboxFacts

                FactComboBox {
                    indexModel:         false
                    model:              object.enumStrings
                    fact:               object
                    Layout.column:      1
                    Layout.row:         index
                    Layout.fillWidth:   true
                }
            }
        }

103
        Rectangle {
DonLakeFlyer's avatar
DonLakeFlyer committed
104 105 106 107 108
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         altColumn.y + altColumn.height + _margin
            color:          qgcPal.windowShade
            visible:        _specifiesAltitude
109 110 111 112 113 114 115 116 117

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

118 119 120 121 122 123 124 125 126 127
                Item {
                    width:  altHamburger.x + altHamburger.width
                    height: altModeLabel.height

                    QGCLabel { id: altModeLabel }

                    QGCColoredImage {
                        id:                     altHamburger
                        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth / 4
                        anchors.left:           altModeLabel.right
Don Gagne's avatar
Don Gagne committed
128 129 130
                        anchors.verticalCenter: altModeLabel.verticalCenter
                        width:                  ScreenTools.defaultFontPixelHeight / 2
                        height:                 width
131
                        sourceSize.height:      height
Don Gagne's avatar
Don Gagne committed
132
                        source:                 "/res/DropArrow.svg"
133
                        color:                  qgcPal.text
134
                    }
DonLakeFlyer's avatar
DonLakeFlyer committed
135

136 137 138
                    QGCMouseArea {
                        anchors.fill:   parent
                        onClicked:      altHamburgerMenu.popup()
139
                    }
140 141 142 143 144 145

                    Menu {
                        id: altHamburgerMenu

                        MenuItem {
                            text:           qsTr("Altitude Relative To Home")
146
                            checkable:      true
147 148
                            checked:        missionItem.altitudeMode === QGroundControl.AltitudeModeRelative
                            onTriggered:    missionItem.altitudeMode = QGroundControl.AltitudeModeRelative
149 150 151
                        }

                        MenuItem {
152 153
                            text:           qsTr("Altitude Above Mean Sea Level")
                            checkable:      true
154
                            checked:        missionItem.altitudeMode === QGroundControl.AltitudeModeAbsolute
155
                            visible:        QGroundControl.corePlugin.options.showMissionAbsoluteAltitude
156
                            onTriggered:    missionItem.altitudeMode = QGroundControl.AltitudeModeAbsolute
157 158 159
                        }

                        MenuItem {
160 161
                            text:           qsTr("Altitude Above Terrain")
                            checkable:      true
162 163
                            checked:        missionItem.altitudeMode === QGroundControl.AltitudeModeAboveTerrain
                            onTriggered:    missionItem.altitudeMode = QGroundControl.AltitudeModeAboveTerrain
Don Gagne's avatar
Don Gagne committed
164
                            visible:        missionItem.specifiesCoordinate
165 166 167 168
                        }

                        MenuItem {
                            text:           qsTr("Terrain Frame")
169
                            checkable:      true
170 171 172
                            checked:        missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame
                            visible:        missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame
                            onTriggered:    missionItem.altitudeMode = QGroundControl.AltitudeModeTerrainFrame
173
                        }
DonLakeFlyer's avatar
DonLakeFlyer committed
174
                    }
175 176
                }

177
                AltitudeFactTextField {
Don Gagne's avatar
Don Gagne committed
178 179
                    id:                 altField
                    fact:               missionItem.altitude
180
                    altitudeMode:       missionItem.altitudeMode
Don Gagne's avatar
Don Gagne committed
181 182
                    anchors.left:       parent.left
                    anchors.right:      parent.right
183 184
                }

185
                QGCLabel {
Don Gagne's avatar
Don Gagne committed
186 187 188 189 190
                    id:                 altModeHelp
                    wrapMode:           Text.WordWrap
                    font.pointSize:     ScreenTools.smallFontPointSize
                    anchors.left:       parent.left
                    anchors.right:      parent.right
191
                }
192 193 194
            }
        }

195 196 197 198
        GridLayout {
            anchors.left:   parent.left
            anchors.right:  parent.right
            flow:           GridLayout.TopToBottom
199 200
            rows:           missionItem.textFieldFacts.count +
                            missionItem.nanFacts.count +
201
                            (missionItem.speedSection.available ? 1 : 0)
202 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
            columns:        2

            Repeater {
                model: missionItem.textFieldFacts

                QGCLabel { text: object.name }
            }

            Repeater {
                model: missionItem.nanFacts

                QGCCheckBox {
                    text:           object.name
                    checked:        !isNaN(object.rawValue)
                    onClicked:      object.rawValue = checked ? 0 : NaN
                }
            }

            QGCCheckBox {
                id:         flightSpeedCheckbox
                text:       qsTr("Flight Speed")
                checked:    missionItem.speedSection.specifyFlightSpeed
                onClicked:  missionItem.speedSection.specifyFlightSpeed = checked
                visible:    missionItem.speedSection.available
            }

228

229 230 231 232 233 234 235
            Repeater {
                model: missionItem.textFieldFacts

                FactTextField {
                    showUnits:          true
                    fact:               object
                    Layout.fillWidth:   true
236
                    enabled:            !object.readOnly
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
                }
            }

            Repeater {
                model: missionItem.nanFacts

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

            FactTextField {
                fact:               missionItem.speedSection.flightSpeed
                Layout.fillWidth:   true
                enabled:            flightSpeedCheckbox.checked
                visible:            missionItem.speedSection.available
            }
        }

        CameraSection {
            checked:    missionItem.cameraSection.settingsSpecified
            visible:    missionItem.cameraSection.available
        }
    } // Column
264
} // Rectangle