CopterGeoFenceEditor.qml 2.57 KB
Newer Older
1 2
import QtQuick          2.3
import QtQuick.Controls 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

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.")
    }

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

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

    Repeater {
        model: geoFenceController.params

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

Don Gagne's avatar
Don Gagne committed
45 46
            property bool showCombo: modelData.enumStrings.length > 0

47 48 49 50 51 52 53 54 55 56 57 58
            QGCLabel {
                id:                 textFieldLabel
                anchors.baseline:   textField.baseline
                text:               geoFenceController.paramLabels[index]
            }

            FactTextField {
                id:             textField
                anchors.right:  parent.right
                width:          _editFieldWidth
                showUnits:      true
                fact:           modelData
Don Gagne's avatar
Don Gagne committed
59
                visible:        !parent.showCombo
60 61 62 63 64 65 66
            }

            FactComboBox {
                id:             comboField
                anchors.right:  parent.right
                width:          _editFieldWidth
                indexModel:     false
Don Gagne's avatar
Don Gagne committed
67 68
                fact:           showCombo ? modelData : _nullFact
                visible:        parent.showCombo
69 70 71 72 73 74

                property var _nullFact: Fact { }
            }
        }
    }

75 76 77 78 79
    QGCButton {
        text:       qsTr("Add fence")
        visible:    geoFenceController.mapPolygon.count < 3
        onClicked:  geoFenceController.addFence()
    }
80

81 82 83 84
    QGCButton {
        text:       qsTr("Remove fence")
        visible:    geoFenceController.mapPolygon.count >= 3
        onClicked:  geoFenceController.removeFence()
85 86
    }
}