WimaItemEditor.qml 5.43 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.4
import QtQuick.Dialogs          1.2
import QtQml                    2.2

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


Valentin Platzgummer's avatar
Valentin Platzgummer committed
15
/// Wima Item edit control
16 17
Rectangle {
    id:     _root
18
    height: editorLoader.visible ? (editorLoader.y + editorLoader.height + (_margin * 2)) : (commandPicker.y + commandPicker.height + _margin / 2)
Valentin Platzgummer's avatar
Valentin Platzgummer committed
19
    color:  interactive ? qgcPal.missionItemEditor : qgcPal.windowShade
20 21 22
    radius: _radius

    property var    map                 ///< Map control
23
    property var    wimaController
24 25 26
    property var    masterController
    property bool   readOnly            ///< true: read only view, false: full editing view
    property var    rootQgcView
27
    property int    _index
Valentin Platzgummer's avatar
Valentin Platzgummer committed
28
    property var    areaItem
29 30 31 32 33 34

    signal clicked
    signal remove

    property var    _masterController:          masterController
    property var    _missionController:         _masterController.missionController
Valentin Platzgummer's avatar
Valentin Platzgummer committed
35 36 37
    property var    _polygon:                   areaItem.polygon
    property bool   interactive:                areaItem.interactive
    property color  _outerTextColor:            interactive ? qgcPal.primaryButtonText : qgcPal.text
38 39 40 41 42
    property real   _sectionSpacer:             ScreenTools.defaultFontPixelWidth / 2  // spacing between section headings

    readonly property real  _editFieldWidth:    Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 12)
    readonly property real  _margin:            ScreenTools.defaultFontPixelWidth / 2
    readonly property real  _radius:            ScreenTools.defaultFontPixelWidth / 2
43
    readonly property real  _hamburgerSize:     commandPicker.height * 0.75
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

    QGCPalette {
        id: qgcPal
        colorGroupEnabled: enabled
    }

    FocusScope {
        id:             currentItemScope
        anchors.fill:   parent

        MouseArea {
            anchors.fill:   parent
            onClicked: {
                currentItemScope.focus = true
                _root.clicked()
            }
        }
    }


    QGCLabel {
        id:                     label
66
        anchors.verticalCenter: commandPicker.verticalCenter
67 68
        anchors.leftMargin:     _margin
        anchors.left:           parent.left
69
        text:                   _index+1
70 71 72 73 74 75 76
        color:                  _outerTextColor
    }

    QGCColoredImage {
        id:                     hamburger
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
        anchors.right:          parent.right
77
        anchors.verticalCenter: commandPicker.verticalCenter
78 79 80 81
        width:                  _hamburgerSize
        height:                 _hamburgerSize
        sourceSize.height:      _hamburgerSize
        source:                 "qrc:/qmlimages/Hamburger.svg"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
82
        visible:                interactive
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
        color:                  qgcPal.text
    }

    QGCMouseArea {
        fillItem:   hamburger
        visible:    hamburger.visible
        onClicked: {
            currentItemScope.focus = true
            hamburgerMenu.popup()
        }

        Menu {
            id: hamburgerMenu

            MenuItem {
98 99 100 101 102 103 104
                text:           qsTr("Add Operating Area")
                onTriggered:    wimaController.addGlobalMeasurementArea()
            }

            MenuItem {
                text:           qsTr("Add Service Area")
                onTriggered:    wimaController.addServiceArea()
105
            }
106

107 108 109 110
            MenuItem {
                text:           qsTr("Delete")
                onTriggered:    remove()
            }
111

112
            MenuItem {
113 114
                text:           qsTr("Change Area Type ...")
                onTriggered:    commandPicker.clicked()
115
            }
116 117


118 119 120
        }
    }

121 122
    QGCButton {
        id:                     commandPicker
123 124 125 126 127
        anchors.topMargin:      _margin / 2
        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth * 2
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
        anchors.left:           label.right
        anchors.top:            parent.top
Valentin Platzgummer's avatar
Valentin Platzgummer committed
128 129
        visible:                interactive
        text:                   areaItem.objectName;
130 131 132 133 134

        Component {
            id: commandDialog

            MissionCommandDialog {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
135
                missionItem: areaItem
136 137 138 139
            }
        }

        onClicked: qgcView.showDialog(commandDialog, qsTr("Select Mission Command"), qgcView.showDialogDefaultWidth, StandardButton.Cancel)
140 141
    }

142 143 144
    QGCLabel {
        id:                 commandLabel
        anchors.fill:       commandPicker
Valentin Platzgummer's avatar
Valentin Platzgummer committed
145
        visible:            !interactive
146
        verticalAlignment:  Text.AlignVCenter
Valentin Platzgummer's avatar
Valentin Platzgummer committed
147
        text:               areaItem.objectName;
148 149
        color:              _outerTextColor
    }
150 151 152 153 154 155

    Loader {
        id:                 editorLoader
        anchors.leftMargin: _margin
        anchors.topMargin:  _margin
        anchors.left:       parent.left
156
        anchors.top:        commandPicker.bottom
Valentin Platzgummer's avatar
Valentin Platzgummer committed
157 158
        source:             areaItem.editorQML
        visible:            interactive
159 160 161 162 163 164

        property var    masterController:   _masterController
        property real   availableWidth:     _root.width - (_margin * 2) ///< How wide the editor should be
        property var    editorRoot:         _root
    }
} // Rectangle
165 166 167 168 169