MainToolBar.qml 30.2 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 71 72 73

        onShowMessage: {
            toolBarMessage.text = message
            mainToolBar.height = toolBarHeight + toolBarMessage.contentHeight + verticalMargins
            toolBarMessageArea.visible = true
        }
Don Gagne's avatar
Don Gagne committed
74 75
    }

dogmaphobic's avatar
dogmaphobic committed
76
    function getProportionalDimmension(val) {
Don Gagne's avatar
Don Gagne committed
77
        return toolBarHeight * val / 40
dogmaphobic's avatar
dogmaphobic committed
78 79
    }

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

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

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

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

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

138 139 140 141 142 143
    function getRSSIColor(value) {
        if(value < 10)
            return colorRed;
        if(value < 50)
            return colorOrange;
        return colorGreen;
144 145
    }

dogmaphobic's avatar
dogmaphobic committed
146
    function showMavStatus() {
147
         return (MavManager.mavPresent && MavManager.heartbeatTimeout === 0 && mainToolBar.connectionCount > 0);
dogmaphobic's avatar
dogmaphobic committed
148 149
    }

dogmaphobic's avatar
dogmaphobic committed
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
    //-------------------------------------------------------------------------
    //-- 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
194
    } // Menu
dogmaphobic's avatar
dogmaphobic committed
195

dogmaphobic's avatar
dogmaphobic committed
196
    Row {
Don Gagne's avatar
Don Gagne committed
197 198 199 200 201
        id:         toolRow
        x:          horizontalMargins
        y:          (toolBarHeight - cellHeight) / 2
        height:     cellHeight
        spacing:    getProportionalDimmension(4)
dogmaphobic's avatar
dogmaphobic committed
202

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

212
            Connections {
213
                target: ScreenTools
Don Gagne's avatar
Don Gagne committed
214
                onRepaintRequested: {
215 216 217
                    setupButton.repaintChevron   = true;
                    planButton.repaintChevron    = true;
                    flyButton.repaintChevron     = true;
218 219
                    analyzeButton.repaintChevron = true;
                }
dogmaphobic's avatar
dogmaphobic committed
220 221
            }

222 223 224 225
            ExclusiveGroup { id: mainActionGroup }

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

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

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

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

dogmaphobic's avatar
dogmaphobic committed
277 278
        //---------------------------------------------------------------------
        //-- Indicators
279 280 281 282
        Row {
            id:                     row12
            height:                 cellHeight
            spacing:                cellSpacerSize
dogmaphobic's avatar
dogmaphobic committed
283 284
            anchors.verticalCenter: parent.verticalCenter

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

                Image {
                    id: messageIcon
                    source: getMessageIcon();
dogmaphobic's avatar
dogmaphobic committed
335
                    height: getProportionalDimmension(16)
336
                    fillMode: Image.PreserveAspectFit
dogmaphobic's avatar
dogmaphobic committed
337
                    anchors.verticalCenter: parent.verticalCenter
338
                    anchors.left: parent.left
339
                    anchors.leftMargin: getProportionalDimmension(8)
dogmaphobic's avatar
dogmaphobic committed
340 341
                }

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

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

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

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

            }

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

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

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

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

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

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

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

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

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

593 594 595
            Column {
                visible: showMavStatus()
                height:  cellHeight * 0.85
dogmaphobic's avatar
dogmaphobic committed
596
                width:   getProportionalDimmension(80)
dogmaphobic's avatar
dogmaphobic committed
597 598
                anchors.verticalCenter: parent.verticalCenter

599 600 601 602 603 604 605 606 607
                Rectangle {
                    id: armedStatus
                    width: parent.width
                    height: parent.height / 2
                    anchors.horizontalCenter: parent.horizontalCenter
                    color: "#00000000"
                    border.color: "#00000000"
                    border.width: 0

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

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

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

            }
dogmaphobic's avatar
dogmaphobic committed
638 639

            Rectangle {
640
                id: modeStatus
dogmaphobic's avatar
dogmaphobic committed
641
                width: getProportionalDimmension(90)
642 643
                height: cellHeight
                visible: showMavStatus()
dogmaphobic's avatar
dogmaphobic committed
644 645 646 647
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

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

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

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

    Row {
Don Gagne's avatar
Don Gagne committed
683 684 685 686 687 688 689
        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
690

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

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

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

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

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

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

Don Gagne's avatar
Don Gagne committed
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803
    // Toolbar message area
    Rectangle {
        id:                 toolBarMessageArea
        anchors.margins:    horizontalMargins
        anchors.top:        progressBar.bottom
        anchors.bottom:     parent.bottom
        anchors.left:       parent.left
        anchors.right:      parent.right
        color:              qgcPal.windowShadeDark
        visible:            false

        QGCLabel {
            id:             toolBarMessage
            anchors.fill:   parent
            wrapMode:       Text.WordWrap
        }

        QGCButton {
            id:                     toolBarMessageCloseButton
            anchors.rightMargin:    horizontalMargins
            anchors.topMargin:      verticalMargins
            anchors.top:            parent.top
            anchors.right:          parent.right
            text:                   "Close Message"

            onClicked: {
                parent.visible = false
                mainToolBar.height = toolBarHeight
            }
        }
    }
} // Rectangle