RallyPointItemEditor.qml 4.28 KB
Newer Older
1 2 3
import QtQuick                      2.11
import QtQuick.Controls             2.4
import QtQuick.Layouts              1.11
4 5 6 7 8 9 10 11 12 13

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

Rectangle {
    id:     root
    height: _currentItem ? valuesRect.y + valuesRect.height + (_margin * 2) : titleBar.y - titleBar.height + _margin
Don Gagne's avatar
Don Gagne committed
14
    color:  _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade
15 16
    radius: _radius

17 18
    signal clicked()

19 20 21
    property var rallyPoint ///< RallyPoint object associated with editor
    property var controller ///< RallyPointController

22
    property bool   _currentItem:       rallyPoint ? rallyPoint === controller.currentRallyPoint : false
23
    property color  _outerTextColor:    qgcPal.text // _currentItem ? "black" : qgcPal.text
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

    readonly property real  _margin:            ScreenTools.defaultFontPixelWidth / 2
    readonly property real  _radius:            ScreenTools.defaultFontPixelWidth / 2
    readonly property real  _titleHeight:       ScreenTools.defaultFontPixelHeight * 2

    QGCPalette { id: qgcPal; colorGroupEnabled: true }

    Item {
        id:                 titleBar
        anchors.margins:    _margin
        anchors.top:        parent.top
        anchors.left:       parent.left
        anchors.right:      parent.right
        height:             _titleHeight

        MissionItemIndexLabel {
            id:                     indicator
            anchors.verticalCenter: parent.verticalCenter
            anchors.left:           parent.left
            label:                  "R"
            checked:                true
        }

        QGCLabel {
            anchors.leftMargin:     _margin
            anchors.left:           indicator.right
            anchors.verticalCenter: parent.verticalCenter
            text:                   qsTr("Rally Point")
            color:                  _outerTextColor
        }

Don Gagne's avatar
Don Gagne committed
55
        QGCColoredImage {
56 57 58 59 60 61 62 63
            id:                     hamburger
            anchors.rightMargin:    _margin
            anchors.right:          parent.right
            anchors.verticalCenter: parent.verticalCenter
            width:                  ScreenTools.defaultFontPixelWidth * 2
            height:                 width
            sourceSize.height:      height
            source:                 "qrc:/qmlimages/Hamburger.svg"
Don Gagne's avatar
Don Gagne committed
64
            color:                  qgcPal.text
65 66 67 68 69

            MouseArea {
                anchors.fill:   parent
                onClicked:      hamburgerMenu.popup()

70
                QGCMenu {
71 72
                    id: hamburgerMenu

73
                    QGCMenuItem {
74 75 76 77 78 79 80 81 82 83 84 85 86 87
                        text:           qsTr("Delete")
                        onTriggered:    controller.removePoint(rallyPoint)
                    }
                }
            }
        }
    } // Item - titleBar

    Rectangle {
        id:                 valuesRect
        anchors.margins:    _margin
        anchors.left:       parent.left
        anchors.right:      parent.right
        anchors.top:        titleBar.bottom
88
        height:             valuesGrid.height + (_margin * 2)
89 90 91 92
        color:              qgcPal.windowShadeDark
        visible:            _currentItem
        radius:             _radius

93 94
        GridLayout {
            id:                 valuesGrid
95 96 97 98
            anchors.margins:    _margin
            anchors.left:       parent.left
            anchors.right:      parent.right
            anchors.top:        parent.top
99 100 101 102
            rowSpacing:         _margin
            columnSpacing:      _margin
            rows:               rallyPoint ? rallyPoint.textFieldFacts.length : 0
            flow:               GridLayout.TopToBottom
103 104 105

            Repeater {
                model: rallyPoint ? rallyPoint.textFieldFacts : 0
106 107 108 109
                QGCLabel {
                    text: modelData.name + ":"
                }
            }
110

111 112 113 114 115 116
            Repeater {
                model: rallyPoint ? rallyPoint.textFieldFacts : 0
                FactTextField {
                    Layout.fillWidth:   true
                    showUnits:          true
                    fact:               modelData
117
                }
118 119
            }
        } // GridLayout
120 121
    } // Rectangle
} // Rectangle