CustomModeIndicator.qml 4.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/****************************************************************************
 *
 * (c) 2009-2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 * @file
 *   @author Gus Grubba <gus@auterion.com>
 */

12 13 14 15 16

import QtQuick                  2.11
import QtQuick.Controls         2.4
import QtQuick.Layouts          1.11
import QtQuick.Dialogs          1.3
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 45 46 47 48 49 50 51 52 53 54

import QGroundControl                       1.0
import QGroundControl.Controls              1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.Palette               1.0

//-------------------------------------------------------------------------
//-- Mode Indicator
Item {
    anchors.top:                    parent.top
    anchors.bottom:                 parent.bottom
    width:                          selectorRow.width

    Row {
        id:                         selectorRow
        spacing:                    ScreenTools.defaultFontPixelWidth
        anchors.verticalCenter:     parent.verticalCenter
        QGCLabel {
            id:                     flightModeSelector
            text:                   activeVehicle ? activeVehicle.flightMode : qsTr("N/A")
            color:                  qgcPal.text
            font.pointSize:         ScreenTools.defaultFontPointSize
            anchors.verticalCenter:     parent.verticalCenter
        }
        QGCColoredImage {
            anchors.verticalCenter: parent.verticalCenter
            height:                 ScreenTools.defaultFontPixelHeight * 0.5
            width:                  height
            sourceSize.height:      parent.height
            fillMode:               Image.PreserveAspectFit
            source:                 "/res/DropArrow.svg"
            color:                  qgcPal.text
        }
    }
    MouseArea {
        visible:        activeVehicle && activeVehicle.flightModeSetAvailable
        anchors.fill:   parent
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
        onClicked:      flightModesMenu.open()
    }
    //-------------------------------------------------------------------------
    //-- Flight Modes
    Popup {
        id:                     flightModesMenu
        width:                  Math.min(mainWindow.width * 0.666, ScreenTools.defaultFontPixelWidth * 40)
        height:                 mainWindow.height * 0.5
        modal:                  true
        focus:                  true
        parent:                 Overlay.overlay
        x:                      Math.round((mainWindow.width  - width)  * 0.5)
        y:                      Math.round((mainWindow.height - height) * 0.5)
        closePolicy:            Popup.CloseOnEscape | Popup.CloseOnPressOutside
        property int selectedIndex: 0
        background: Rectangle {
            anchors.fill:       parent
            color:              qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
            border.color:       qgcPal.text
            radius:             ScreenTools.defaultFontPixelWidth
        }
Gus Grubba's avatar
Gus Grubba committed
76
        ColumnLayout {
77 78 79 80
            id:                 comboListCol
            spacing:            ScreenTools.defaultFontPixelHeight
            anchors.centerIn:   parent
            QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
81 82
                text:           qsTr("Flight Modes")
                Layout.alignment:  Qt.AlignHCenter
83 84 85 86 87
            }
            Repeater {
                model:          activeVehicle ? activeVehicle.flightModes : [ ]
                QGCButton {
                    text:       modelData
Gus Grubba's avatar
Gus Grubba committed
88 89 90 91 92
                    Layout.minimumHeight:   ScreenTools.defaultFontPixelHeight * 3
                    Layout.minimumWidth:    ScreenTools.defaultFontPixelWidth  * 30
                    Layout.fillHeight:      true
                    Layout.fillWidth:       true
                    Layout.alignment:       Qt.AlignHCenter
93 94 95 96 97 98 99
                    onClicked: {
                        activeVehicle.flightMode = modelData
                        flightModesMenu.close()
                    }
                }
            }
        }
100 101
    }
}