MainToolBar.qml 29.1 KB
Newer Older
dogmaphobic's avatar
dogmaphobic committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QGROUNDCONTROL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief QGC Main Tool Bar
 *   @author Gus Grubba <mavlink@grubba.com>
 */

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2

import QGroundControl.Controls 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.MainToolBar 1.0
38
import QGroundControl.MavManager 1.0
39
import QGroundControl.ScreenTools 1.0
dogmaphobic's avatar
dogmaphobic committed
40 41

Rectangle {
dogmaphobic's avatar
dogmaphobic committed
42
    id: toolBarHolder
dogmaphobic's avatar
dogmaphobic committed
43 44

    property var qgcPal: QGCPalette { id: palette; colorGroupEnabled: true }
45

46
    property int cellSpacerSize: ScreenTools.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4)
dogmaphobic's avatar
dogmaphobic committed
47
    property int cellHeight:     getProportionalDimmension(30)
dogmaphobic's avatar
dogmaphobic committed
48

dogmaphobic's avatar
dogmaphobic committed
49
    property var colorBlue:       "#1a6eaa"
dogmaphobic's avatar
dogmaphobic committed
50 51
    property var colorGreen:      "#329147"
    property var colorRed:        "#942324"
dogmaphobic's avatar
dogmaphobic committed
52 53
    property var colorOrange:     "#a76f26"
    property var colorWhite:      "#f0f0f0"
dogmaphobic's avatar
dogmaphobic committed
54

55 56 57 58 59
    property var colorOrangeText: (qgcPal.globalTheme === QGCPalette.Light) ? "#b75711" : "#ea8225"
    property var colorRedText:    (qgcPal.globalTheme === QGCPalette.Light) ? "#ee1112" : "#ef2526"
    property var colorGreenText:  (qgcPal.globalTheme === QGCPalette.Light) ? "#046b1b" : "#00d930"
    property var colorWhiteText:  (qgcPal.globalTheme === QGCPalette.Light) ? "#343333" : "#f0f0f0"

60
    color:  qgcPal.windowShade
dogmaphobic's avatar
dogmaphobic committed
61

dogmaphobic's avatar
dogmaphobic committed
62 63 64 65
    function getProportionalDimmension(val) {
        return toolBarHolder.height * val / 40
    }

dogmaphobic's avatar
dogmaphobic committed
66
    function getMessageColor() {
67
        if(MavManager.messageType === MavManager.MessageNone)
dogmaphobic's avatar
dogmaphobic committed
68
            return qgcPal.button;
69
        if(MavManager.messageType === MavManager.MessageNormal)
dogmaphobic's avatar
dogmaphobic committed
70
            return colorBlue;
71
        if(MavManager.messageType === MavManager.MessageWarning)
dogmaphobic's avatar
dogmaphobic committed
72
            return colorOrange;
73
        if(MavManager.messageType === MavManager.MessageError)
dogmaphobic's avatar
dogmaphobic committed
74 75 76 77 78 79
            return colorRed;
        // Cannot be so make make it obnoxious to show error
        return "purple";
    }

    function getMessageIcon() {
80
        if(MavManager.messageType === MavManager.MessageNormal || MavManager.messageType === MavManager.MessageNone)
Don Gagne's avatar
Don Gagne committed
81
            return "qrc:/res/Megaphone";
dogmaphobic's avatar
dogmaphobic committed
82
        else
Don Gagne's avatar
Don Gagne committed
83
            return "qrc:/res/Yield";
dogmaphobic's avatar
dogmaphobic committed
84 85 86
    }

    function getBatteryIcon() {
87
        if(MavManager.batteryPercent < 20.0)
Don Gagne's avatar
Don Gagne committed
88
            return "qrc:/res/Battery_0";
89
        else if(MavManager.batteryPercent < 40.0)
Don Gagne's avatar
Don Gagne committed
90
            return "qrc:/res/Battery_20";
91
        else if(MavManager.batteryPercent < 60.0)
Don Gagne's avatar
Don Gagne committed
92
            return "qrc:/res/Battery_40";
93
        else if(MavManager.batteryPercent < 80.0)
Don Gagne's avatar
Don Gagne committed
94
            return "qrc:/res/Battery_60";
95
        else if(MavManager.batteryPercent < 90.0)
Don Gagne's avatar
Don Gagne committed
96
            return "qrc:/res/Battery_80";
dogmaphobic's avatar
dogmaphobic committed
97
        else
Don Gagne's avatar
Don Gagne committed
98
            return "qrc:/res/Battery_100";
dogmaphobic's avatar
dogmaphobic committed
99 100
    }

dogmaphobic's avatar
dogmaphobic committed
101
    function getBatteryColor() {
102
        if (MavManager.batteryPercent > 40.0)
dogmaphobic's avatar
dogmaphobic committed
103
            return colorGreen;
104
        if(MavManager.batteryPercent > 0.01)
dogmaphobic's avatar
dogmaphobic committed
105 106 107 108 109 110 111
            return colorRed;
        // This means there is no battery level data
        return colorBlue;
    }

    function getSatelliteColor() {
        // No GPS data
112
        if (MavManager.satelliteCount < 0)
dogmaphobic's avatar
dogmaphobic committed
113 114
            return qgcPal.button
        // No Lock
115
        if(MavManager.satelliteLock < 2)
dogmaphobic's avatar
dogmaphobic committed
116 117
            return colorRed;
        // 2D Lock
118
        if(MavManager.satelliteLock === 2)
dogmaphobic's avatar
dogmaphobic committed
119 120 121 122 123
            return colorBlue;
        // Lock is 3D or more
        return colorGreen;
    }

124 125 126 127 128 129
    function getRSSIColor(value) {
        if(value < 10)
            return colorRed;
        if(value < 50)
            return colorOrange;
        return colorGreen;
130 131
    }

dogmaphobic's avatar
dogmaphobic committed
132
    function showMavStatus() {
133
         return (MavManager.mavPresent && MavManager.heartbeatTimeout === 0 && mainToolBar.connectionCount > 0);
dogmaphobic's avatar
dogmaphobic committed
134 135
    }

dogmaphobic's avatar
dogmaphobic committed
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
    //-------------------------------------------------------------------------
    //-- Main menu for Mobile Devices
    Menu {
        id: maintMenu
        ExclusiveGroup { id: mainMenuGroup }
        MenuItem {
            text: "Vehicle Setup"
            checkable:  true
            exclusiveGroup: mainMenuGroup
            checked: (mainToolBar.currentView === MainToolBar.ViewSetup)
            onTriggered:
            {
                mainToolBar.onSetupView();
            }
        }
        MenuItem {
            text: "Plan View"
            checkable:  true
            checked: (mainToolBar.currentView === MainToolBar.ViewPlan)
            exclusiveGroup: mainMenuGroup
            onTriggered:
            {
                mainToolBar.onPlanView();
            }
        }
        MenuItem {
            text: "Flight View"
            checkable: true
            checked: (mainToolBar.currentView === MainToolBar.ViewFly)
            exclusiveGroup: mainMenuGroup
            onTriggered:
            {
                mainToolBar.onFlyView();
            }
        }
        //-- Flight View Context Menu
        MenuItem {
            text: "Flight View Options..."
            visible: (mainToolBar.currentView === MainToolBar.ViewFly)
            onTriggered:
            {
                mainToolBar.onFlyViewMenu();
            }
        }
    }

dogmaphobic's avatar
dogmaphobic committed
182
    Row {
183 184 185
        id:                     row1
        height:                 cellHeight
        anchors.left:           parent.left
dogmaphobic's avatar
dogmaphobic committed
186
        spacing:                getProportionalDimmension(4)
dogmaphobic's avatar
dogmaphobic committed
187
        anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
188
        anchors.leftMargin:     getProportionalDimmension(10)
dogmaphobic's avatar
dogmaphobic committed
189

dogmaphobic's avatar
dogmaphobic committed
190 191
        //---------------------------------------------------------------------
        //-- Main menu for Non Mobile Devices (Chevron Buttons)
192 193 194
        Row {
            id:                     row11
            height:                 cellHeight
dogmaphobic's avatar
dogmaphobic committed
195
            spacing:                -getProportionalDimmension(12)
dogmaphobic's avatar
dogmaphobic committed
196
            anchors.verticalCenter: parent.verticalCenter
197
            visible:                !ScreenTools.isMobile
198
            Connections {
199
                target: ScreenTools
Don Gagne's avatar
Don Gagne committed
200
                onRepaintRequested: {
201 202 203
                    setupButton.repaintChevron   = true;
                    planButton.repaintChevron    = true;
                    flyButton.repaintChevron     = true;
204 205
                    analyzeButton.repaintChevron = true;
                }
dogmaphobic's avatar
dogmaphobic committed
206 207
            }

208 209 210 211
            ExclusiveGroup { id: mainActionGroup }

            QGCToolBarButton {
                id: setupButton
dogmaphobic's avatar
dogmaphobic committed
212
                width: getProportionalDimmension(90)
213 214
                height: cellHeight
                exclusiveGroup: mainActionGroup
215
                text: qsTr("Setup")
216 217 218 219 220 221
                anchors.verticalCenter: parent.verticalCenter
                checked: (mainToolBar.currentView === MainToolBar.ViewSetup)
                onClicked: {
                    mainToolBar.onSetupView();
                }
                z: 1000
dogmaphobic's avatar
dogmaphobic committed
222 223
            }

224 225
            QGCToolBarButton {
                id: planButton
dogmaphobic's avatar
dogmaphobic committed
226
                width: getProportionalDimmension(90)
227 228
                height: cellHeight
                exclusiveGroup: mainActionGroup
229
                text: qsTr("Plan")
230 231 232 233 234 235
                anchors.verticalCenter: parent.verticalCenter
                checked: (mainToolBar.currentView === MainToolBar.ViewPlan)
                onClicked: {
                    mainToolBar.onPlanView();
                }
                z: 900
dogmaphobic's avatar
dogmaphobic committed
236 237
            }

238 239
            QGCToolBarButton {
                id: flyButton
dogmaphobic's avatar
dogmaphobic committed
240
                width: getProportionalDimmension(90)
241 242
                height: cellHeight
                exclusiveGroup: mainActionGroup
243
                text: qsTr("Fly")
244 245 246 247 248 249 250 251 252 253
                anchors.verticalCenter: parent.verticalCenter
                checked: (mainToolBar.currentView === MainToolBar.ViewFly)
                onClicked: {
                    mainToolBar.onFlyView();
                }
                z: 800
            }

            QGCToolBarButton {
                id: analyzeButton
dogmaphobic's avatar
dogmaphobic committed
254
                width: getProportionalDimmension(90)
255 256
                height: cellHeight
                exclusiveGroup: mainActionGroup
257
                text: qsTr("Analyze")
258 259 260 261 262 263
                anchors.verticalCenter: parent.verticalCenter
                checked: (mainToolBar.currentView === MainToolBar.ViewAnalyze)
                onClicked: {
                    mainToolBar.onAnalyzeView();
                }
                z: 700
dogmaphobic's avatar
dogmaphobic committed
264 265 266 267
            }

        }

dogmaphobic's avatar
dogmaphobic committed
268 269
        //---------------------------------------------------------------------
        //-- Indicators
270 271 272 273
        Row {
            id:                     row12
            height:                 cellHeight
            spacing:                cellSpacerSize
dogmaphobic's avatar
dogmaphobic committed
274 275
            anchors.verticalCenter: parent.verticalCenter

dogmaphobic's avatar
dogmaphobic committed
276 277 278
            //-- "Hamburger" menu for Mobile Devices
            Item {
                id:         actionButton
279
                visible:    ScreenTools.isMobile
dogmaphobic's avatar
dogmaphobic committed
280 281 282 283 284
                height:     cellHeight
                width:      cellHeight
                Image {
                    id:             buttomImg
                    anchors.fill:   parent
285
                    source:         "/qmlimages/buttonMore.svg"
dogmaphobic's avatar
dogmaphobic committed
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
                    mipmap:         true
                    smooth:         true
                    antialiasing:   true
                    fillMode:       Image.PreserveAspectFit
                }
                MouseArea {
                    anchors.fill: parent
                    acceptedButtons: Qt.LeftButton
                    onClicked: {
                        if (mouse.button == Qt.LeftButton)
                        {
                            maintMenu.popup();
                        }
                    }
                }
            }

            //-- Separator if Hamburger menu is visible
            Rectangle {
                visible:    actionButton.visible
                height:     cellHeight
                width:      cellHeight
                color:      "#00000000"
                anchors.verticalCenter: parent.verticalCenter
            }

dogmaphobic's avatar
dogmaphobic committed
312
            Rectangle {
313
                id: messages
314
                width: (MavManager.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60)
315 316
                height: cellHeight
                visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages)
dogmaphobic's avatar
dogmaphobic committed
317
                anchors.verticalCenter: parent.verticalCenter
318 319 320 321 322 323 324 325
                color:  getMessageColor()
                border.color: "#00000000"
                border.width: 0
                property bool showTriangle: false

                Image {
                    id: messageIcon
                    source: getMessageIcon();
dogmaphobic's avatar
dogmaphobic committed
326
                    height: getProportionalDimmension(16)
327
                    fillMode: Image.PreserveAspectFit
dogmaphobic's avatar
dogmaphobic committed
328
                    anchors.verticalCenter: parent.verticalCenter
329
                    anchors.left: parent.left
330
                    anchors.leftMargin: getProportionalDimmension(8)
dogmaphobic's avatar
dogmaphobic committed
331 332
                }

dogmaphobic's avatar
dogmaphobic committed
333
                Item {
334 335 336 337
                    id: messageTextRect
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
                    width: messages.width - messageIcon.width
338
                    QGCLabel {
339
                        id: messageText
340
                        text: (MavManager.messageCount > 0) ? MavManager.messageCount : ''
Don Gagne's avatar
Don Gagne committed
341
                        font.pixelSize: ScreenTools.smallFontPixelSize
342 343 344 345 346 347 348
                        font.weight: Font.DemiBold
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.horizontalCenter: parent.horizontalCenter
                        horizontalAlignment: Text.AlignHCenter
                        color: colorWhite
                    }
                }
dogmaphobic's avatar
dogmaphobic committed
349

350 351
                Image {
                    id: dropDown
352
                    source: "/qmlimages/arrow-down.png"
353
                    visible: (messages.showTriangle) && (MavManager.messageCount > 0)
354 355
                    anchors.bottom: parent.bottom
                    anchors.right: parent.right
dogmaphobic's avatar
dogmaphobic committed
356 357
                    anchors.bottomMargin: getProportionalDimmension(3)
                    anchors.rightMargin:  getProportionalDimmension(3)
dogmaphobic's avatar
dogmaphobic committed
358 359
                }

360 361 362 363 364 365 366 367
                Timer {
                    id: mouseOffTimer
                    interval: 2000;
                    running: false;
                    repeat: false
                    onTriggered: {
                        messages.showTriangle = false;
                    }
dogmaphobic's avatar
dogmaphobic committed
368
                }
369 370 371 372 373 374 375 376 377

                MouseArea {
                    anchors.fill: parent
                    hoverEnabled: true
                    onEntered: {
                        messages.showTriangle = true;
                        mouseOffTimer.start();
                    }
                    onClicked: {
dogmaphobic's avatar
dogmaphobic committed
378 379 380
                        var p = mapToItem(toolBarHolder, mouseX, mouseY);
                        mainToolBar.onEnterMessageArea(p.x, p.y);
                    }
dogmaphobic's avatar
dogmaphobic committed
381 382 383 384
                }

            }

385 386 387 388 389
            Rectangle {
                id: mavIcon
                width: cellHeight
                height: cellHeight
                visible: showMavStatus() &&  (mainToolBar.showMav)
dogmaphobic's avatar
dogmaphobic committed
390
                anchors.verticalCenter: parent.verticalCenter
391 392 393 394
                color: colorBlue
                border.color: "#00000000"
                border.width: 0
                Image {
395
                    source: MavManager.systemPixmap
396 397 398 399 400
                    height: cellHeight * 0.75
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                }
dogmaphobic's avatar
dogmaphobic committed
401 402
            }

403 404
            Rectangle {
                id: satelitte
405
                width:  getProportionalDimmension(55)
406 407
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showGPS)
dogmaphobic's avatar
dogmaphobic committed
408
                anchors.verticalCenter: parent.verticalCenter
409 410 411 412 413
                color:  getSatelliteColor();
                border.color: "#00000000"
                border.width: 0

                Image {
Don Gagne's avatar
Don Gagne committed
414
                    source: "qrc:/res/Gps";
dogmaphobic's avatar
dogmaphobic committed
415
                    height: getProportionalDimmension(24)
416 417 418
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
419
                    anchors.leftMargin: getProportionalDimmension(6)
420 421 422 423
                    mipmap: true
                    smooth: true
                }

424
                QGCLabel {
425
                    id: satelitteText
426
                    text: MavManager.satelliteCount >= 0 ? MavManager.satelliteCount : 'NA'
Don Gagne's avatar
Don Gagne committed
427
                    font.pixelSize: MavManager.satelliteCount >= 0 ? ScreenTools.defaultFontPixelSize : ScreenTools.smallFontPixelSize
428 429 430
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
431
                    anchors.rightMargin: getProportionalDimmension(6)
432 433 434
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
dogmaphobic's avatar
dogmaphobic committed
435 436
            }

437
            Rectangle {
438 439
                id: rssiRC
                width:  getProportionalDimmension(55)
440
                height: cellHeight
441
                visible: showMavStatus() && mainToolBar.showRSSI && mainToolBar.remoteRSSI <= 100
442
                anchors.verticalCenter: parent.verticalCenter
443
                color:  getRSSIColor(mainToolBar.remoteRSSI);
444 445 446
                border.color: "#00000000"
                border.width: 0
                Image {
447 448
                    source: "qrc:/res/AntennaRC";
                    width: cellHeight * 0.7
449 450 451 452 453 454 455
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }
456 457 458 459 460 461
                QGCLabel {
                    text: mainToolBar.remoteRSSI
                    anchors.right: parent.right
                    anchors.rightMargin: getProportionalDimmension(6)
                    anchors.verticalCenter: parent.verticalCenter
                    horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
462
                    font.pixelSize: ScreenTools.smallFontPixelSize
463 464 465 466
                    font.weight: Font.DemiBold
                    color: colorWhite
                }
            }
467

468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
            Rectangle {
                id: rssiTelemetry
                width:  getProportionalDimmension(80)
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showRSSI) && ((mainToolBar.telemetryRRSSI > 0) && (mainToolBar.telemetryLRSSI > 0))
                anchors.verticalCenter: parent.verticalCenter
                color:  getRSSIColor(Math.min(mainToolBar.telemetryRRSSI,mainToolBar.telemetryLRSSI));
                border.color: "#00000000"
                border.width: 0
                Image {
                    source: "qrc:/res/AntennaT";
                    width: cellHeight * 0.7
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }
487 488 489 490 491 492 493 494
                Column {
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right:          parent.right
                    anchors.rightMargin:    getProportionalDimmension(6)
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
                            text: 'R '
Don Gagne's avatar
Don Gagne committed
495
                            font.pixelSize: ScreenTools.smallFontPixelSize
496 497 498 499
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
500 501
                            text: mainToolBar.telemetryRRSSI + 'dB'
                            width: getProportionalDimmension(30)
502
                            horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
503
                            font.pixelSize: ScreenTools.smallFontPixelSize
504 505 506 507 508 509 510
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
511
                            text: 'L '
Don Gagne's avatar
Don Gagne committed
512
                            font.pixelSize: ScreenTools.smallFontPixelSize
513 514 515 516
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
517 518
                            text: mainToolBar.telemetryLRSSI + 'dB'
                            width: getProportionalDimmension(30)
519
                            horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
520
                            font.pixelSize: ScreenTools.smallFontPixelSize
521 522 523 524 525 526 527
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                }
            }

528
            Rectangle {
529 530
                id: batteryStatus
                width:  MavManager.batteryConsumed < 0.0 ? getProportionalDimmension(60) : getProportionalDimmension(80)
531 532
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showBattery)
dogmaphobic's avatar
dogmaphobic committed
533
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
534
                color:  getBatteryColor();
535 536 537 538
                border.color: "#00000000"
                border.width: 0
                Image {
                    source: getBatteryIcon();
dogmaphobic's avatar
dogmaphobic committed
539
                    height: getProportionalDimmension(20)
540 541 542
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
dogmaphobic's avatar
dogmaphobic committed
543
                    anchors.leftMargin: getProportionalDimmension(6)
544 545 546 547
                    mipmap: true
                    smooth: true
                }

548
                QGCLabel {
549
                    visible: batteryStatus.visible && MavManager.batteryConsumed < 0.0
550
                    text: MavManager.batteryVoltage.toFixed(1) + 'V';
Don Gagne's avatar
Don Gagne committed
551
                    font.pixelSize: ScreenTools.smallFontPixelSize
552 553
                    font.weight: Font.DemiBold
                    anchors.right: parent.right
554
                    anchors.rightMargin: getProportionalDimmension(6)
dogmaphobic's avatar
dogmaphobic committed
555
                    anchors.verticalCenter: parent.verticalCenter
556 557 558
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
559 560 561 562 563 564 565 566 567 568

                Column {
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right:          parent.right
                    anchors.rightMargin:    getProportionalDimmension(6)
                    visible: batteryStatus.visible && MavManager.batteryConsumed >= 0.0
                    QGCLabel {
                        text: MavManager.batteryVoltage.toFixed(1) + 'V';
                        width: getProportionalDimmension(30)
                        horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
569
                        font.pixelSize: ScreenTools.smallFontPixelSize
570 571 572 573
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                    QGCLabel {
574
                        text: MavManager.batteryConsumed.toFixed(0) + 'mAh';
575 576
                        width: getProportionalDimmension(30)
                        horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
577
                        font.pixelSize: ScreenTools.smallFontPixelSize
578 579 580 581
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                }
dogmaphobic's avatar
dogmaphobic committed
582 583
            }

584 585 586
            Column {
                visible: showMavStatus()
                height:  cellHeight * 0.85
dogmaphobic's avatar
dogmaphobic committed
587
                width:   getProportionalDimmension(80)
dogmaphobic's avatar
dogmaphobic committed
588 589
                anchors.verticalCenter: parent.verticalCenter

590 591 592 593 594 595 596 597 598
                Rectangle {
                    id: armedStatus
                    width: parent.width
                    height: parent.height / 2
                    anchors.horizontalCenter: parent.horizontalCenter
                    color: "#00000000"
                    border.color: "#00000000"
                    border.width: 0

599
                    QGCLabel {
600
                        id: armedStatusText
601
                        text: (MavManager.systemArmed) ? qsTr("ARMED") :  qsTr("DISARMED")
Don Gagne's avatar
Don Gagne committed
602
                        font.pixelSize: ScreenTools.smallFontPixelSize
603 604
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
605
                        color: (MavManager.systemArmed) ? colorOrangeText : colorGreenText
606 607 608 609 610 611 612 613 614 615 616 617
                    }
                }

                Rectangle {
                    id: stateStatus
                    width: parent.width
                    height: parent.height / 2
                    anchors.horizontalCenter: parent.horizontalCenter
                    color: "#00000000"
                    border.color: "#00000000"
                    border.width: 0

618
                    QGCLabel {
619
                        id: stateStatusText
620
                        text: MavManager.currentState
Don Gagne's avatar
Don Gagne committed
621
                        font.pixelSize: ScreenTools.smallFontPixelSize
622 623
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
624
                        color: (MavManager.currentState === "STANDBY") ? colorGreenText : colorRedText
625 626 627 628
                    }
                }

            }
dogmaphobic's avatar
dogmaphobic committed
629 630

            Rectangle {
631
                id: modeStatus
dogmaphobic's avatar
dogmaphobic committed
632
                width: getProportionalDimmension(90)
633 634
                height: cellHeight
                visible: showMavStatus()
dogmaphobic's avatar
dogmaphobic committed
635 636 637 638
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

639
                QGCLabel {
640
                    id: modeStatusText
641
                    text: MavManager.currentMode
Don Gagne's avatar
Don Gagne committed
642
                    font.pixelSize: ScreenTools.smallFontPixelSize
dogmaphobic's avatar
dogmaphobic committed
643
                    font.weight: Font.DemiBold
644 645
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
646
                    color: colorWhiteText
dogmaphobic's avatar
dogmaphobic committed
647 648 649 650
                }
            }

            Rectangle {
651
                id: connectionStatus
dogmaphobic's avatar
dogmaphobic committed
652
                width: getProportionalDimmension(160)
653
                height: cellHeight
654
                visible: (mainToolBar.connectionCount > 0 && MavManager.mavPresent && MavManager.heartbeatTimeout != 0)
655
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
656 657 658 659
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

660
                QGCLabel {
661 662
                    id: connectionStatusText
                    text: qsTr("CONNECTION LOST")
Don Gagne's avatar
Don Gagne committed
663
                    font.pixelSize: ScreenTools.defaultFontPixelSize
dogmaphobic's avatar
dogmaphobic committed
664
                    font.weight: Font.DemiBold
665 666
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
667
                    color: colorRedText
dogmaphobic's avatar
dogmaphobic committed
668 669 670 671 672 673 674 675 676 677 678
                }
            }
        }
    }

    Row {
        id: row2
        height: cellHeight
        spacing: cellSpacerSize
        anchors.right: parent.right
        anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
679 680
        anchors.leftMargin:  getProportionalDimmension(10)
        anchors.rightMargin: getProportionalDimmension(10)
dogmaphobic's avatar
dogmaphobic committed
681

dogmaphobic's avatar
dogmaphobic committed
682 683
        Menu {
            id: connectMenu
dogmaphobic's avatar
dogmaphobic committed
684
            Component.onCompleted: {
dogmaphobic's avatar
dogmaphobic committed
685 686
                mainToolBar.configListChanged.connect(connectMenu.updateConnectionList);
                connectMenu.updateConnectionList();
dogmaphobic's avatar
dogmaphobic committed
687
            }
dogmaphobic's avatar
dogmaphobic committed
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
            function addMenuEntry(name) {
                var label = "Add Connection"
                if(name !== "")
                    label = name;
                var mItem = connectMenu.addItem(label);
                var menuSlot = function() {mainToolBar.onConnect(name)};
                mItem.triggered.connect(menuSlot);
            }
            function updateConnectionList() {
                connectMenu.clear();
                for(var i = 0; i < mainToolBar.configList.length; i++) {
                    connectMenu.addMenuEntry(mainToolBar.configList[i]);
                }
                if(mainToolBar.configList.length > 0) {
                    connectMenu.addSeparator();
                }
                // Add "Add Connection" to the list
                connectMenu.addMenuEntry("");
dogmaphobic's avatar
dogmaphobic committed
706 707 708 709
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
710
            id:         connectButton
dogmaphobic's avatar
dogmaphobic committed
711
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
712 713 714 715 716 717 718 719
            visible:    mainToolBar.connectionCount === 0
            text:       qsTr("Connect")
            menu:       connectMenu
            anchors.verticalCenter: parent.verticalCenter
        }

        QGCButton {
            id:         disconnectButton
dogmaphobic's avatar
dogmaphobic committed
720
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
721 722
            visible:    mainToolBar.connectionCount === 1
            text:       qsTr("Disconnect")
dogmaphobic's avatar
dogmaphobic committed
723 724
            anchors.verticalCenter: parent.verticalCenter
            onClicked: {
dogmaphobic's avatar
dogmaphobic committed
725
                mainToolBar.onDisconnect("");
dogmaphobic's avatar
dogmaphobic committed
726 727 728 729 730 731 732 733
            }
        }

        Menu {
            id: disconnectMenu
            Component.onCompleted: {
                mainToolBar.connectedListChanged.connect(disconnectMenu.onConnectedListChanged)
            }
dogmaphobic's avatar
dogmaphobic committed
734 735 736 737 738
            function addMenuEntry(name) {
                var mItem = disconnectMenu.addItem(name);
                var menuSlot = function() {mainToolBar.onDisconnect(name)};
                mItem.triggered.connect(menuSlot);
            }
dogmaphobic's avatar
dogmaphobic committed
739 740 741
            function onConnectedListChanged(conList) {
                disconnectMenu.clear();
                for(var i = 0; i < conList.length; i++) {
dogmaphobic's avatar
dogmaphobic committed
742
                    disconnectMenu.addMenuEntry(conList[i]);
dogmaphobic's avatar
dogmaphobic committed
743 744 745 746 747
                }
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
748
            id:         multidisconnectButton
dogmaphobic's avatar
dogmaphobic committed
749
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
750 751 752
            text:       "Disconnect"
            visible:    mainToolBar.connectionCount > 1
            menu:       disconnectMenu
dogmaphobic's avatar
dogmaphobic committed
753 754 755 756
            anchors.verticalCenter: parent.verticalCenter
        }

    }
757 758 759

    // Progress bar
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
760
        readonly property int progressBarHeight: getProportionalDimmension(3)
761 762 763 764 765
        y:      parent.height  - progressBarHeight
        height: progressBarHeight
        width:  parent.width * mainToolBar.progressBarValue
        color:  qgcPal.text
    }
dogmaphobic's avatar
dogmaphobic committed
766 767
}