SimpleItemEditor.qml 8.28 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 25 26 27 28
    property bool _specifiesAltitude:       missionItem.specifiesAltitude
    property real _margin:                  ScreenTools.defaultFontPixelHeight / 2
    property bool _supportsTerrainFrame:    missionItem

    readonly property int _altModeRelative:     0
    readonly property int _altModeAbsolute:     1
    readonly property int _altModeAboveTerrain: 2
    readonly property int _altModeTerrainFrame: 3
29 30 31

    ExclusiveGroup {
        id: altRadios
DonLakeFlyer's avatar
DonLakeFlyer committed
32 33 34 35
        onCurrentChanged: {
            altModeLabel.text = Qt.binding(function() { return current.helpText })
            missionItem.altitudeMode = current.altModeValue
        }
36
    }
37

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    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
65
                    visible:        object.name !== ""
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
                    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
                }
            }
        }

85
        Rectangle {
DonLakeFlyer's avatar
DonLakeFlyer committed
86 87 88 89 90
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         altColumn.y + altColumn.height + _margin
            color:          qgcPal.windowShade
            visible:        _specifiesAltitude
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

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

                QGCLabel {
                    font.pointSize: ScreenTools.smallFontPointSize
                    text:           qsTr("Altitude")
                }

                RowLayout {
106 107 108 109 110
                    QGCRadioButton {
                        text:           qsTr("Rel")
                        exclusiveGroup: altRadios
                        checked:        missionItem.altitudeMode === altModeValue

DonLakeFlyer's avatar
DonLakeFlyer committed
111 112
                        readonly property int       altModeValue:   _altModeRelative
                        readonly property string    helpText:       qsTr("Relative to home altitude")
113 114 115 116 117 118
					}
                    QGCRadioButton {
                        text:           qsTr("Abs")
                        exclusiveGroup: altRadios
                        checked:        missionItem.altitudeMode === altModeValue
                        visible:        QGroundControl.corePlugin.options.showMissionAbsoluteAltitude || missionItem.altitudeMode === altModeValue
DonLakeFlyer's avatar
DonLakeFlyer committed
119 120 121

                        readonly property int       altModeValue:   _altModeAbsolute
                        readonly property string    helpText:       qsTr("Absolute WGS84")
122 123 124 125 126
                    }
                    QGCRadioButton {
                        text:           qsTr("AGL")
                        exclusiveGroup: altRadios
                        checked:        missionItem.altitudeMode === altModeValue
DonLakeFlyer's avatar
DonLakeFlyer committed
127 128 129

                        readonly property int   altModeValue: _altModeAboveTerrain
                        property string         helpText:     qsTr("Calculated from terrain data\nAbs Alt ") + missionItem.amslAltAboveTerrain.valueString + " " + missionItem.amslAltAboveTerrain.units
130 131 132 133 134 135
                    }
                    QGCRadioButton {
                        text:           qsTr("TerrF")
                        exclusiveGroup: altRadios
                        checked:        missionItem.altitudeMode === altModeValue
                        visible:        missionItem.supportsTerrainFrame || missionItem.altitudeMode === altModeValue
DonLakeFlyer's avatar
DonLakeFlyer committed
136 137 138 139

                        readonly property int       altModeValue:   _altModeTerrainFrame
                        readonly property string    helpText:       qsTr("Using terrain reference frame")
                    }
140 141 142 143 144 145 146 147
                }

                FactValueSlider {
                    fact:           missionItem.altitude
                    digitCount:     3
                    incrementSlots: 1
                }

148
                QGCLabel {
DonLakeFlyer's avatar
DonLakeFlyer committed
149 150 151 152
                    id:             altModeLabel
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    wrapMode:       Text.WordWrap
153 154
                    font.pointSize: ScreenTools.smallFontPointSize
                }
155 156 157
            }
        }

158 159 160 161
        GridLayout {
            anchors.left:   parent.left
            anchors.right:  parent.right
            flow:           GridLayout.TopToBottom
162 163
            rows:           missionItem.textFieldFacts.count +
                            missionItem.nanFacts.count +
164
                            (missionItem.speedSection.available ? 1 : 0)
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
            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
            }

191

192 193 194 195 196 197 198
            Repeater {
                model: missionItem.textFieldFacts

                FactTextField {
                    showUnits:          true
                    fact:               object
                    Layout.fillWidth:   true
199
                    enabled:            !object.readOnly
200 201 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
                }
            }

            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
227
} // Rectangle