MultiVehicleList.qml 6.73 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

10 11 12
import QtQuick          2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts  1.2
13 14 15 16 17 18 19 20

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.FlightMap     1.0

21
Item {
Gus Grubba's avatar
Gus Grubba committed
22
    property var    guidedActionsController
23

24 25 26 27
    property real   _margin:        ScreenTools.defaultFontPixelWidth / 2
    property real   _widgetHeight:  ScreenTools.defaultFontPixelHeight * 3
    property color  _textColor:     "black"
    property real   _rectOpacity:   0.8
28

29
    QGCPalette { id: qgcPal }
30

31
    Rectangle {
32 33 34 35 36 37 38
        id:             mvCommands
        anchors.left:   parent.left
        anchors.right:  parent.right
        height:         mvCommandsColumn.height + (_margin *2)
        color:          qgcPal.missionItemEditor
        opacity:        _rectOpacity
        radius:         _margin
39

40 41 42 43
        DeadMouseArea {
            anchors.fill: parent
        }

44
        Column {
45
            id:                 mvCommandsColumn
46
            anchors.margins:    _margin
47
            anchors.top:        parent.top
48 49 50 51
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin

52
            QGCLabel {
53 54
                anchors.left:   parent.left
                anchors.right:  parent.right
55 56 57 58
                text:           qsTr("The following commands will be applied to all vehicles")
                color:          _textColor
                wrapMode:       Text.WordWrap
                font.pointSize: ScreenTools.smallFontPointSize
59 60 61
            }

            Row {
62
                spacing:            _margin
63 64

                QGCButton {
65 66
                    text:       "Pause"
                    onClicked:  guidedActionsController.confirmAction(guidedActionsController.actionMVPause)
67 68 69
                }

                QGCButton {
Gus Grubba's avatar
Gus Grubba committed
70
                    text:       "Start Mission"
71
                    onClicked:  guidedActionsController.confirmAction(guidedActionsController.actionMVStartMission)
72 73 74 75
                }
            }
        }
    }
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

    QGCListView {
        id:                 missionItemEditorListView
        anchors.left:       parent.left
        anchors.right:      parent.right
        anchors.topMargin:  _margin
        anchors.top:        mvCommands.bottom
        anchors.bottom:     parent.bottom
        spacing:            ScreenTools.defaultFontPixelHeight / 2
        orientation:        ListView.Vertical
        model:              QGroundControl.multiVehicleManager.vehicles
        cacheBuffer:        _cacheBuffer < 0 ? 0 : _cacheBuffer
        clip:               true

        property real _cacheBuffer:     height * 2

        delegate: Rectangle {
            width:      parent.width
            height:     innerColumn.y + innerColumn.height + _margin
            color:      qgcPal.missionItemEditor
            opacity:    _rectOpacity
            radius:     _margin

            property var    _vehicle:   object

            ColumnLayout {
                id:                 innerColumn
                anchors.margins:    _margin
                anchors.top:        parent.top
                anchors.left:       parent.left
                anchors.right:      parent.left
                spacing:            _margin

                RowLayout {
110
                    Layout.fillWidth:       true
111 112 113

                    QGCLabel {
                        Layout.alignment:   Qt.AlignTop
Gus Grubba's avatar
Gus Grubba committed
114
                        text:               _vehicle ? _vehicle.id : ""
115 116 117 118 119 120 121 122
                        color:              _textColor
                    }

                    ColumnLayout {
                        Layout.alignment:   Qt.AlignCenter
                        spacing:            _margin

                        FlightModeMenu {
123
                            Layout.alignment:           Qt.AlignHCenter
124 125
                            font.pointSize:             ScreenTools.largeFontPointSize
                            color:                      _textColor
126
                            currentVehicle:             _vehicle
127 128 129
                        }

                        QGCLabel {
130
                            Layout.alignment:           Qt.AlignHCenter
Gus Grubba's avatar
Gus Grubba committed
131
                            text:                       _vehicle && _vehicle.armed ? qsTr("Armed") : qsTr("Disarmed")
132 133 134 135 136 137
                            color:                      _textColor
                        }
                    }

                    QGCCompassWidget {
                        size:       _widgetHeight
138
                        usedByMultipleVehicleList: true
139 140 141 142 143 144 145 146 147 148 149 150 151 152
                        vehicle:    _vehicle
                    }

                    QGCAttitudeWidget {
                        size:       _widgetHeight
                        vehicle:    _vehicle
                    }
                } // RowLayout

                Row {
                    spacing: ScreenTools.defaultFontPixelWidth

                    QGCButton {
                        text:       "Arm"
Gus Grubba's avatar
Gus Grubba committed
153
                        visible:    _vehicle && !_vehicle.armed
154 155 156 157 158
                        onClicked:  _vehicle.armed = true
                    }

                    QGCButton {
                        text:       "Start Mission"
Gus Grubba's avatar
Gus Grubba committed
159
                        visible:    _vehicle && _vehicle.armed && _vehicle.flightMode !== _vehicle.missionFlightMode
160 161 162 163 164
                        onClicked:  _vehicle.startMission()
                    }

                    QGCButton {
                        text:       "Pause"
Gus Grubba's avatar
Gus Grubba committed
165
                        visible:    _vehicle && _vehicle.armed && _vehicle.pauseVehicleSupported
166 167 168 169 170
                        onClicked:  _vehicle.pauseVehicle()
                    }

                    QGCButton {
                        text:       "RTL"
Gus Grubba's avatar
Gus Grubba committed
171
                        visible:    _vehicle && _vehicle.armed && _vehicle.flightMode !== _vehicle.rtlFlightMode
172 173 174 175 176
                        onClicked:  _vehicle.flightMode = _vehicle.rtlFlightMode
                    }

                    QGCButton {
                        text:       "Take control"
Gus Grubba's avatar
Gus Grubba committed
177
                        visible:    _vehicle && _vehicle.armed && _vehicle.flightMode !== _vehicle.takeControlFlightMode
178 179 180 181 182 183 184
                        onClicked:  _vehicle.flightMode = _vehicle.takeControlFlightMode
                    }
                } // Row
            } // ColumnLayout
        } // delegate - Rectangle
    } // QGCListView
} // Item