WimaItemEditor_old.qml 4.9 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


15
/// Fly Area Item edit control
16 17
Rectangle {
    id:     _root
18
    height: editorLoader.visible ? (editorLoader.y + editorLoader.height + (_margin * 2)) : (descriptionLabel.y + descriptionLabel.height + _margin / 2)
19 20 21 22
    color:  _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade
    radius: _radius

    property var    map                 ///< Map control
23
    property var    flyArea
24
    property var    masterController
25
    property var    polygon         ///< MissionItem associated with this editor
26 27
    property bool   readOnly            ///< true: read only view, false: full editing view
    property var    rootQgcView
28
    property int    _index
29 30 31 32 33 34

    signal clicked
    signal remove

    property var    _masterController:          masterController
    property var    _missionController:         _masterController.missionController
35
    property bool   _currentItem:               polygon.interactive
36 37 38 39 40 41 42
    property color  _outerTextColor:            _currentItem ? qgcPal.primaryButtonText : qgcPal.text
    property bool   _noMissionItemsAdded:       ListView.view.model.count === 1
    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:     descriptionLabel.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 66
    readonly property bool  _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly

    QGCPalette {
        id: qgcPal
        colorGroupEnabled: enabled
    }

    FocusScope {
        id:             currentItemScope
        anchors.fill:   parent

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


    QGCLabel {
        id:                     label
67
        anchors.verticalCenter: descriptionLabel.verticalCenter
68 69
        anchors.leftMargin:     _margin
        anchors.left:           parent.left
70
        text:                   index
71 72 73 74 75 76 77
        color:                  _outerTextColor
    }

    QGCColoredImage {
        id:                     hamburger
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
        anchors.right:          parent.right
78
        anchors.verticalCenter: descriptionLabel.verticalCenter
79 80 81 82
        width:                  _hamburgerSize
        height:                 _hamburgerSize
        sourceSize.height:      _hamburgerSize
        source:                 "qrc:/qmlimages/Hamburger.svg"
83
        visible:                _currentItem
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
        color:                  qgcPal.text
    }

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

        Menu {
            id: hamburgerMenu

            MenuItem {
                text:           qsTr("Insert Fly Area")
                onTriggered:    flyArea.appendFlyAreaPolygon()
            }
102

103 104 105 106
            MenuItem {
                text:           qsTr("Delete")
                onTriggered:    remove()
            }
107 108 109 110
            MenuItem {
                text:           qsTr("Copy Fly Area")
                //onTriggered:    //To Do
            }
111 112


113 114 115
        }
    }

116 117
    QGCLabel {
        id:                     descriptionLabel
118 119 120 121 122
        anchors.topMargin:      _margin / 2
        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth * 2
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
        anchors.left:           label.right
        anchors.top:            parent.top
123
        text:                   "Fly Area"
124 125
        verticalAlignment:      Text.AlignVCenter
        color:                  _outerTextColor
126 127 128 129 130 131 132 133
    }


    Loader {
        id:                 editorLoader
        anchors.leftMargin: _margin
        anchors.topMargin:  _margin
        anchors.left:       parent.left
134
        anchors.top:        descriptionLabel.bottom
135 136 137 138 139 140 141 142
        source:             "FlyAreaEditor.qml"
        visible:            _currentItem

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