AltitudeFactTextField.qml 3.57 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9 10 11 12
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
import QtQuick          2.3
import QtQuick.Dialogs  1.2
import QtQuick.Layouts  1.2

13 14
import QGroundControl               1.0
import QGroundControl.FactSystem    1.0
15 16
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
17 18

FactTextField {
19 20 21 22
    unitsLabel:                 fact ? fact.units : ""
    extraUnitsLabel:            fact ? _altitudeModeExtraUnits : ""
    showUnits:                  true
    showHelp:                   true
23

24 25
    property int  altitudeMode:             QGroundControl.AltitudeModeNone
    property bool showAboveTerrainWarning:  true
26 27

    readonly property string _altModeNoneExtraUnits:            ""
Don Gagne's avatar
Don Gagne committed
28 29 30 31
    readonly property string _altModeRelativeExtraUnits:        qsTr("(Rel)")
    readonly property string _altModeAbsoluteExtraUnits:        qsTr("(AMSL)")
    readonly property string _altModeAboveTerrainExtraUnits:    qsTr("(Abv Terr)")
    readonly property string _altModeTerrainFrameExtraUnits:    qsTr("(TerrF)")
32

33 34
    property string _altitudeModeExtraUnits:    _altModeNoneExtraUnits
    property Fact   _aboveTerrainWarning:       QGroundControl.settingsManager.planViewSettings.aboveTerrainWarning
Don Gagne's avatar
Don Gagne committed
35 36

    onAltitudeModeChanged: updateAltitudeModeExtraUnits()
37 38 39 40 41

    function updateAltitudeModeExtraUnits() {
        if (altitudeMode === QGroundControl.AltitudeModeNone) {
            _altitudeModeExtraUnits = _altModeNoneExtraUnits
        } else if (altitudeMode === QGroundControl.AltitudeModeRelative) {
42 43
            //_altitudeModeExtraUnits = _altModeRelativeExtraUnits
            _altitudeModeExtraUnits = "" // Showing (rel) all the time is too noisy
44 45 46 47
        } else if (altitudeMode === QGroundControl.AltitudeModeAbsolute) {
            _altitudeModeExtraUnits = _altModeAbsoluteExtraUnits
        } else if (altitudeMode === QGroundControl.AltitudeModeAboveTerrain) {
            _altitudeModeExtraUnits = _altModeAboveTerrainExtraUnits
48
            if (!_aboveTerrainWarning.rawValue && showAboveTerrainWarning) {
49 50
                mainWindow.showComponentDialog(aboveTerrainWarning, qsTr("Warning"), mainWindow.showDialogDefaultWidth, StandardButton.Ok)
            }
51 52 53 54 55 56 57
        } else if (missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame) {
            _altitudeModeExtraUnits = _altModeTerrainFrameExtraUnits
        } else {
            console.log("AltitudeFactTextField Internal error: Unknown altitudeMode", altitudeMode)
            _altitudeModeExtraUnits = ""
        }
    }
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

    Component {
        id: aboveTerrainWarning
        QGCViewDialog {
            ColumnLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        ScreenTools.defaultFontPixelHeight

                QGCLabel {
                    Layout.fillWidth:   true
                    wrapMode:           Text.WordWrap
                    text:               qsTr("'Above Terrain' will set an absolute altitude for the item based on the terrain height at the location and the requested altitude above terrain. It does not send terrain heights to the vehicle.")
                }

                FactCheckBox {
                    text: qsTr("Don't show again")
                    fact: _aboveTerrainWarning
                }
            }
        }
    }
80
}