MainToolBarIndicators.qml 23.4 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 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.
 *
 ****************************************************************************/
dogmaphobic's avatar
dogmaphobic committed
9 10


Don Gagne's avatar
Don Gagne committed
11 12 13
import QtQuick          2.5
import QtQuick.Controls 1.2
import QtQuick.Layouts  1.2
dogmaphobic's avatar
dogmaphobic committed
14

Don Gagne's avatar
Don Gagne committed
15 16 17 18 19
import QGroundControl                       1.0
import QGroundControl.Controls              1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.Palette               1.0
dogmaphobic's avatar
dogmaphobic committed
20

Don Gagne's avatar
Don Gagne committed
21 22 23
Item {
    property var  _activeVehicle:        QGroundControl.multiVehicleManager.activeVehicle
    property bool _communicationLost:   _activeVehicle ? _activeVehicle.connectionLost : false
dogmaphobic's avatar
dogmaphobic committed
24

Don Gagne's avatar
Don Gagne committed
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
    QGCPalette { id: qgcPal }

    function getBatteryColor() {
        if(_activeVehicle) {
            if(_activeVehicle.battery.percentRemaining.value > 75) {
                return qgcPal.text
            }
            if(_activeVehicle.battery.percentRemaining.value > 50) {
                return colorOrange
            }
            if(_activeVehicle.battery.percentRemaining.value > 0.1) {
                return colorRed
            }
        }
        return colorGrey
    }

    function getRSSIColor(value) {
        if(value >= 0)
            return colorGrey;
        if(value > -60)
            return colorGreen;
        if(value > -90)
            return colorOrange;
        return colorRed;
    }

dogmaphobic's avatar
dogmaphobic committed
52
    function getMessageColor() {
Don Gagne's avatar
Don Gagne committed
53 54
        if (_activeVehicle) {
            if (_activeVehicle.messageTypeNone)
55
                return colorGrey
Don Gagne's avatar
Don Gagne committed
56
            if (_activeVehicle.messageTypeNormal)
57
                return colorBlue;
Don Gagne's avatar
Don Gagne committed
58
            if (_activeVehicle.messageTypeWarning)
59
                return colorOrange;
Don Gagne's avatar
Don Gagne committed
60
            if (_activeVehicle.messageTypeError)
61
                return colorRed;
62 63 64
            // Cannot be so make make it obnoxious to show error
            console.log("Invalid vehicle message type")
            return "purple";
65
        }
66 67
        //-- It can only get here when closing (vehicle gone while window active)
        return "white";
dogmaphobic's avatar
dogmaphobic committed
68 69 70
    }

    function getBatteryVoltageText() {
Don Gagne's avatar
Don Gagne committed
71 72
        if (_activeVehicle.battery.voltage.value >= 0) {
            return _activeVehicle.battery.voltage.valueString + _activeVehicle.battery.voltage.units
dogmaphobic's avatar
dogmaphobic committed
73 74 75 76 77
        }
        return 'N/A';
    }

    function getBatteryPercentageText() {
Don Gagne's avatar
Don Gagne committed
78 79
        if(_activeVehicle) {
            if(_activeVehicle.battery.percentRemaining.value > 98.9) {
80 81
                return "100%"
            }
Don Gagne's avatar
Don Gagne committed
82 83
            if(_activeVehicle.battery.percentRemaining.value > 0.1) {
                return _activeVehicle.battery.percentRemaining.valueString + _activeVehicle.battery.percentRemaining.units
84
            }
Don Gagne's avatar
Don Gagne committed
85 86
            if(_activeVehicle.battery.voltage.value >= 0) {
                return _activeVehicle.battery.voltage.valueString + _activeVehicle.battery.voltage.units
87
            }
dogmaphobic's avatar
dogmaphobic committed
88 89 90 91
        }
        return "N/A"
    }

Don Gagne's avatar
Don Gagne committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
    //---------------------------------------------
    // GPS Info
    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
                    text:           (_activeVehicle && _activeVehicle.gps.count.value >= 0) ? qsTr("GPS Status") : qsTr("GPS Data Unavailable")
                    font.family:    ScreenTools.demiboldFontFamily
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                GridLayout {
                    id:                 gpsGrid
                    visible:            (_activeVehicle && _activeVehicle.gps.count.value >= 0)
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter: parent.horizontalCenter
                    columns: 2

                    QGCLabel { text: qsTr("GPS Count:") }
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.count.valueString : qsTr("N/A", "No data to display") }
                    QGCLabel { text: qsTr("GPS Lock:") }
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.lock.enumStringValue : qsTr("N/A", "No data to display") }
                    QGCLabel { text: qsTr("HDOP:") }
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.hdop.valueString : qsTr("--.--", "No data to display") }
                    QGCLabel { text: qsTr("VDOP:") }
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.vdop.valueString : qsTr("--.--", "No data to display") }
                    QGCLabel { text: qsTr("Course Over Ground:") }
                    QGCLabel { text: _activeVehicle ? _activeVehicle.gps.courseOverGround.valueString : qsTr("--.--", "No data to display") }
                }
            }

            Component.onCompleted: {
                var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
                x = pos.x
                y = pos.y + ScreenTools.defaultFontPixelHeight
            }
        }
    }

    //---------------------------------------------
    // Battery Info
    Component {
        id: batteryInfo

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

            Column {
                id:                 battCol
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                width:              Math.max(battGrid.width, battLabel.width)
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent

                QGCLabel {
                    id:             battLabel
                    text:           qsTr("Battery Status")
                    font.family:    ScreenTools.demiboldFontFamily
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                GridLayout {
                    id:                 battGrid
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    columns:            2
                    anchors.horizontalCenter: parent.horizontalCenter

                    QGCLabel { text: qsTr("Voltage:") }
                    QGCLabel { text: (_activeVehicle && _activeVehicle.battery.voltage.value != -1) ? (_activeVehicle.battery.voltage.valueString + " " + _activeVehicle.battery.voltage.units) : "N/A" }
                    QGCLabel { text: qsTr("Accumulated Consumption:") }
                    QGCLabel { text: (_activeVehicle && _activeVehicle.battery.mahConsumed.value != -1) ? (_activeVehicle.battery.mahConsumed.valueString + " " + _activeVehicle.battery.mahConsumed.units) : "N/A" }
                }
            }

            Component.onCompleted: {
                var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
                x = pos.x
                y = pos.y + ScreenTools.defaultFontPixelHeight
            }
        }
    }

    //---------------------------------------------
    // RC RSSI Info
    Component {
        id: rcRSSIInfo

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

            Column {
                id:                 rcrssiCol
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                width:              Math.max(rcrssiGrid.width, rssiLabel.width)
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent

                QGCLabel {
                    id:             rssiLabel
                    text:           _activeVehicle ? (_activeVehicle.rcRSSI != 255 ? qsTr("RC RSSI Status") : qsTr("RC RSSI Data Unavailable")) : qsTr("N/A", "No data available")
                    font.family:    ScreenTools.demiboldFontFamily
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                GridLayout {
                    id:                 rcrssiGrid
                    visible:            _activeVehicle && _activeVehicle.rcRSSI != 255
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    columns:            2
                    anchors.horizontalCenter: parent.horizontalCenter

                    QGCLabel { text: qsTr("RSSI:") }
                    QGCLabel { text: _activeVehicle ? (_activeVehicle.rcRSSI + "%") : 0 }
                }
            }

            Component.onCompleted: {
                var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
                x = pos.x
                y = pos.y + ScreenTools.defaultFontPixelHeight
            }
        }
    }

    //---------------------------------------------
    // Telemetry RSSI Info
    Component {
        id: telemRSSIInfo

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

            Column {
                id:                 telemCol
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                width:              Math.max(telemGrid.width, telemLabel.width)
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent

                QGCLabel {
                    id:             telemLabel
                    text:           qsTr("Telemetry RSSI Status")
                    font.family:    ScreenTools.demiboldFontFamily
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                GridLayout {
                    id:                 telemGrid
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    columns:            2
                    anchors.horizontalCenter: parent.horizontalCenter

                    QGCLabel { text: qsTr("Local RSSI:") }
Gus Grubba's avatar
Gus Grubba committed
276
                    QGCLabel { text: _activeVehicle.telemetryLRSSI + " dBm" }
Don Gagne's avatar
Don Gagne committed
277
                    QGCLabel { text: qsTr("Remote RSSI:") }
Gus Grubba's avatar
Gus Grubba committed
278
                    QGCLabel { text: _activeVehicle.telemetryRRSSI + " dBm" }
Don Gagne's avatar
Don Gagne committed
279
                    QGCLabel { text: qsTr("RX Errors:") }
Gus Grubba's avatar
Gus Grubba committed
280
                    QGCLabel { text: _activeVehicle.telemetryRXErrors }
Don Gagne's avatar
Don Gagne committed
281
                    QGCLabel { text: qsTr("Errors Fixed:") }
Gus Grubba's avatar
Gus Grubba committed
282
                    QGCLabel { text: _activeVehicle.telemetryFixed }
Don Gagne's avatar
Don Gagne committed
283
                    QGCLabel { text: qsTr("TX Buffer:") }
Gus Grubba's avatar
Gus Grubba committed
284
                    QGCLabel { text: _activeVehicle.telemetryTXBuffer }
Don Gagne's avatar
Don Gagne committed
285
                    QGCLabel { text: qsTr("Local Noise:") }
Gus Grubba's avatar
Gus Grubba committed
286
                    QGCLabel { text: _activeVehicle.telemetryLNoise }
Don Gagne's avatar
Don Gagne committed
287
                    QGCLabel { text: qsTr("Remote Noise:") }
Gus Grubba's avatar
Gus Grubba committed
288
                    QGCLabel { text: _activeVehicle.telemetryRNoise }
Don Gagne's avatar
Don Gagne committed
289 290
                }
            }
dogmaphobic's avatar
dogmaphobic committed
291

Don Gagne's avatar
Don Gagne committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305
            Component.onCompleted: {
                var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
                x = pos.x
                y = pos.y + ScreenTools.defaultFontPixelHeight
            }
        }
    }

    Row {
        id:             indicatorRow
        anchors.top:    parent.top
        anchors.bottom: parent.bottom
        spacing:        ScreenTools.defaultFontPixelWidth * 1.5
        visible:        !_communicationLost
306

Don Gagne's avatar
Don Gagne committed
307 308 309
        //-------------------------------------------------------------------------
        //-- Message Indicator
        Item {
Don Gagne's avatar
Don Gagne committed
310 311 312 313 314 315 316 317
            id:             messages
            width:          height
            anchors.top:    parent.top
            anchors.bottom: parent.bottom
            visible:        _activeVehicle && _activeVehicle.messageCount

            Image {
                id:                 criticalMessageIcon
Don Gagne's avatar
Don Gagne committed
318
                anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
319 320 321 322
                source:             "/qmlimages/Yield.svg"
                sourceSize.height:  height
                fillMode:           Image.PreserveAspectFit
                cache:              false
Don Gagne's avatar
Don Gagne committed
323
                visible:            _activeVehicle && _activeVehicle.messageCount > 0 && isMessageImportant
dogmaphobic's avatar
dogmaphobic committed
324
            }
Don Gagne's avatar
Don Gagne committed
325 326

            QGCColoredImage {
Don Gagne's avatar
Don Gagne committed
327
                anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
328 329 330 331 332
                source:             "/qmlimages/Megaphone.svg"
                sourceSize.height:  height
                fillMode:           Image.PreserveAspectFit
                color:              getMessageColor()
                visible:            !criticalMessageIcon.visible
dogmaphobic's avatar
dogmaphobic committed
333
            }
Don Gagne's avatar
Don Gagne committed
334

Don Gagne's avatar
Don Gagne committed
335
            MouseArea {
Don Gagne's avatar
Don Gagne committed
336 337
                anchors.fill:   parent
                onClicked:      mainWindow.showMessageArea()
dogmaphobic's avatar
dogmaphobic committed
338 339
            }
        }
dogmaphobic's avatar
dogmaphobic committed
340

Don Gagne's avatar
Don Gagne committed
341 342 343
        //-------------------------------------------------------------------------
        //-- GPS Indicator
        Item {
Don Gagne's avatar
Don Gagne committed
344 345 346 347
            id:             satelitte
            width:          (gpsValuesColumn.x + gpsValuesColumn.width) * 1.1
            anchors.top:    parent.top
            anchors.bottom: parent.bottom
Don Gagne's avatar
Don Gagne committed
348

349
            QGCColoredImage {
Don Gagne's avatar
Don Gagne committed
350 351 352 353 354 355 356 357 358
                id:                 gpsIcon
                width:              height
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                source:             "/qmlimages/Gps.svg"
                fillMode:           Image.PreserveAspectFit
                sourceSize.height:  height
                opacity:            (_activeVehicle && _activeVehicle.gps.count.value >= 0) ? 1 : 0.5
                color:              qgcPal.buttonText
dogmaphobic's avatar
dogmaphobic committed
359
            }
Don Gagne's avatar
Don Gagne committed
360 361 362

            Column {
                id:                     gpsValuesColumn
dogmaphobic's avatar
dogmaphobic committed
363
                anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
364 365 366 367
                anchors.leftMargin:     ScreenTools.defaultFontPixelWidth / 2
                anchors.left:           gpsIcon.right

                QGCLabel {
Don Gagne's avatar
Don Gagne committed
368 369 370 371
                    anchors.horizontalCenter:   hdopValue.horizontalCenter
                    visible:                    _activeVehicle && !isNaN(_activeVehicle.gps.hdop.value)
                    color:                      qgcPal.buttonText
                    text:                       _activeVehicle ? _activeVehicle.gps.count.valueString : ""
Don Gagne's avatar
Don Gagne committed
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
                }

                QGCLabel {
                    id:         hdopValue
                    visible:    _activeVehicle && !isNaN(_activeVehicle.gps.hdop.value)
                    color:      qgcPal.buttonText
                    text:       _activeVehicle ? _activeVehicle.gps.hdop.value.toFixed(1) : ""
                }
            } // Column

            MouseArea {
                anchors.fill:   parent
                onClicked: {
                    var centerX = mapToItem(toolBar, x, y).x + (width / 2)
                    mainWindow.showPopUp(gpsInfo, centerX)
                }
dogmaphobic's avatar
dogmaphobic committed
388 389 390
            }
        }

Don Gagne's avatar
Don Gagne committed
391 392 393
        //-------------------------------------------------------------------------
        //-- RC RSSI
        Item {
Don Gagne's avatar
Don Gagne committed
394 395 396 397 398 399
            id:             rcRssi
            width:          rssiRow.width * 1.1
            anchors.top:    parent.top
            anchors.bottom: parent.bottom
            visible:        _activeVehicle ? _activeVehicle.supportsRadio : true

Don Gagne's avatar
Don Gagne committed
400
            Row {
Don Gagne's avatar
Don Gagne committed
401 402 403 404 405
                id:             rssiRow
                anchors.top:    parent.top
                anchors.bottom: parent.bottom
                spacing:        ScreenTools.defaultFontPixelWidth

Don Gagne's avatar
Don Gagne committed
406
                QGCColoredImage {
Don Gagne's avatar
Don Gagne committed
407 408 409 410 411 412 413 414
                    width:              height
                    anchors.top:        parent.top
                    anchors.bottom:     parent.bottom
                    sourceSize.height:  height
                    source:             "/qmlimages/RC.svg"
                    fillMode:           Image.PreserveAspectFit
                    opacity:            _activeVehicle ? (((_activeVehicle.rcRSSI < 0) || (_activeVehicle.rcRSSI > 100)) ? 0.5 : 1) : 0.5
                    color:              qgcPal.buttonText
Don Gagne's avatar
Don Gagne committed
415
                }
Don Gagne's avatar
Don Gagne committed
416

Don Gagne's avatar
Don Gagne committed
417 418
                SignalStrength {
                    anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
419 420
                    size:                   parent.height * 0.5
                    percent:                _activeVehicle ? ((_activeVehicle.rcRSSI > 100) ? 0 : _activeVehicle.rcRSSI) : 0
Don Gagne's avatar
Don Gagne committed
421 422
                }
            }
Don Gagne's avatar
Don Gagne committed
423

Don Gagne's avatar
Don Gagne committed
424 425
            MouseArea {
                anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
426

Don Gagne's avatar
Don Gagne committed
427 428 429 430
                onClicked: {
                    var centerX = mapToItem(toolBar, x, y).x + (width / 2)
                    mainWindow.showPopUp(rcRSSIInfo, centerX)
                }
dogmaphobic's avatar
dogmaphobic committed
431 432 433
            }
        }

Don Gagne's avatar
Don Gagne committed
434 435
        //-------------------------------------------------------------------------
        //-- Telemetry RSSI
Don Gagne's avatar
Don Gagne committed
436 437 438 439 440 441 442
        QGCColoredImage {
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
            sourceSize.height:  height
            source:             "/qmlimages/TelemRSSI.svg"
            fillMode:           Image.PreserveAspectFit
            color:              qgcPal.buttonText
Gus Grubba's avatar
Gus Grubba committed
443
            visible:            _activeVehicle ? (_activeVehicle.telemetryLRSSI < 0) : false
Don Gagne's avatar
Don Gagne committed
444

Don Gagne's avatar
Don Gagne committed
445
            MouseArea {
Don Gagne's avatar
Don Gagne committed
446 447
                anchors.fill: parent

Don Gagne's avatar
Don Gagne committed
448
                onClicked: {
Don Gagne's avatar
Don Gagne committed
449
                    var centerX = mapToItem(toolBar, x, y).x + (width / 2)
Don Gagne's avatar
Don Gagne committed
450
                    mainWindow.showPopUp(telemRSSIInfo, centerX)
Don Gagne's avatar
Don Gagne committed
451
                }
dogmaphobic's avatar
dogmaphobic committed
452 453 454
            }
        }

Don Gagne's avatar
Don Gagne committed
455 456 457
        //-------------------------------------------------------------------------
        //-- Battery Indicator
        Item {
Don Gagne's avatar
Don Gagne committed
458 459 460 461
            anchors.top:    parent.top
            anchors.bottom: parent.bottom
            width:          batteryIndicatorRow.width

Don Gagne's avatar
Don Gagne committed
462
            Row {
Don Gagne's avatar
Don Gagne committed
463 464 465 466 467
                id:             batteryIndicatorRow
                anchors.top:    parent.top
                anchors.bottom: parent.bottom
                opacity:        (_activeVehicle && _activeVehicle.battery.voltage.value >= 0) ? 1 : 0.5

Don Gagne's avatar
Don Gagne committed
468
                QGCColoredImage {
Don Gagne's avatar
Don Gagne committed
469 470 471 472 473 474 475
                    anchors.top:        parent.top
                    anchors.bottom:     parent.bottom
                    width:              height
                    sourceSize.width:   width
                    source:             "/qmlimages/Battery.svg"
                    fillMode:           Image.PreserveAspectFit
                    color:              qgcPal.text
Don Gagne's avatar
Don Gagne committed
476
                }
Don Gagne's avatar
Don Gagne committed
477

Don Gagne's avatar
Don Gagne committed
478
                QGCLabel {
Don Gagne's avatar
Don Gagne committed
479 480 481
                    text:                   getBatteryPercentageText()
                    font.pointSize:         ScreenTools.mediumFontPointSize
                    color:                  getBatteryColor()
Don Gagne's avatar
Don Gagne committed
482 483
                    anchors.verticalCenter: parent.verticalCenter
                }
dogmaphobic's avatar
dogmaphobic committed
484 485
            }

Don Gagne's avatar
Don Gagne committed
486 487 488
            MouseArea {
                anchors.fill:   parent
                onClicked:      mainWindow.showPopUp(batteryInfo, mapToItem(toolBar, x, y).x + (width / 2))
dogmaphobic's avatar
dogmaphobic committed
489 490 491
            }
        }

Don Gagne's avatar
Don Gagne committed
492 493 494 495 496 497 498 499
        //-------------------------------------------------------------------------
        //-- Mode Selector
        QGCLabel {
            id:                     flightModeSelector
            text:                   _activeVehicle ? _activeVehicle.flightMode : qsTr("N/A", "No data to display")
            font.pointSize:         ScreenTools.mediumFontPointSize
            color:                  qgcPal.buttonText
            anchors.verticalCenter: parent.verticalCenter
500

Don Gagne's avatar
Don Gagne committed
501 502
            Menu {
                id: flightModesMenu
dogmaphobic's avatar
dogmaphobic committed
503 504
            }

Don Gagne's avatar
Don Gagne committed
505 506
            Component {
                id: flightModeMenuItemComponent
dogmaphobic's avatar
dogmaphobic committed
507

Don Gagne's avatar
Don Gagne committed
508 509
                MenuItem {
                    onTriggered: _activeVehicle.flightMode = text
510
                }
dogmaphobic's avatar
dogmaphobic committed
511 512
            }

Don Gagne's avatar
Don Gagne committed
513
            property var flightModesMenuItems: []
dogmaphobic's avatar
dogmaphobic committed
514

Don Gagne's avatar
Don Gagne committed
515 516 517 518 519 520 521 522 523 524 525 526 527
            function updateFlightModesMenu() {
                if (_activeVehicle && _activeVehicle.flightModeSetAvailable) {
                    // Remove old menu items
                    for (var i = 0; i < flightModesMenuItems.length; i++) {
                        flightModesMenu.removeItem(flightModesMenuItems[i])
                    }
                    flightModesMenuItems.length = 0
                    // Add new items
                    for (var i = 0; i < _activeVehicle.flightModes.length; i++) {
                        var menuItem = flightModeMenuItemComponent.createObject(null, { "text": _activeVehicle.flightModes[i] })
                        flightModesMenuItems.push(menuItem)
                        flightModesMenu.insertItem(i, menuItem)
                    }
dogmaphobic's avatar
dogmaphobic committed
528 529 530
                }
            }

Don Gagne's avatar
Don Gagne committed
531
            Component.onCompleted: flightModeSelector.updateFlightModesMenu()
dogmaphobic's avatar
dogmaphobic committed
532

Don Gagne's avatar
Don Gagne committed
533 534 535 536
            Connections {
                target:                 QGroundControl.multiVehicleManager
                onActiveVehicleChanged: flightModeSelector.updateFlightModesMenu()
            }
dogmaphobic's avatar
dogmaphobic committed
537

Don Gagne's avatar
Don Gagne committed
538 539 540 541
            MouseArea {
                visible:        _activeVehicle && _activeVehicle.flightModeSetAvailable
                anchors.fill:   parent
                onClicked:      flightModesMenu.popup()
dogmaphobic's avatar
dogmaphobic committed
542
            }
Don Gagne's avatar
Don Gagne committed
543 544 545 546 547 548 549 550 551 552
        } // QGCLabel - Flight mode selector
    } // Row - Vehicle indicators

    Image {
        anchors.right:          parent.right
        anchors.top:            parent.top
        anchors.bottom:         parent.bottom
        visible:                x > indicatorRow.width && !_communicationLost
        fillMode:               Image.PreserveAspectFit
        source:                 _activeVehicle ? _activeVehicle.brandImage : ""
dogmaphobic's avatar
dogmaphobic committed
553
    }
dogmaphobic's avatar
dogmaphobic committed
554

Don Gagne's avatar
Don Gagne committed
555 556 557 558 559 560 561 562 563 564 565 566 567
    Row {
        anchors.fill:       parent
        layoutDirection:    Qt.RightToLeft
        spacing:            ScreenTools.defaultFontPixelWidth
        visible:            _communicationLost

        QGCButton {
            id:                     disconnectButton
            anchors.verticalCenter: parent.verticalCenter
            text:                   qsTr("Disconnect")
            primary:                true
            onClicked:              _activeVehicle.disconnectInactiveVehicle()
        }
dogmaphobic's avatar
dogmaphobic committed
568

Don Gagne's avatar
Don Gagne committed
569 570 571 572 573 574 575 576 577 578
        QGCLabel {
            id:                     connectionLost
            anchors.verticalCenter: parent.verticalCenter
            text:                   qsTr("COMMUNICATION LOST")
            font.pointSize:         ScreenTools.largeFontPointSize
            font.family:            ScreenTools.demiboldFontFamily
            color:                  colorRed
        }
    } // Row - Communication lost
} // Item