MainToolBar.qml 31.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
/*=====================================================================

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

34 35 36 37 38 39
import QGroundControl.Controls              1.0
import QGroundControl.FactControls          1.0
import QGroundControl.Palette               1.0
import QGroundControl.MainToolBar           1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
dogmaphobic's avatar
dogmaphobic committed
40 41

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

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

46 47
    property var activeVehicle: multiVehicleManager.activeVehicle

Don Gagne's avatar
Don Gagne committed
48 49
    readonly property real toolBarHeight:   ScreenTools.defaultFontPixelHeight * 3
    property int cellSpacerSize:            ScreenTools.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4)
Don Gagne's avatar
Don Gagne committed
50 51 52 53
    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
54

Don Gagne's avatar
Don Gagne committed
55 56 57 58 59
    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
60

61 62 63 64 65
    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"

66
    color:  qgcPal.windowShade
dogmaphobic's avatar
dogmaphobic committed
67

Don Gagne's avatar
Don Gagne committed
68 69
    Connections {
        target: mainToolBar
Don Gagne's avatar
Don Gagne committed
70 71 72

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

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

dogmaphobic's avatar
dogmaphobic committed
86
    function getMessageColor() {
87
        if (activeVehicle.messageTypeNone)
dogmaphobic's avatar
dogmaphobic committed
88
            return qgcPal.button;
89
        if (activeVehicle.messageTypeNorma)
dogmaphobic's avatar
dogmaphobic committed
90
            return colorBlue;
91
        if (activeVehicle.messageTypeWarning)
dogmaphobic's avatar
dogmaphobic committed
92
            return colorOrange;
93
        if (activeVehicle.messageTypeError)
dogmaphobic's avatar
dogmaphobic committed
94 95 96 97 98 99
            return colorRed;
        // Cannot be so make make it obnoxious to show error
        return "purple";
    }

    function getMessageIcon() {
100
        if (activeVehicle.messageTypeNormal || activeVehicle.messageTypeNone)
Don Gagne's avatar
Don Gagne committed
101
            return "qrc:/res/Megaphone";
dogmaphobic's avatar
dogmaphobic committed
102
        else
Don Gagne's avatar
Don Gagne committed
103
            return "qrc:/res/Yield";
dogmaphobic's avatar
dogmaphobic committed
104 105 106
    }

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

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

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

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

dogmaphobic's avatar
dogmaphobic committed
152
    function showMavStatus() {
153
         return (multiVehicleManager.activeVehicleAvailable && activeVehicle.heartbeatTimeout === 0 && mainToolBar.connectionCount > 0);
dogmaphobic's avatar
dogmaphobic committed
154 155
    }

dogmaphobic's avatar
dogmaphobic committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
    //-------------------------------------------------------------------------
    //-- 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
200
    } // Menu
dogmaphobic's avatar
dogmaphobic committed
201

202 203
    Component {
        id: activeVehicleComponent
dogmaphobic's avatar
dogmaphobic committed
204

205
        Row {
206 207
            height:     cellHeight
            spacing:    cellSpacerSize
dogmaphobic's avatar
dogmaphobic committed
208

dogmaphobic's avatar
dogmaphobic committed
209
            Rectangle {
210
                id: messages
211
                width: (activeVehicle.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60)
212
                height: cellHeight
213
                visible: mainToolBar.showMessages
dogmaphobic's avatar
dogmaphobic committed
214
                anchors.verticalCenter: parent.verticalCenter
215 216 217 218 219 220 221 222
                color:  getMessageColor()
                border.color: "#00000000"
                border.width: 0
                property bool showTriangle: false

                Image {
                    id: messageIcon
                    source: getMessageIcon();
dogmaphobic's avatar
dogmaphobic committed
223
                    height: getProportionalDimmension(16)
224
                    fillMode: Image.PreserveAspectFit
dogmaphobic's avatar
dogmaphobic committed
225
                    anchors.verticalCenter: parent.verticalCenter
226
                    anchors.left: parent.left
227
                    anchors.leftMargin: getProportionalDimmension(8)
dogmaphobic's avatar
dogmaphobic committed
228 229
                }

dogmaphobic's avatar
dogmaphobic committed
230
                Item {
231 232 233 234
                    id: messageTextRect
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
                    width: messages.width - messageIcon.width
235
                    QGCLabel {
236
                        id: messageText
237
                        text: (activeVehicle.messageCount > 0) ? activeVehicle.messageCount : ''
Don Gagne's avatar
Don Gagne committed
238
                        font.pixelSize: ScreenTools.smallFontPixelSize
239 240 241 242 243 244 245
                        font.weight: Font.DemiBold
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.horizontalCenter: parent.horizontalCenter
                        horizontalAlignment: Text.AlignHCenter
                        color: colorWhite
                    }
                }
dogmaphobic's avatar
dogmaphobic committed
246

247 248
                Image {
                    id: dropDown
249
                    source: "/qmlimages/arrow-down.png"
250
                    visible: (messages.showTriangle) && (activeVehicle.messageCount > 0)
251 252
                    anchors.bottom: parent.bottom
                    anchors.right: parent.right
dogmaphobic's avatar
dogmaphobic committed
253 254
                    anchors.bottomMargin: getProportionalDimmension(3)
                    anchors.rightMargin:  getProportionalDimmension(3)
dogmaphobic's avatar
dogmaphobic committed
255 256
                }

257 258 259 260 261 262 263 264
                Timer {
                    id: mouseOffTimer
                    interval: 2000;
                    running: false;
                    repeat: false
                    onTriggered: {
                        messages.showTriangle = false;
                    }
dogmaphobic's avatar
dogmaphobic committed
265
                }
266 267 268 269 270 271 272 273 274

                MouseArea {
                    anchors.fill: parent
                    hoverEnabled: true
                    onEntered: {
                        messages.showTriangle = true;
                        mouseOffTimer.start();
                    }
                    onClicked: {
dogmaphobic's avatar
dogmaphobic committed
275 276 277
                        var p = mapToItem(toolBarHolder, mouseX, mouseY);
                        mainToolBar.onEnterMessageArea(p.x, p.y);
                    }
dogmaphobic's avatar
dogmaphobic committed
278 279 280 281
                }

            }

282 283 284 285
            Rectangle {
                id: mavIcon
                width: cellHeight
                height: cellHeight
286
                visible: mainToolBar.showMav
dogmaphobic's avatar
dogmaphobic committed
287
                anchors.verticalCenter: parent.verticalCenter
288 289 290 291
                color: colorBlue
                border.color: "#00000000"
                border.width: 0
                Image {
292
                    source: activeVehicle.systemPixmap
293 294 295 296 297
                    height: cellHeight * 0.75
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                }
dogmaphobic's avatar
dogmaphobic committed
298 299
            }

300 301
            Rectangle {
                id: satelitte
302
                width:  getProportionalDimmension(55)
303
                height: cellHeight
304
                visible: mainToolBar.showGPS
dogmaphobic's avatar
dogmaphobic committed
305
                anchors.verticalCenter: parent.verticalCenter
306 307 308 309 310
                color:  getSatelliteColor();
                border.color: "#00000000"
                border.width: 0

                Image {
Don Gagne's avatar
Don Gagne committed
311
                    source: "qrc:/res/Gps";
dogmaphobic's avatar
dogmaphobic committed
312
                    height: getProportionalDimmension(24)
313 314 315
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
316
                    anchors.leftMargin: getProportionalDimmension(6)
317 318 319 320
                    mipmap: true
                    smooth: true
                }

321
                QGCLabel {
322
                    id: satelitteText
323 324
                    text: activeVehicle.satelliteCount >= 0 ? activeVehicle.satelliteCount : 'NA'
                    font.pixelSize: activeVehicle.satelliteCount >= 0 ? ScreenTools.defaultFontPixelSize : ScreenTools.smallFontPixelSize
325 326 327
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
328
                    anchors.rightMargin: getProportionalDimmension(6)
329 330 331
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
dogmaphobic's avatar
dogmaphobic committed
332 333
            }

334
            Rectangle {
335 336
                id: rssiRC
                width:  getProportionalDimmension(55)
337
                height: cellHeight
338
                visible: mainToolBar.showRSSI && mainToolBar.remoteRSSI <= 100
339
                anchors.verticalCenter: parent.verticalCenter
340
                color:  getRSSIColor(mainToolBar.remoteRSSI);
341 342 343
                border.color: "#00000000"
                border.width: 0
                Image {
344 345
                    source: "qrc:/res/AntennaRC";
                    width: cellHeight * 0.7
346 347 348 349 350 351 352
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }
353 354 355 356 357 358
                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
359
                    font.pixelSize: ScreenTools.smallFontPixelSize
360 361 362 363
                    font.weight: Font.DemiBold
                    color: colorWhite
                }
            }
364

365 366 367 368
            Rectangle {
                id: rssiTelemetry
                width:  getProportionalDimmension(80)
                height: cellHeight
369
                visible: mainToolBar.showRSSI && (mainToolBar.telemetryRRSSI > 0) && (mainToolBar.telemetryLRSSI > 0)
370 371 372 373 374 375 376 377 378 379 380 381 382 383
                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
                }
384 385 386 387 388 389 390 391
                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
392
                            font.pixelSize: ScreenTools.smallFontPixelSize
393 394 395 396
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
397 398
                            text: mainToolBar.telemetryRRSSI + 'dB'
                            width: getProportionalDimmension(30)
399
                            horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
400
                            font.pixelSize: ScreenTools.smallFontPixelSize
401 402 403 404 405 406 407
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
408
                            text: 'L '
Don Gagne's avatar
Don Gagne committed
409
                            font.pixelSize: ScreenTools.smallFontPixelSize
410 411 412 413
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
414 415
                            text: mainToolBar.telemetryLRSSI + 'dB'
                            width: getProportionalDimmension(30)
416
                            horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
417
                            font.pixelSize: ScreenTools.smallFontPixelSize
418 419 420 421 422 423 424
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                }
            }

425
            Rectangle {
426
                id: batteryStatus
427
                width:  activeVehicle.batteryConsumed < 0.0 ? getProportionalDimmension(60) : getProportionalDimmension(80)
428
                height: cellHeight
429
                visible: mainToolBar.showBattery
dogmaphobic's avatar
dogmaphobic committed
430
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
431
                color:  getBatteryColor();
432 433 434 435
                border.color: "#00000000"
                border.width: 0
                Image {
                    source: getBatteryIcon();
dogmaphobic's avatar
dogmaphobic committed
436
                    height: getProportionalDimmension(20)
437 438 439
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
dogmaphobic's avatar
dogmaphobic committed
440
                    anchors.leftMargin: getProportionalDimmension(6)
441 442 443 444
                    mipmap: true
                    smooth: true
                }

445
                QGCLabel {
446 447
                    visible: batteryStatus.visible && activeVehicle.batteryConsumed < 0.0
                    text: activeVehicle.batteryVoltage.toFixed(1) + 'V';
Don Gagne's avatar
Don Gagne committed
448
                    font.pixelSize: ScreenTools.smallFontPixelSize
449 450
                    font.weight: Font.DemiBold
                    anchors.right: parent.right
451
                    anchors.rightMargin: getProportionalDimmension(6)
dogmaphobic's avatar
dogmaphobic committed
452
                    anchors.verticalCenter: parent.verticalCenter
453 454 455
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
456 457 458 459 460

                Column {
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right:          parent.right
                    anchors.rightMargin:    getProportionalDimmension(6)
461
                    visible: batteryStatus.visible && activeVehicle.batteryConsumed >= 0.0
462
                    QGCLabel {
463
                        text: activeVehicle.batteryVoltage.toFixed(1) + 'V';
464 465
                        width: getProportionalDimmension(30)
                        horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
466
                        font.pixelSize: ScreenTools.smallFontPixelSize
467 468 469 470
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                    QGCLabel {
471
                        text: activeVehicle.batteryConsumed.toFixed(0) + 'mAh';
472 473
                        width: getProportionalDimmension(30)
                        horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
474
                        font.pixelSize: ScreenTools.smallFontPixelSize
475 476 477 478
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                }
dogmaphobic's avatar
dogmaphobic committed
479 480
            }

481 482
            Column {
                height:  cellHeight * 0.85
dogmaphobic's avatar
dogmaphobic committed
483
                width:   getProportionalDimmension(80)
dogmaphobic's avatar
dogmaphobic committed
484 485
                anchors.verticalCenter: parent.verticalCenter

486 487 488 489 490 491 492 493 494
                Rectangle {
                    id: armedStatus
                    width: parent.width
                    height: parent.height / 2
                    anchors.horizontalCenter: parent.horizontalCenter
                    color: "#00000000"
                    border.color: "#00000000"
                    border.width: 0

495
                    QGCLabel {
496
                        id: armedStatusText
497
                        text: (activeVehicle.systemArmed) ? qsTr("ARMED") :  qsTr("DISARMED")
Don Gagne's avatar
Don Gagne committed
498
                        font.pixelSize: ScreenTools.smallFontPixelSize
499 500
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
501
                        color: (activeVehicle.systemArmed) ? colorOrangeText : colorGreenText
502 503 504 505 506 507 508 509 510 511 512 513
                    }
                }

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

514
                    QGCLabel {
515
                        id: stateStatusText
516
                        text: activeVehicle.currentState
Don Gagne's avatar
Don Gagne committed
517
                        font.pixelSize: ScreenTools.smallFontPixelSize
518 519
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
520
                        color: (activeVehicle.currentState === "STANDBY") ? colorGreenText : colorRedText
521 522 523 524
                    }
                }

            }
dogmaphobic's avatar
dogmaphobic committed
525 526

            Rectangle {
527
                id: modeStatus
dogmaphobic's avatar
dogmaphobic committed
528
                width: getProportionalDimmension(90)
529
                height: cellHeight
dogmaphobic's avatar
dogmaphobic committed
530 531 532 533
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

534
                QGCLabel {
535
                    id: modeStatusText
536
                    text: activeVehicle.currentMode
Don Gagne's avatar
Don Gagne committed
537
                    font.pixelSize: ScreenTools.smallFontPixelSize
dogmaphobic's avatar
dogmaphobic committed
538
                    font.weight: Font.DemiBold
539 540
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
541
                    color: colorWhiteText
dogmaphobic's avatar
dogmaphobic committed
542 543
                }
            }
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
        } // Row
    } // Component - activeVehicleComponent

    Row {
        id:         toolRow
        x:          horizontalMargins
        y:          (toolBarHeight - cellHeight) / 2
        height:     cellHeight
        spacing:    getProportionalDimmension(4)

        //---------------------------------------------------------------------
        //-- Main menu for Non Mobile Devices (Chevron Buttons)
        Row {
            id:             row11
            height:         cellHeight
            spacing:        -getProportionalDimmension(12)
            anchors.top:    parent.top
            visible:        !ScreenTools.isMobile

            Connections {
                target: ScreenTools
                onRepaintRequested: {
                    setupButton.repaintChevron   = true;
                    planButton.repaintChevron    = true;
                    flyButton.repaintChevron     = true;
                    analyzeButton.repaintChevron = true;
                }
            }

            ExclusiveGroup { id: mainActionGroup }

            QGCToolBarButton {
                id: setupButton
                width: getProportionalDimmension(90)
                height: cellHeight
                exclusiveGroup: mainActionGroup
                text: qsTr("Setup")
                checked: (mainToolBar.currentView === MainToolBar.ViewSetup)
                onClicked: {
                    mainToolBar.onSetupView();
                }
                z: 1000
            }

            QGCToolBarButton {
                id: planButton
                width: getProportionalDimmension(90)
                height: cellHeight
                exclusiveGroup: mainActionGroup
                text: qsTr("Plan")
                checked: (mainToolBar.currentView === MainToolBar.ViewPlan)
                onClicked: {
                    mainToolBar.onPlanView();
                }
                z: 900
            }

            QGCToolBarButton {
                id: flyButton
                width: getProportionalDimmension(90)
                height: cellHeight
                exclusiveGroup: mainActionGroup
                text: qsTr("Fly")
                checked: (mainToolBar.currentView === MainToolBar.ViewFly)
                onClicked: {
                    mainToolBar.onFlyView();
                }
                z: 800
            }

            QGCToolBarButton {
                id: analyzeButton
                width: getProportionalDimmension(90)
                height: cellHeight
                exclusiveGroup: mainActionGroup
                text: qsTr("Analyze")
                checked: (mainToolBar.currentView === MainToolBar.ViewAnalyze)
                onClicked: {
                    mainToolBar.onAnalyzeView();
                }
                z: 700
            }
        } // Row

        //---------------------------------------------------------------------
        //-- Indicators
        Row {
            id:                     row12
            height:                 cellHeight
            spacing:                cellSpacerSize
            anchors.verticalCenter: parent.verticalCenter

            //-- "Hamburger" menu for Mobile Devices
            Item {
                id:         actionButton
                visible:    ScreenTools.isMobile
                height:     cellHeight
                width:      cellHeight
                Image {
                    id:             buttomImg
                    anchors.fill:   parent
                    source:         "/qmlimages/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
            }

            Loader {
                id:                 activeVehicleLoader
                visible:            showMavStatus()
                sourceComponent:    multiVehicleManager.activeVehicleAvailable ? activeVehicleComponent : undefined

                property real cellHeight:       toolBarHolder.cellHeight
                property real cellSpacerSize:   toolBarHolder.cellSpacerSize
            }
dogmaphobic's avatar
dogmaphobic committed
680 681

            Rectangle {
682
                id: connectionStatus
dogmaphobic's avatar
dogmaphobic committed
683
                width: getProportionalDimmension(160)
684
                height: cellHeight
685
                visible: (mainToolBar.connectionCount > 0 && multiVehicleManager.activeVehicleAvailable && activeVehicle.heartbeatTimeout != 0)
686
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
687 688 689 690
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

691
                QGCLabel {
692 693
                    id: connectionStatusText
                    text: qsTr("CONNECTION LOST")
Don Gagne's avatar
Don Gagne committed
694
                    font.pixelSize: ScreenTools.defaultFontPixelSize
dogmaphobic's avatar
dogmaphobic committed
695
                    font.weight: Font.DemiBold
696 697
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
698
                    color: colorRedText
dogmaphobic's avatar
dogmaphobic committed
699 700
                }
            }
Don Gagne's avatar
Don Gagne committed
701 702
        } // Row
    } // Row
dogmaphobic's avatar
dogmaphobic committed
703 704

    Row {
Don Gagne's avatar
Don Gagne committed
705 706 707 708 709 710 711
        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
712

dogmaphobic's avatar
dogmaphobic committed
713 714
        Menu {
            id: connectMenu
dogmaphobic's avatar
dogmaphobic committed
715
            Component.onCompleted: {
dogmaphobic's avatar
dogmaphobic committed
716 717
                mainToolBar.configListChanged.connect(connectMenu.updateConnectionList);
                connectMenu.updateConnectionList();
dogmaphobic's avatar
dogmaphobic committed
718
            }
dogmaphobic's avatar
dogmaphobic committed
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
            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
737 738 739 740
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
741
            id:         connectButton
dogmaphobic's avatar
dogmaphobic committed
742
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
743 744 745 746 747 748 749
            visible:    mainToolBar.connectionCount === 0
            text:       qsTr("Connect")
            menu:       connectMenu
        }

        QGCButton {
            id:         disconnectButton
dogmaphobic's avatar
dogmaphobic committed
750
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
751 752
            visible:    mainToolBar.connectionCount === 1
            text:       qsTr("Disconnect")
dogmaphobic's avatar
dogmaphobic committed
753
            onClicked: {
dogmaphobic's avatar
dogmaphobic committed
754
                mainToolBar.onDisconnect("");
dogmaphobic's avatar
dogmaphobic committed
755 756 757 758 759 760 761 762
            }
        }

        Menu {
            id: disconnectMenu
            Component.onCompleted: {
                mainToolBar.connectedListChanged.connect(disconnectMenu.onConnectedListChanged)
            }
dogmaphobic's avatar
dogmaphobic committed
763 764 765 766 767
            function addMenuEntry(name) {
                var mItem = disconnectMenu.addItem(name);
                var menuSlot = function() {mainToolBar.onDisconnect(name)};
                mItem.triggered.connect(menuSlot);
            }
dogmaphobic's avatar
dogmaphobic committed
768 769 770
            function onConnectedListChanged(conList) {
                disconnectMenu.clear();
                for(var i = 0; i < conList.length; i++) {
dogmaphobic's avatar
dogmaphobic committed
771
                    disconnectMenu.addMenuEntry(conList[i]);
dogmaphobic's avatar
dogmaphobic committed
772 773 774 775 776
                }
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
777
            id:         multidisconnectButton
dogmaphobic's avatar
dogmaphobic committed
778
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
779 780 781
            text:       "Disconnect"
            visible:    mainToolBar.connectionCount > 1
            menu:       disconnectMenu
dogmaphobic's avatar
dogmaphobic committed
782
        }
Don Gagne's avatar
Don Gagne committed
783
    } // Row
784 785 786

    // Progress bar
    Rectangle {
Don Gagne's avatar
Don Gagne committed
787 788 789 790 791
        id:             progressBar
        anchors.top:    toolRow.bottom
        height:         getProportionalDimmension(3)
        width:          parent.width * mainToolBar.progressBarValue
        color:          qgcPal.text
792
    }
dogmaphobic's avatar
dogmaphobic committed
793

Don Gagne's avatar
Don Gagne committed
794 795
    // Toolbar message area
    Rectangle {
796 797 798 799 800 801 802 803 804 805 806
        id:                     toolBarMessageArea
        anchors.leftMargin:     horizontalMargins
        anchors.rightMargin:    horizontalMargins
        anchors.topMargin:      verticalMargins
        anchors.bottomMargin:   verticalMargins
        anchors.top:            progressBar.bottom
        anchors.bottom:         parent.bottom
        anchors.left:           parent.left
        anchors.right:          parent.right
        color:                  qgcPal.windowShadeDark
        visible:                false
Don Gagne's avatar
Don Gagne committed
807 808 809 810 811

        QGCLabel {
            id:             toolBarMessage
            anchors.fill:   parent
            wrapMode:       Text.WordWrap
812
			color:			qgcPal.warningText
Don Gagne's avatar
Don Gagne committed
813 814 815 816 817 818 819
        }

        QGCButton {
            id:                     toolBarMessageCloseButton
            anchors.rightMargin:    horizontalMargins
            anchors.top:            parent.top
            anchors.right:          parent.right
820
			primary:				true
Don Gagne's avatar
Don Gagne committed
821 822 823 824 825
            text:                   "Close Message"

            onClicked: {
                parent.visible = false
                mainToolBar.height = toolBarHeight
826
                mainToolBar.onToolBarMessageClosed()
Don Gagne's avatar
Don Gagne committed
827 828 829 830
            }
        }
    }
} // Rectangle