CopterGeoFenceEditor.qml 2.68 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
import QtQuick          2.2
import QtQuick.Controls 1.2

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.FlightMap     1.0
import QGroundControl.FactSystem    1.0

Column {
    id:         editorColumn
    width:      availableWidth
    spacing:    _margin

    //property real availableWidth - Available width for control - Must be passed in from Loader

    readonly property real _margin:         ScreenTools.defaultFontPixelWidth / 2
    readonly property real _editFieldWidth: Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 15)

    QGCLabel {
        anchors.left:   parent.left
        anchors.right:  parent.right
        wrapMode:       Text.WordWrap
        text:           qsTr("Click in map to set breach return point.")
        visible:        geoFenceController.breachReturnSupported
    }

    QGCLabel { text: qsTr("Fence Settings:") }

    Rectangle {
        anchors.left:   parent.left
        anchors.right:  parent.right
        height:         1
        color:          qgcPal.text
    }

    QGCLabel {
        text:       qsTr("Must be connected to Vehicle to change fence settings.")
        visible:    !QGroundControl.multiVehicleManager.activeVehicle
    }

    Repeater {
        model: geoFenceController.params

        Item {
            width:  editorColumn.width
            height: textField.height

            QGCLabel {
                id:                 textFieldLabel
                anchors.baseline:   textField.baseline
                text:               geoFenceController.paramLabels[index]
            }

            FactTextField {
                id:             textField
                anchors.right:  parent.right
                width:          _editFieldWidth
                showUnits:      true
                fact:           modelData
                visible:        !comboField.visible
            }

            FactComboBox {
                id:             comboField
                anchors.right:  parent.right
                width:          _editFieldWidth
                indexModel:     false
                fact:           visible ? modelData : _nullFact
                visible:        modelData.enumStrings.length

                property var _nullFact: Fact { }
            }
        }
    }

    QGCMapPolygonControls {
        anchors.left:   parent.left
        anchors.right:  parent.right
        flightMap:      editorMap
        polygon:        root.polygon
        sectionLabel:   qsTr("Fence Polygon:")
        visible:        geoFenceController.polygonSupported
    }
}