MainToolBar.qml 30.6 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

Don Gagne's avatar
Don Gagne committed
46 47
    readonly property real toolBarHeight:   ScreenTools.defaultFontPixelHeight * 3
    property int cellSpacerSize:            ScreenTools.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4)
Don Gagne's avatar
Don Gagne committed
48 49 50 51
    readonly property int cellHeight:       toolBarHeight * 0.75

    readonly property real horizontalMargins:   ScreenTools.defaultFontPixelWidth / 2
    readonly property real verticalMargins:     ScreenTools.defaultFontPixelHeight / 4
dogmaphobic's avatar
dogmaphobic committed
52

Don Gagne's avatar
Don Gagne committed
53 54 55 56 57
    readonly property var colorBlue:    "#1a6eaa"
    readonly property var colorGreen:   "#329147"
    readonly property var colorRed:     "#942324"
    readonly property var colorOrange:  "#a76f26"
    readonly property var colorWhite:   "#f0f0f0"
dogmaphobic's avatar
dogmaphobic committed
58

59 60 61 62 63
    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"

64
    color:  qgcPal.windowShade
dogmaphobic's avatar
dogmaphobic committed
65

Don Gagne's avatar
Don Gagne committed
66 67
    Connections {
        target: mainToolBar
Don Gagne's avatar
Don Gagne committed
68 69 70

        onShowMessage: {
            toolBarMessage.text = message
71 72 73 74 75
            if (toolBarMessage.contentHeight > toolBarMessageCloseButton.height) {
                mainToolBar.height = toolBarHeight + toolBarMessage.contentHeight + (verticalMargins * 2)
            } else {
                mainToolBar.height = toolBarHeight + toolBarMessageCloseButton.height + (verticalMargins * 2)
            }
Don Gagne's avatar
Don Gagne committed
76 77
            toolBarMessageArea.visible = true
        }
Don Gagne's avatar
Don Gagne committed
78 79
    }

dogmaphobic's avatar
dogmaphobic committed
80
    function getProportionalDimmension(val) {
Don Gagne's avatar
Don Gagne committed
81
        return toolBarHeight * val / 40
dogmaphobic's avatar
dogmaphobic committed
82 83
    }

dogmaphobic's avatar
dogmaphobic committed
84
    function getMessageColor() {
85
        if(MavManager.messageType === MavManager.MessageNone)
dogmaphobic's avatar
dogmaphobic committed
86
            return qgcPal.button;
87
        if(MavManager.messageType === MavManager.MessageNormal)
dogmaphobic's avatar
dogmaphobic committed
88
            return colorBlue;
89
        if(MavManager.messageType === MavManager.MessageWarning)
dogmaphobic's avatar
dogmaphobic committed
90
            return colorOrange;
91
        if(MavManager.messageType === MavManager.MessageError)
dogmaphobic's avatar
dogmaphobic committed
92 93 94 95 96 97
            return colorRed;
        // Cannot be so make make it obnoxious to show error
        return "purple";
    }

    function getMessageIcon() {
98
        if(MavManager.messageType === MavManager.MessageNormal || MavManager.messageType === MavManager.MessageNone)
Don Gagne's avatar
Don Gagne committed
99
            return "qrc:/res/Megaphone";
dogmaphobic's avatar
dogmaphobic committed
100
        else
Don Gagne's avatar
Don Gagne committed
101
            return "qrc:/res/Yield";
dogmaphobic's avatar
dogmaphobic committed
102 103 104
    }

    function getBatteryIcon() {
105
        if(MavManager.batteryPercent < 20.0)
Don Gagne's avatar
Don Gagne committed
106
            return "qrc:/res/Battery_0";
107
        else if(MavManager.batteryPercent < 40.0)
Don Gagne's avatar
Don Gagne committed
108
            return "qrc:/res/Battery_20";
109
        else if(MavManager.batteryPercent < 60.0)
Don Gagne's avatar
Don Gagne committed
110
            return "qrc:/res/Battery_40";
111
        else if(MavManager.batteryPercent < 80.0)
Don Gagne's avatar
Don Gagne committed
112
            return "qrc:/res/Battery_60";
113
        else if(MavManager.batteryPercent < 90.0)
Don Gagne's avatar
Don Gagne committed
114
            return "qrc:/res/Battery_80";
dogmaphobic's avatar
dogmaphobic committed
115
        else
Don Gagne's avatar
Don Gagne committed
116
            return "qrc:/res/Battery_100";
dogmaphobic's avatar
dogmaphobic committed
117 118
    }

dogmaphobic's avatar
dogmaphobic committed
119
    function getBatteryColor() {
120
        if (MavManager.batteryPercent > 40.0)
dogmaphobic's avatar
dogmaphobic committed
121
            return colorGreen;
122
        if(MavManager.batteryPercent > 0.01)
dogmaphobic's avatar
dogmaphobic committed
123 124 125 126 127 128 129
            return colorRed;
        // This means there is no battery level data
        return colorBlue;
    }

    function getSatelliteColor() {
        // No GPS data
130
        if (MavManager.satelliteCount < 0)
dogmaphobic's avatar
dogmaphobic committed
131 132
            return qgcPal.button
        // No Lock
133
        if(MavManager.satelliteLock < 2)
dogmaphobic's avatar
dogmaphobic committed
134 135
            return colorRed;
        // 2D Lock
136
        if(MavManager.satelliteLock === 2)
dogmaphobic's avatar
dogmaphobic committed
137 138 139 140 141
            return colorBlue;
        // Lock is 3D or more
        return colorGreen;
    }

142 143 144 145 146 147
    function getRSSIColor(value) {
        if(value < 10)
            return colorRed;
        if(value < 50)
            return colorOrange;
        return colorGreen;
148 149
    }

dogmaphobic's avatar
dogmaphobic committed
150
    function showMavStatus() {
151
         return (MavManager.mavPresent && MavManager.heartbeatTimeout === 0 && mainToolBar.connectionCount > 0);
dogmaphobic's avatar
dogmaphobic committed
152 153
    }

dogmaphobic's avatar
dogmaphobic committed
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
    //-------------------------------------------------------------------------
    //-- 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();
            }
        }
Don Gagne's avatar
Don Gagne committed
198
    } // Menu
dogmaphobic's avatar
dogmaphobic committed
199

dogmaphobic's avatar
dogmaphobic committed
200
    Row {
Don Gagne's avatar
Don Gagne committed
201 202 203 204 205
        id:         toolRow
        x:          horizontalMargins
        y:          (toolBarHeight - cellHeight) / 2
        height:     cellHeight
        spacing:    getProportionalDimmension(4)
dogmaphobic's avatar
dogmaphobic committed
206

dogmaphobic's avatar
dogmaphobic committed
207 208
        //---------------------------------------------------------------------
        //-- Main menu for Non Mobile Devices (Chevron Buttons)
209
        Row {
Don Gagne's avatar
Don Gagne committed
210 211 212 213 214 215
            id:             row11
            height:         cellHeight
            spacing:        -getProportionalDimmension(12)
            anchors.top:    parent.top
            visible:        !ScreenTools.isMobile

216
            Connections {
217
                target: ScreenTools
Don Gagne's avatar
Don Gagne committed
218
                onRepaintRequested: {
219 220 221
                    setupButton.repaintChevron   = true;
                    planButton.repaintChevron    = true;
                    flyButton.repaintChevron     = true;
222 223
                    analyzeButton.repaintChevron = true;
                }
dogmaphobic's avatar
dogmaphobic committed
224 225
            }

226 227 228 229
            ExclusiveGroup { id: mainActionGroup }

            QGCToolBarButton {
                id: setupButton
dogmaphobic's avatar
dogmaphobic committed
230
                width: getProportionalDimmension(90)
231 232
                height: cellHeight
                exclusiveGroup: mainActionGroup
233
                text: qsTr("Setup")
234 235 236 237 238
                checked: (mainToolBar.currentView === MainToolBar.ViewSetup)
                onClicked: {
                    mainToolBar.onSetupView();
                }
                z: 1000
dogmaphobic's avatar
dogmaphobic committed
239 240
            }

241 242
            QGCToolBarButton {
                id: planButton
dogmaphobic's avatar
dogmaphobic committed
243
                width: getProportionalDimmension(90)
244 245
                height: cellHeight
                exclusiveGroup: mainActionGroup
246
                text: qsTr("Plan")
247 248 249 250 251
                checked: (mainToolBar.currentView === MainToolBar.ViewPlan)
                onClicked: {
                    mainToolBar.onPlanView();
                }
                z: 900
dogmaphobic's avatar
dogmaphobic committed
252 253
            }

254 255
            QGCToolBarButton {
                id: flyButton
dogmaphobic's avatar
dogmaphobic committed
256
                width: getProportionalDimmension(90)
257 258
                height: cellHeight
                exclusiveGroup: mainActionGroup
259
                text: qsTr("Fly")
260 261 262 263 264 265 266 267 268
                checked: (mainToolBar.currentView === MainToolBar.ViewFly)
                onClicked: {
                    mainToolBar.onFlyView();
                }
                z: 800
            }

            QGCToolBarButton {
                id: analyzeButton
dogmaphobic's avatar
dogmaphobic committed
269
                width: getProportionalDimmension(90)
270 271
                height: cellHeight
                exclusiveGroup: mainActionGroup
272
                text: qsTr("Analyze")
273 274 275 276 277
                checked: (mainToolBar.currentView === MainToolBar.ViewAnalyze)
                onClicked: {
                    mainToolBar.onAnalyzeView();
                }
                z: 700
dogmaphobic's avatar
dogmaphobic committed
278
            }
Don Gagne's avatar
Don Gagne committed
279
        } // Row
dogmaphobic's avatar
dogmaphobic committed
280

dogmaphobic's avatar
dogmaphobic committed
281 282
        //---------------------------------------------------------------------
        //-- Indicators
283 284 285 286
        Row {
            id:                     row12
            height:                 cellHeight
            spacing:                cellSpacerSize
dogmaphobic's avatar
dogmaphobic committed
287 288
            anchors.verticalCenter: parent.verticalCenter

dogmaphobic's avatar
dogmaphobic committed
289 290 291
            //-- "Hamburger" menu for Mobile Devices
            Item {
                id:         actionButton
292
                visible:    ScreenTools.isMobile
dogmaphobic's avatar
dogmaphobic committed
293 294 295 296 297
                height:     cellHeight
                width:      cellHeight
                Image {
                    id:             buttomImg
                    anchors.fill:   parent
298
                    source:         "/qmlimages/buttonMore.svg"
dogmaphobic's avatar
dogmaphobic committed
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
                    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
325
            Rectangle {
326
                id: messages
327
                width: (MavManager.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60)
328 329
                height: cellHeight
                visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages)
dogmaphobic's avatar
dogmaphobic committed
330
                anchors.verticalCenter: parent.verticalCenter
331 332 333 334 335 336 337 338
                color:  getMessageColor()
                border.color: "#00000000"
                border.width: 0
                property bool showTriangle: false

                Image {
                    id: messageIcon
                    source: getMessageIcon();
dogmaphobic's avatar
dogmaphobic committed
339
                    height: getProportionalDimmension(16)
340
                    fillMode: Image.PreserveAspectFit
dogmaphobic's avatar
dogmaphobic committed
341
                    anchors.verticalCenter: parent.verticalCenter
342
                    anchors.left: parent.left
343
                    anchors.leftMargin: getProportionalDimmension(8)
dogmaphobic's avatar
dogmaphobic committed
344 345
                }

dogmaphobic's avatar
dogmaphobic committed
346
                Item {
347 348 349 350
                    id: messageTextRect
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
                    width: messages.width - messageIcon.width
351
                    QGCLabel {
352
                        id: messageText
353
                        text: (MavManager.messageCount > 0) ? MavManager.messageCount : ''
Don Gagne's avatar
Don Gagne committed
354
                        font.pixelSize: ScreenTools.smallFontPixelSize
355 356 357 358 359 360 361
                        font.weight: Font.DemiBold
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.horizontalCenter: parent.horizontalCenter
                        horizontalAlignment: Text.AlignHCenter
                        color: colorWhite
                    }
                }
dogmaphobic's avatar
dogmaphobic committed
362

363 364
                Image {
                    id: dropDown
365
                    source: "/qmlimages/arrow-down.png"
366
                    visible: (messages.showTriangle) && (MavManager.messageCount > 0)
367 368
                    anchors.bottom: parent.bottom
                    anchors.right: parent.right
dogmaphobic's avatar
dogmaphobic committed
369 370
                    anchors.bottomMargin: getProportionalDimmension(3)
                    anchors.rightMargin:  getProportionalDimmension(3)
dogmaphobic's avatar
dogmaphobic committed
371 372
                }

373 374 375 376 377 378 379 380
                Timer {
                    id: mouseOffTimer
                    interval: 2000;
                    running: false;
                    repeat: false
                    onTriggered: {
                        messages.showTriangle = false;
                    }
dogmaphobic's avatar
dogmaphobic committed
381
                }
382 383 384 385 386 387 388 389 390

                MouseArea {
                    anchors.fill: parent
                    hoverEnabled: true
                    onEntered: {
                        messages.showTriangle = true;
                        mouseOffTimer.start();
                    }
                    onClicked: {
dogmaphobic's avatar
dogmaphobic committed
391 392 393
                        var p = mapToItem(toolBarHolder, mouseX, mouseY);
                        mainToolBar.onEnterMessageArea(p.x, p.y);
                    }
dogmaphobic's avatar
dogmaphobic committed
394 395 396 397
                }

            }

398 399 400 401 402
            Rectangle {
                id: mavIcon
                width: cellHeight
                height: cellHeight
                visible: showMavStatus() &&  (mainToolBar.showMav)
dogmaphobic's avatar
dogmaphobic committed
403
                anchors.verticalCenter: parent.verticalCenter
404 405 406 407
                color: colorBlue
                border.color: "#00000000"
                border.width: 0
                Image {
408
                    source: MavManager.systemPixmap
409 410 411 412 413
                    height: cellHeight * 0.75
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                }
dogmaphobic's avatar
dogmaphobic committed
414 415
            }

416 417
            Rectangle {
                id: satelitte
418
                width:  getProportionalDimmension(55)
419 420
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showGPS)
dogmaphobic's avatar
dogmaphobic committed
421
                anchors.verticalCenter: parent.verticalCenter
422 423 424 425 426
                color:  getSatelliteColor();
                border.color: "#00000000"
                border.width: 0

                Image {
Don Gagne's avatar
Don Gagne committed
427
                    source: "qrc:/res/Gps";
dogmaphobic's avatar
dogmaphobic committed
428
                    height: getProportionalDimmension(24)
429 430 431
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
432
                    anchors.leftMargin: getProportionalDimmension(6)
433 434 435 436
                    mipmap: true
                    smooth: true
                }

437
                QGCLabel {
438
                    id: satelitteText
439
                    text: MavManager.satelliteCount >= 0 ? MavManager.satelliteCount : 'NA'
Don Gagne's avatar
Don Gagne committed
440
                    font.pixelSize: MavManager.satelliteCount >= 0 ? ScreenTools.defaultFontPixelSize : ScreenTools.smallFontPixelSize
441 442 443
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
444
                    anchors.rightMargin: getProportionalDimmension(6)
445 446 447
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
dogmaphobic's avatar
dogmaphobic committed
448 449
            }

450
            Rectangle {
451 452
                id: rssiRC
                width:  getProportionalDimmension(55)
453
                height: cellHeight
454
                visible: showMavStatus() && mainToolBar.showRSSI && mainToolBar.remoteRSSI <= 100
455
                anchors.verticalCenter: parent.verticalCenter
456
                color:  getRSSIColor(mainToolBar.remoteRSSI);
457 458 459
                border.color: "#00000000"
                border.width: 0
                Image {
460 461
                    source: "qrc:/res/AntennaRC";
                    width: cellHeight * 0.7
462 463 464 465 466 467 468
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }
469 470 471 472 473 474
                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
475
                    font.pixelSize: ScreenTools.smallFontPixelSize
476 477 478 479
                    font.weight: Font.DemiBold
                    color: colorWhite
                }
            }
480

481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
            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
                }
500 501 502 503 504 505 506 507
                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
508
                            font.pixelSize: ScreenTools.smallFontPixelSize
509 510 511 512
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
513 514
                            text: mainToolBar.telemetryRRSSI + 'dB'
                            width: getProportionalDimmension(30)
515
                            horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
516
                            font.pixelSize: ScreenTools.smallFontPixelSize
517 518 519 520 521 522 523
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
524
                            text: 'L '
Don Gagne's avatar
Don Gagne committed
525
                            font.pixelSize: ScreenTools.smallFontPixelSize
526 527 528 529
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
530 531
                            text: mainToolBar.telemetryLRSSI + 'dB'
                            width: getProportionalDimmension(30)
532
                            horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
533
                            font.pixelSize: ScreenTools.smallFontPixelSize
534 535 536 537 538 539 540
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                }
            }

541
            Rectangle {
542 543
                id: batteryStatus
                width:  MavManager.batteryConsumed < 0.0 ? getProportionalDimmension(60) : getProportionalDimmension(80)
544 545
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showBattery)
dogmaphobic's avatar
dogmaphobic committed
546
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
547
                color:  getBatteryColor();
548 549 550 551
                border.color: "#00000000"
                border.width: 0
                Image {
                    source: getBatteryIcon();
dogmaphobic's avatar
dogmaphobic committed
552
                    height: getProportionalDimmension(20)
553 554 555
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
dogmaphobic's avatar
dogmaphobic committed
556
                    anchors.leftMargin: getProportionalDimmension(6)
557 558 559 560
                    mipmap: true
                    smooth: true
                }

561
                QGCLabel {
562
                    visible: batteryStatus.visible && MavManager.batteryConsumed < 0.0
563
                    text: MavManager.batteryVoltage.toFixed(1) + 'V';
Don Gagne's avatar
Don Gagne committed
564
                    font.pixelSize: ScreenTools.smallFontPixelSize
565 566
                    font.weight: Font.DemiBold
                    anchors.right: parent.right
567
                    anchors.rightMargin: getProportionalDimmension(6)
dogmaphobic's avatar
dogmaphobic committed
568
                    anchors.verticalCenter: parent.verticalCenter
569 570 571
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
572 573 574 575 576 577 578 579 580 581

                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
582
                        font.pixelSize: ScreenTools.smallFontPixelSize
583 584 585 586
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                    QGCLabel {
587
                        text: MavManager.batteryConsumed.toFixed(0) + 'mAh';
588 589
                        width: getProportionalDimmension(30)
                        horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
590
                        font.pixelSize: ScreenTools.smallFontPixelSize
591 592 593 594
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                }
dogmaphobic's avatar
dogmaphobic committed
595 596
            }

597 598 599
            Column {
                visible: showMavStatus()
                height:  cellHeight * 0.85
dogmaphobic's avatar
dogmaphobic committed
600
                width:   getProportionalDimmension(80)
dogmaphobic's avatar
dogmaphobic committed
601 602
                anchors.verticalCenter: parent.verticalCenter

603 604 605 606 607 608 609 610 611
                Rectangle {
                    id: armedStatus
                    width: parent.width
                    height: parent.height / 2
                    anchors.horizontalCenter: parent.horizontalCenter
                    color: "#00000000"
                    border.color: "#00000000"
                    border.width: 0

612
                    QGCLabel {
613
                        id: armedStatusText
614
                        text: (MavManager.systemArmed) ? qsTr("ARMED") :  qsTr("DISARMED")
Don Gagne's avatar
Don Gagne committed
615
                        font.pixelSize: ScreenTools.smallFontPixelSize
616 617
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
618
                        color: (MavManager.systemArmed) ? colorOrangeText : colorGreenText
619 620 621 622 623 624 625 626 627 628 629 630
                    }
                }

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

631
                    QGCLabel {
632
                        id: stateStatusText
633
                        text: MavManager.currentState
Don Gagne's avatar
Don Gagne committed
634
                        font.pixelSize: ScreenTools.smallFontPixelSize
635 636
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
637
                        color: (MavManager.currentState === "STANDBY") ? colorGreenText : colorRedText
638 639 640 641
                    }
                }

            }
dogmaphobic's avatar
dogmaphobic committed
642 643

            Rectangle {
644
                id: modeStatus
dogmaphobic's avatar
dogmaphobic committed
645
                width: getProportionalDimmension(90)
646 647
                height: cellHeight
                visible: showMavStatus()
dogmaphobic's avatar
dogmaphobic committed
648 649 650 651
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

652
                QGCLabel {
653
                    id: modeStatusText
654
                    text: MavManager.currentMode
Don Gagne's avatar
Don Gagne committed
655
                    font.pixelSize: ScreenTools.smallFontPixelSize
dogmaphobic's avatar
dogmaphobic committed
656
                    font.weight: Font.DemiBold
657 658
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
659
                    color: colorWhiteText
dogmaphobic's avatar
dogmaphobic committed
660 661 662 663
                }
            }

            Rectangle {
664
                id: connectionStatus
dogmaphobic's avatar
dogmaphobic committed
665
                width: getProportionalDimmension(160)
666
                height: cellHeight
667
                visible: (mainToolBar.connectionCount > 0 && MavManager.mavPresent && MavManager.heartbeatTimeout != 0)
668
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
669 670 671 672
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

673
                QGCLabel {
674 675
                    id: connectionStatusText
                    text: qsTr("CONNECTION LOST")
Don Gagne's avatar
Don Gagne committed
676
                    font.pixelSize: ScreenTools.defaultFontPixelSize
dogmaphobic's avatar
dogmaphobic committed
677
                    font.weight: Font.DemiBold
678 679
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
680
                    color: colorRedText
dogmaphobic's avatar
dogmaphobic committed
681 682
                }
            }
Don Gagne's avatar
Don Gagne committed
683 684
        } // Row
    } // Row
dogmaphobic's avatar
dogmaphobic committed
685 686

    Row {
Don Gagne's avatar
Don Gagne committed
687 688 689 690 691 692 693
        id:                     connectRow
        anchors.rightMargin:    verticalMargins
        anchors.right:          parent.right
        anchors.top:            toolRow.top
        anchors.verticalCenter: toolRow.verticalCenter
        height:                 toolRow.height
        spacing:                cellSpacerSize
dogmaphobic's avatar
dogmaphobic committed
694

dogmaphobic's avatar
dogmaphobic committed
695 696
        Menu {
            id: connectMenu
dogmaphobic's avatar
dogmaphobic committed
697
            Component.onCompleted: {
dogmaphobic's avatar
dogmaphobic committed
698 699
                mainToolBar.configListChanged.connect(connectMenu.updateConnectionList);
                connectMenu.updateConnectionList();
dogmaphobic's avatar
dogmaphobic committed
700
            }
dogmaphobic's avatar
dogmaphobic committed
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
            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
719 720 721 722
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
723
            id:         connectButton
dogmaphobic's avatar
dogmaphobic committed
724
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
725 726 727 728 729 730 731
            visible:    mainToolBar.connectionCount === 0
            text:       qsTr("Connect")
            menu:       connectMenu
        }

        QGCButton {
            id:         disconnectButton
dogmaphobic's avatar
dogmaphobic committed
732
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
733 734
            visible:    mainToolBar.connectionCount === 1
            text:       qsTr("Disconnect")
dogmaphobic's avatar
dogmaphobic committed
735
            onClicked: {
dogmaphobic's avatar
dogmaphobic committed
736
                mainToolBar.onDisconnect("");
dogmaphobic's avatar
dogmaphobic committed
737 738 739 740 741 742 743 744
            }
        }

        Menu {
            id: disconnectMenu
            Component.onCompleted: {
                mainToolBar.connectedListChanged.connect(disconnectMenu.onConnectedListChanged)
            }
dogmaphobic's avatar
dogmaphobic committed
745 746 747 748 749
            function addMenuEntry(name) {
                var mItem = disconnectMenu.addItem(name);
                var menuSlot = function() {mainToolBar.onDisconnect(name)};
                mItem.triggered.connect(menuSlot);
            }
dogmaphobic's avatar
dogmaphobic committed
750 751 752
            function onConnectedListChanged(conList) {
                disconnectMenu.clear();
                for(var i = 0; i < conList.length; i++) {
dogmaphobic's avatar
dogmaphobic committed
753
                    disconnectMenu.addMenuEntry(conList[i]);
dogmaphobic's avatar
dogmaphobic committed
754 755 756 757 758
                }
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
759
            id:         multidisconnectButton
dogmaphobic's avatar
dogmaphobic committed
760
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
761 762 763
            text:       "Disconnect"
            visible:    mainToolBar.connectionCount > 1
            menu:       disconnectMenu
dogmaphobic's avatar
dogmaphobic committed
764
        }
Don Gagne's avatar
Don Gagne committed
765
    } // Row
766 767 768

    // Progress bar
    Rectangle {
Don Gagne's avatar
Don Gagne committed
769 770 771 772 773
        id:             progressBar
        anchors.top:    toolRow.bottom
        height:         getProportionalDimmension(3)
        width:          parent.width * mainToolBar.progressBarValue
        color:          qgcPal.text
774
    }
dogmaphobic's avatar
dogmaphobic committed
775

Don Gagne's avatar
Don Gagne committed
776 777
    // Toolbar message area
    Rectangle {
778 779 780 781 782 783 784 785 786 787 788
        id:                     toolBarMessageArea
        anchors.leftMargin:     horizontalMargins
        anchors.rightMargin:    horizontalMargins
        anchors.topMargin:      verticalMargins
        anchors.bottomMargin:   verticalMargins
        anchors.top:            progressBar.bottom
        anchors.bottom:         parent.bottom
        anchors.left:           parent.left
        anchors.right:          parent.right
        color:                  qgcPal.windowShadeDark
        visible:                false
Don Gagne's avatar
Don Gagne committed
789 790 791 792 793

        QGCLabel {
            id:             toolBarMessage
            anchors.fill:   parent
            wrapMode:       Text.WordWrap
794
			color:			qgcPal.warningText
Don Gagne's avatar
Don Gagne committed
795 796 797 798 799 800 801
        }

        QGCButton {
            id:                     toolBarMessageCloseButton
            anchors.rightMargin:    horizontalMargins
            anchors.top:            parent.top
            anchors.right:          parent.right
802
			primary:				true
Don Gagne's avatar
Don Gagne committed
803 804 805 806 807
            text:                   "Close Message"

            onClicked: {
                parent.visible = false
                mainToolBar.height = toolBarHeight
808
                mainToolBar.onToolBarMessageClosed()
Don Gagne's avatar
Don Gagne committed
809 810 811 812
            }
        }
    }
} // Rectangle