GPSIndicator.qml 4.86 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.
 *
 ****************************************************************************/

Gus Grubba's avatar
Gus Grubba committed
10 11
import QtQuick          2.11
import QtQuick.Layouts  1.11
12 13 14 15 16 17 18 19 20 21

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

//-------------------------------------------------------------------------
//-- GPS Indicator
Item {
22
    id:             _root
23 24 25 26
    width:          (gpsValuesColumn.x + gpsValuesColumn.width) * 1.1
    anchors.top:    parent.top
    anchors.bottom: parent.bottom

27 28
    property bool showIndicator: true

29 30
    property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
    Component {
        id: gpsInfo

        Rectangle {
            width:  gpsCol.width   + ScreenTools.defaultFontPixelWidth  * 3
            height: gpsCol.height  + ScreenTools.defaultFontPixelHeight * 2
            radius: ScreenTools.defaultFontPixelHeight * 0.5
            color:  qgcPal.window
            border.color:   qgcPal.text

            Column {
                id:                 gpsCol
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                width:              Math.max(gpsGrid.width, gpsLabel.width)
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent

                QGCLabel {
                    id:             gpsLabel
50
                    text:           (_activeVehicle && _activeVehicle.gps.count.value >= 0) ? qsTr("GPS Status") : qsTr("GPS Data Unavailable")
51 52 53 54 55 56
                    font.family:    ScreenTools.demiboldFontFamily
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                GridLayout {
                    id:                 gpsGrid
57
                    visible:            (_activeVehicle && _activeVehicle.gps.count.value >= 0)
58 59 60 61 62 63
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter: parent.horizontalCenter
                    columns: 2

                    QGCLabel { text: qsTr("GPS Count:") }
64
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.count.valueString : qsTr("N/A", "No data to display") }
65
                    QGCLabel { text: qsTr("GPS Lock:") }
66
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.lock.enumStringValue : qsTr("N/A", "No data to display") }
67
                    QGCLabel { text: qsTr("HDOP:") }
68
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.hdop.valueString : qsTr("--.--", "No data to display") }
69
                    QGCLabel { text: qsTr("VDOP:") }
70
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.vdop.valueString : qsTr("--.--", "No data to display") }
71
                    QGCLabel { text: qsTr("Course Over Ground:") }
72
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.courseOverGround.valueString : qsTr("--.--", "No data to display") }
73 74 75 76 77 78 79 80 81 82 83 84 85
                }
            }
        }
    }

    QGCColoredImage {
        id:                 gpsIcon
        width:              height
        anchors.top:        parent.top
        anchors.bottom:     parent.bottom
        source:             "/qmlimages/Gps.svg"
        fillMode:           Image.PreserveAspectFit
        sourceSize.height:  height
86
        opacity:            (_activeVehicle && _activeVehicle.gps.count.value >= 0) ? 1 : 0.5
87 88 89 90 91 92 93 94 95 96 97
        color:              qgcPal.buttonText
    }

    Column {
        id:                     gpsValuesColumn
        anchors.verticalCenter: parent.verticalCenter
        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth / 2
        anchors.left:           gpsIcon.right

        QGCLabel {
            anchors.horizontalCenter:   hdopValue.horizontalCenter
98
            visible:                    _activeVehicle && !isNaN(_activeVehicle.gps.hdop.value)
99
            color:                      qgcPal.buttonText
100
            text:                       _activeVehicle ? _activeVehicle.gps.count.valueString : ""
101 102 103 104
        }

        QGCLabel {
            id:         hdopValue
105
            visible:    _activeVehicle && !isNaN(_activeVehicle.gps.hdop.value)
106
            color:      qgcPal.buttonText
107
            text:       _activeVehicle ? _activeVehicle.gps.hdop.value.toFixed(1) : ""
108 109
        }
    }
110

111 112 113
    MouseArea {
        anchors.fill:   parent
        onClicked: {
114
            mainWindow.showIndicatorPopup(_root, gpsInfo)
115 116 117
        }
    }
}