Skip to content
SimpleItemEditor.qml 12.3 KiB
Newer Older
import QtQuick                      2.11
import QtQuick.Controls             2.4
import QtQuick.Controls.Styles      1.4
import QtQuick.Layouts              1.11
import QGroundControl               1.0
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 {
    width:  availableWidth
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    height: editorColumn.height + (_margin * 2)
    color:  qgcPal.windowShadeDark
    radius: _radius

Don Gagne's avatar
 
Don Gagne committed
    property bool _specifiesAltitude:       missionItem.specifiesAltitude
    property real _margin:                  ScreenTools.defaultFontPixelHeight / 2
    property bool _supportsTerrainFrame:    missionItem

Don Gagne's avatar
 
Don Gagne committed
    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)
Don Gagne's avatar
 
Don Gagne committed
    property string _altModeTerrainFrameHelpText:   qsTr("Using terrain reference frame")

    function updateAltitudeModeText() {
Don Gagne's avatar
 
Don Gagne committed
        if (missionItem.altitudeMode === QGroundControl.AltitudeModeRelative) {
Don Gagne's avatar
 
Don Gagne committed
            altModeLabel.text = qsTr("Altitude")
            altModeHelp.text = _altModeRelativeHelpText
Don Gagne's avatar
 
Don Gagne committed
        } else if (missionItem.altitudeMode === QGroundControl.AltitudeModeAbsolute) {
Don Gagne's avatar
 
Don Gagne committed
            altModeLabel.text = qsTr("Above Mean Sea Level")
            altModeHelp.text = _altModeAbsoluteHelpText
Don Gagne's avatar
 
Don Gagne committed
        } else if (missionItem.altitudeMode === QGroundControl.AltitudeModeAboveTerrain) {
Don Gagne's avatar
 
Don Gagne committed
            altModeLabel.text = qsTr("Above Terrain")
            altModeHelp.text = Qt.binding(function() { return _altModeAboveTerrainHelpText })
Don Gagne's avatar
 
Don Gagne committed
        } else if (missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame) {
Don Gagne's avatar
 
Don Gagne committed
            altModeLabel.text = qsTr("Terrain Frame")
            altModeHelp.text = _altModeTerrainFrameHelpText
        } else {
            altModeLabel.text = qsTr("Internal Error")
            altModeHelp.text = ""
DonLakeFlyer's avatar
DonLakeFlyer committed
        }
Don Gagne's avatar
 
Don Gagne committed
    Component.onCompleted: updateAltitudeModeText()

    Connections {
        target:                 missionItem
        onAltitudeModeChanged:  updateAltitudeModeText()
    }

DonLakeFlyer's avatar
 
DonLakeFlyer committed
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.left:       parent.left
        anchors.right:      parent.right
        anchors.top:        parent.top

DonLakeFlyer's avatar
 
DonLakeFlyer committed
        ColumnLayout {
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin
            visible:            missionItem.wizardMode
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            QGCLabel {
                text:               qsTr("Adjust the initial launch location by selecting 'P' and dragging it to the correct location.")
                Layout.fillWidth:   true
                wrapMode:           Text.WordWrap
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            QGCLabel {
                text:               qsTr("Adjust the takeoff completion location by dragging it to the correct location.")
                Layout.fillWidth:   true
                wrapMode:           Text.WordWrap
            }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            QGCButton {
                text:               qsTr("Done Adjusting")
                Layout.fillWidth:   true
                onClicked: {
                    missionItem.wizardMode = false
                    editorRoot.selectNextNotReadyItem()
DonLakeFlyer's avatar
 
DonLakeFlyer committed
        Column {
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin
            visible:            !missionItem.wizardMode

            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
            }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            GridLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                columns:        2
Don Gagne's avatar
 
Don Gagne committed

DonLakeFlyer's avatar
 
DonLakeFlyer committed
                Repeater {
                    model: missionItem.comboboxFacts
Don Gagne's avatar
 
Don Gagne committed

DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    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
                    }
                }
            }
Don Gagne's avatar
 
Don Gagne committed

DonLakeFlyer's avatar
 
DonLakeFlyer committed
            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

                    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
Don Gagne's avatar
 
Don Gagne committed
                        }

DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        QGCMouseArea {
                            anchors.fill:   parent
                            onClicked:      altHamburgerMenu.popup()
Don Gagne's avatar
 
Don Gagne committed
                        }

DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        QGCMenu {
                            id: altHamburgerMenu

                            QGCMenuItem {
                                text:           qsTr("Altitude Relative To Home")
                                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
                                visible:        missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame
                                onTriggered:    missionItem.altitudeMode = QGroundControl.AltitudeModeTerrainFrame
                            }
Don Gagne's avatar
 
Don Gagne committed
                        }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    AltitudeFactTextField {
                        id:                 altField
                        fact:               missionItem.altitude
                        altitudeMode:       missionItem.altitudeMode
                        anchors.left:       parent.left
                        anchors.right:      parent.right
                    }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    QGCLabel {
                        id:                 altModeHelp
                        wrapMode:           Text.WordWrap
                        font.pointSize:     ScreenTools.smallFontPointSize
                        anchors.left:       parent.left
                        anchors.right:      parent.right
                    }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            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
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                Repeater {
                    model: missionItem.textFieldFacts
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    QGCLabel { text: object.name }
                }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                Repeater {
                    model: missionItem.nanFacts
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    QGCCheckBox {
                        text:           object.name
                        checked:        !isNaN(object.rawValue)
                        onClicked:      object.rawValue = checked ? 0 : NaN
                    }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                QGCCheckBox {
                    id:         flightSpeedCheckbox
                    text:       qsTr("Flight Speed")
                    checked:    missionItem.speedSection.specifyFlightSpeed
                    onClicked:  missionItem.speedSection.specifyFlightSpeed = checked
                    visible:    missionItem.speedSection.available
                }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                Repeater {
                    model: missionItem.textFieldFacts
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    FactTextField {
                        showUnits:          true
                        fact:               object
                        Layout.fillWidth:   true
                        enabled:            !object.readOnly
                    }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                Repeater {
                    model: missionItem.nanFacts

                    FactTextField {
                        showUnits:          true
                        fact:               object
                        Layout.fillWidth:   true
                        enabled:            !isNaN(object.rawValue)
                    }
                }
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    fact:               missionItem.speedSection.flightSpeed
                    Layout.fillWidth:   true
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    enabled:            flightSpeedCheckbox.checked
                    visible:            missionItem.speedSection.available
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            CameraSection {
                checked:    missionItem.cameraSection.settingsSpecified
                visible:    missionItem.cameraSection.available
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    }
}