MainToolBar.qml 28 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.ScreenTools 1.0
dogmaphobic's avatar
dogmaphobic committed
39 40

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

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

dogmaphobic's avatar
dogmaphobic committed
46
    property int cellSpacerSize: mainToolBar.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 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    function getMessageColor() {
        if(mainToolBar.messageType === MainToolBar.MessageNone)
            return qgcPal.button;
        if(mainToolBar.messageType === MainToolBar.MessageNormal)
            return colorBlue;
        if(mainToolBar.messageType === MainToolBar.MessageWarning)
            return colorOrange;
        if(mainToolBar.messageType === MainToolBar.MessageError)
            return colorRed;
        // Cannot be so make make it obnoxious to show error
        return "purple";
    }

    function getMessageIcon() {
        if(mainToolBar.messageType === MainToolBar.MessageNormal || mainToolBar.messageType === MainToolBar.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 87
    }

    function getBatteryIcon() {
        if(mainToolBar.batteryPercent < 20.0)
Don Gagne's avatar
Don Gagne committed
88
            return "qrc:/res/Battery_0";
dogmaphobic's avatar
dogmaphobic committed
89
        else if(mainToolBar.batteryPercent < 40.0)
Don Gagne's avatar
Don Gagne committed
90
            return "qrc:/res/Battery_20";
dogmaphobic's avatar
dogmaphobic committed
91
        else if(mainToolBar.batteryPercent < 60.0)
Don Gagne's avatar
Don Gagne committed
92
            return "qrc:/res/Battery_40";
dogmaphobic's avatar
dogmaphobic committed
93
        else if(mainToolBar.batteryPercent < 80.0)
Don Gagne's avatar
Don Gagne committed
94
            return "qrc:/res/Battery_60";
dogmaphobic's avatar
dogmaphobic committed
95
        else if(mainToolBar.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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    function getBatteryColor() {
        if (mainToolBar.batteryPercent > 40.0)
            return colorGreen;
        if(mainToolBar.batteryPercent > 0.01)
            return colorRed;
        // This means there is no battery level data
        return colorBlue;
    }

    function getSatelliteColor() {
        // No GPS data
        if (mainToolBar.satelliteCount < 0)
            return qgcPal.button
        // No Lock
        if(mainToolBar.satelliteLock < 2)
            return colorRed;
        // 2D Lock
        if(mainToolBar.satelliteLock === 2)
            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 133 134 135
    function showMavStatus() {
         return (mainToolBar.mavPresent && mainToolBar.heartbeatTimeout === 0 && mainToolBar.connectionCount > 0);
    }

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
dogmaphobic's avatar
dogmaphobic committed
197
            visible:                !mainToolBar.isMobile
198
            Connections {
199
                target: __screenTools
200
                onRepaintRequestedChanged: {
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 279 280 281 282 283 284 285 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
            //-- "Hamburger" menu for Mobile Devices
            Item {
                id:         actionButton
                visible:    mainToolBar.isMobile
                height:     cellHeight
                width:      cellHeight
                Image {
                    id:             buttomImg
                    anchors.fill:   parent
                    source:         "/qml/buttonMore.svg"
                    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
dogmaphobic's avatar
dogmaphobic committed
314
                width: (mainToolBar.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 340
                        id: messageText
                        text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : ''
341
                        font.pointSize: __screenTools.fontPointFactor * (14);
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 352 353 354 355
                Image {
                    id: dropDown
                    source: "QGroundControl/Controls/arrow-down.png"
                    visible: (messages.showTriangle) && (mainToolBar.messageCount > 0)
                    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 395 396 397 398 399 400
                color: colorBlue
                border.color: "#00000000"
                border.width: 0
                Image {
                    source: mainToolBar.systemPixmap
                    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 427
                    text: mainToolBar.satelliteCount >= 0 ? mainToolBar.satelliteCount : 'NA'
                    font.pointSize: mainToolBar.satelliteCount >= 0 ? __screenTools.fontPointFactor * (14) : __screenTools.fontPointFactor * (10)
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
462
                    font.pointSize: __screenTools.fontPointFactor * (12);
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 '
495
                            font.pointSize: __screenTools.fontPointFactor * (11);
496 497 498 499
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
500 501
                            text: mainToolBar.telemetryRRSSI + 'dB'
                            width: getProportionalDimmension(30)
502
                            horizontalAlignment: Text.AlignRight
503
                            font.pointSize: __screenTools.fontPointFactor * (11);
504 505 506 507 508 509 510
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
511
                            text: 'L '
512
                            font.pointSize: __screenTools.fontPointFactor * (11);
513 514 515 516
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
517 518
                            text: mainToolBar.telemetryLRSSI + 'dB'
                            width: getProportionalDimmension(30)
519
                            horizontalAlignment: Text.AlignRight
520
                            font.pointSize: __screenTools.fontPointFactor * (11);
521 522 523 524 525 526 527
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                }
            }

528 529
            Rectangle {
                id: battery
530
                width: getProportionalDimmension(60)
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 539
                border.color: "#00000000"
                border.width: 0

                Image {
                    source: getBatteryIcon();
dogmaphobic's avatar
dogmaphobic committed
540
                    height: getProportionalDimmension(20)
541 542 543
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
dogmaphobic's avatar
dogmaphobic committed
544
                    anchors.leftMargin: getProportionalDimmension(6)
545 546 547 548
                    mipmap: true
                    smooth: true
                }

549
                QGCLabel {
550
                    id: batteryText
551
                    text: mainToolBar.batteryVoltage.toFixed(1) + 'V';
dogmaphobic's avatar
dogmaphobic committed
552
                    font.pointSize: __screenTools.fontPointFactor * (11);
553 554 555
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
556
                    anchors.rightMargin: getProportionalDimmension(6)
557 558 559
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
dogmaphobic's avatar
dogmaphobic committed
560 561
            }

562 563 564
            Column {
                visible: showMavStatus()
                height:  cellHeight * 0.85
dogmaphobic's avatar
dogmaphobic committed
565
                width:   getProportionalDimmension(80)
dogmaphobic's avatar
dogmaphobic committed
566 567
                anchors.verticalCenter: parent.verticalCenter

568 569 570 571 572 573 574 575 576
                Rectangle {
                    id: armedStatus
                    width: parent.width
                    height: parent.height / 2
                    anchors.horizontalCenter: parent.horizontalCenter
                    color: "#00000000"
                    border.color: "#00000000"
                    border.width: 0

577
                    QGCLabel {
578 579
                        id: armedStatusText
                        text: (mainToolBar.systemArmed) ? qsTr("ARMED") :  qsTr("DISARMED")
580
                        font.pointSize: __screenTools.fontPointFactor * (12);
581 582
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
583
                        color: (mainToolBar.systemArmed) ? colorOrangeText : colorGreenText
584 585 586 587 588 589 590 591 592 593 594 595
                    }
                }

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

596
                    QGCLabel {
597 598
                        id: stateStatusText
                        text: mainToolBar.currentState
599
                        font.pointSize: __screenTools.fontPointFactor * (12);
600 601
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
602
                        color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRedText
603 604 605 606
                    }
                }

            }
dogmaphobic's avatar
dogmaphobic committed
607 608

            Rectangle {
609
                id: modeStatus
dogmaphobic's avatar
dogmaphobic committed
610
                width: getProportionalDimmension(90)
611 612
                height: cellHeight
                visible: showMavStatus()
dogmaphobic's avatar
dogmaphobic committed
613 614 615 616
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

617
                QGCLabel {
618 619
                    id: modeStatusText
                    text: mainToolBar.currentMode
620
                    font.pointSize: __screenTools.fontPointFactor * (12);
dogmaphobic's avatar
dogmaphobic committed
621
                    font.weight: Font.DemiBold
622 623
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
624
                    color: colorWhiteText
dogmaphobic's avatar
dogmaphobic committed
625 626 627 628
                }
            }

            Rectangle {
629
                id: connectionStatus
dogmaphobic's avatar
dogmaphobic committed
630
                width: getProportionalDimmension(160)
631 632 633
                height: cellHeight
                visible: (mainToolBar.connectionCount > 0 && mainToolBar.mavPresent && mainToolBar.heartbeatTimeout != 0)
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
634 635 636 637
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

638
                QGCLabel {
639 640
                    id: connectionStatusText
                    text: qsTr("CONNECTION LOST")
641
                    font.pointSize: __screenTools.fontPointFactor * (14);
dogmaphobic's avatar
dogmaphobic committed
642
                    font.weight: Font.DemiBold
643 644
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
645
                    color: colorRedText
dogmaphobic's avatar
dogmaphobic committed
646 647 648 649 650 651 652 653 654 655 656
                }
            }
        }
    }

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

dogmaphobic's avatar
dogmaphobic committed
660 661
        Menu {
            id: connectMenu
dogmaphobic's avatar
dogmaphobic committed
662
            Component.onCompleted: {
dogmaphobic's avatar
dogmaphobic committed
663 664
                mainToolBar.configListChanged.connect(connectMenu.updateConnectionList);
                connectMenu.updateConnectionList();
dogmaphobic's avatar
dogmaphobic committed
665
            }
dogmaphobic's avatar
dogmaphobic committed
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
            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
684 685 686 687
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
688
            id:         connectButton
dogmaphobic's avatar
dogmaphobic committed
689
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
690 691 692 693 694 695 696 697
            visible:    mainToolBar.connectionCount === 0
            text:       qsTr("Connect")
            menu:       connectMenu
            anchors.verticalCenter: parent.verticalCenter
        }

        QGCButton {
            id:         disconnectButton
dogmaphobic's avatar
dogmaphobic committed
698
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
699 700
            visible:    mainToolBar.connectionCount === 1
            text:       qsTr("Disconnect")
dogmaphobic's avatar
dogmaphobic committed
701 702
            anchors.verticalCenter: parent.verticalCenter
            onClicked: {
dogmaphobic's avatar
dogmaphobic committed
703
                mainToolBar.onDisconnect("");
dogmaphobic's avatar
dogmaphobic committed
704 705 706 707 708 709 710 711
            }
        }

        Menu {
            id: disconnectMenu
            Component.onCompleted: {
                mainToolBar.connectedListChanged.connect(disconnectMenu.onConnectedListChanged)
            }
dogmaphobic's avatar
dogmaphobic committed
712 713 714 715 716
            function addMenuEntry(name) {
                var mItem = disconnectMenu.addItem(name);
                var menuSlot = function() {mainToolBar.onDisconnect(name)};
                mItem.triggered.connect(menuSlot);
            }
dogmaphobic's avatar
dogmaphobic committed
717 718 719
            function onConnectedListChanged(conList) {
                disconnectMenu.clear();
                for(var i = 0; i < conList.length; i++) {
dogmaphobic's avatar
dogmaphobic committed
720
                    disconnectMenu.addMenuEntry(conList[i]);
dogmaphobic's avatar
dogmaphobic committed
721 722 723 724 725
                }
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
726
            id:         multidisconnectButton
dogmaphobic's avatar
dogmaphobic committed
727
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
728 729 730
            text:       "Disconnect"
            visible:    mainToolBar.connectionCount > 1
            menu:       disconnectMenu
dogmaphobic's avatar
dogmaphobic committed
731 732 733 734
            anchors.verticalCenter: parent.verticalCenter
        }

    }
735 736 737

    // Progress bar
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
738
        readonly property int progressBarHeight: getProportionalDimmension(3)
739 740 741 742 743
        y:      parent.height  - progressBarHeight
        height: progressBarHeight
        width:  parent.width * mainToolBar.progressBarValue
        color:  qgcPal.text
    }
dogmaphobic's avatar
dogmaphobic committed
744 745
}