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

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

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

54 55 56 57 58
    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"

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

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

dogmaphobic's avatar
dogmaphobic committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
    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
80
            return "qrc:/res/Megaphone";
dogmaphobic's avatar
dogmaphobic committed
81
        else
Don Gagne's avatar
Don Gagne committed
82
            return "qrc:/res/Yield";
dogmaphobic's avatar
dogmaphobic committed
83 84 85 86
    }

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

dogmaphobic's avatar
dogmaphobic committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
    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;
    }

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

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

dogmaphobic's avatar
dogmaphobic committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
    //-------------------------------------------------------------------------
    //-- 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
181
    Row {
182 183 184
        id:                     row1
        height:                 cellHeight
        anchors.left:           parent.left
dogmaphobic's avatar
dogmaphobic committed
185
        spacing:                getProportionalDimmension(4)
dogmaphobic's avatar
dogmaphobic committed
186
        anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
187
        anchors.leftMargin:     getProportionalDimmension(10)
dogmaphobic's avatar
dogmaphobic committed
188

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

207 208 209 210
            ExclusiveGroup { id: mainActionGroup }

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

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

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

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

        }

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

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

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

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

349 350 351 352 353 354
                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
355 356
                    anchors.bottomMargin: getProportionalDimmension(3)
                    anchors.rightMargin:  getProportionalDimmension(3)
dogmaphobic's avatar
dogmaphobic committed
357 358
                }

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

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

            }

384 385 386 387 388
            Rectangle {
                id: mavIcon
                width: cellHeight
                height: cellHeight
                visible: showMavStatus() &&  (mainToolBar.showMav)
dogmaphobic's avatar
dogmaphobic committed
389
                anchors.verticalCenter: parent.verticalCenter
390 391 392 393 394 395 396 397 398 399
                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
400 401
            }

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

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

423
                QGCLabel {
424
                    id: satelitteText
425
                    text: mainToolBar.satelliteCount >= 0 ? mainToolBar.satelliteCount : 'NA'
426
                    font.pointSize: mainToolBar.satelliteCount >= 0 ? ScreenTools.fontPointFactor * (14) : ScreenTools.fontPointFactor * (10)
427 428 429
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
430
                    anchors.rightMargin: getProportionalDimmension(6)
431 432 433
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
dogmaphobic's avatar
dogmaphobic committed
434 435
            }

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

467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
            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
                }
486 487 488 489 490 491 492 493
                Column {
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right:          parent.right
                    anchors.rightMargin:    getProportionalDimmension(6)
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
                            text: 'R '
494
                            font.pointSize: ScreenTools.fontPointFactor * (11);
495 496 497 498
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
499 500
                            text: mainToolBar.telemetryRRSSI + 'dB'
                            width: getProportionalDimmension(30)
501
                            horizontalAlignment: Text.AlignRight
502
                            font.pointSize: ScreenTools.fontPointFactor * (11);
503 504 505 506 507 508 509
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
510
                            text: 'L '
511
                            font.pointSize: ScreenTools.fontPointFactor * (11);
512 513 514 515
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
516 517
                            text: mainToolBar.telemetryLRSSI + 'dB'
                            width: getProportionalDimmension(30)
518
                            horizontalAlignment: Text.AlignRight
519
                            font.pointSize: ScreenTools.fontPointFactor * (11);
520 521 522 523 524 525 526
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                }
            }

527 528
            Rectangle {
                id: battery
529
                width: getProportionalDimmension(60)
530 531
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showBattery)
dogmaphobic's avatar
dogmaphobic committed
532
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
533
                color:  getBatteryColor();
534 535 536 537 538
                border.color: "#00000000"
                border.width: 0

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

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

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

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

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

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

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

            }
dogmaphobic's avatar
dogmaphobic committed
606 607

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

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

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

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

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

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

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

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

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

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

    }
734 735 736

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