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

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>
 */

dogmaphobic's avatar
dogmaphobic committed
30
import QtQuick 2.5
31
import QtQuick.Layouts 1.2
dogmaphobic's avatar
dogmaphobic committed
32 33 34
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2

Don Gagne's avatar
Don Gagne committed
35
import QGroundControl                       1.0
36 37 38 39
import QGroundControl.Controls              1.0
import QGroundControl.Palette               1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
40
import QGroundControl.Controllers           1.0
dogmaphobic's avatar
dogmaphobic committed
41

42
Rectangle {
dogmaphobic's avatar
dogmaphobic committed
43
    id:     toolBar
dogmaphobic's avatar
dogmaphobic committed
44
    color:  opaqueBackground ? "#404040" : Qt.rgba(0,0,0,0.75)
dogmaphobic's avatar
dogmaphobic committed
45

Don Gagne's avatar
Don Gagne committed
46
    QGCPalette { id: qgcPal; colorGroupEnabled: true }
47

dogmaphobic's avatar
dogmaphobic committed
48
    property var  activeVehicle:        multiVehicleManager.activeVehicle
dogmaphobic's avatar
dogmaphobic committed
49
    property var  mainWindow:           null
dogmaphobic's avatar
dogmaphobic committed
50 51
    property bool isMessageImportant:   activeVehicle ? !activeVehicle.messageTypeNormal && !activeVehicle.messageTypeNone : false
    property bool isBackgroundDark:     true
dogmaphobic's avatar
dogmaphobic committed
52
    property bool opaqueBackground:     false
53

dogmaphobic's avatar
dogmaphobic committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    /*
        Dev System (Mac OS)

        qml: Main Window Width:   1008
        qml: Toolbar height:      51.2
        qml: Default font:        12.8
        qml: Font (.75):          9.600000000000001
        qml: Font (.85):          10.88
        qml: Font 1.5):           19.200000000000003
        qml: Default Font Width:  8.328125
        qml: Default Font Height: 12.8
        qml: --
        qml: Real Font Height:    16
        qml: fontHRatio:          1
        qml: --
        qml: cellHeight:          38
        qml: tbFontSmall:         10
        qml: tbFontNormal:        12
        qml: tbFontLarge:         18
        qml: tbSpacing:           9.54

        Nexus 9

        qml: Main Window Width:   2048
        qml: Toolbar height:      90.9312
        qml: Default font:        38
        qml: Font (.75):          28.5
        qml: Font (.85):          32.3
        qml: Font 1.5):           57
        qml: Default Font Width:  20.0625
        qml: Default Font Height: 38
        qml: --
        qml: Real Font Height:    38
        qml: fontHRatio:          2.375
        qml: --
        qml: cellHeight:          68
        qml: tbFontSmall:         23.75
        qml: tbFontNormal:        28.5
        qml: tbFontLarge:         42.75
        qml: tbSpacing:           16.87552

        Nexus 7

        qml: Main Window Width:   1920
        qml: Toolbar height:      85.248
        qml: Default font:        38
        qml: Font (.75):          28.5
        qml: Font (.85):          32.3
        qml: Font 1.5):           57
        qml: Default Font Width:  20.140625
        qml: Default Font Height: 38
        qml: --
        qml: Real Font Height:    38
        qml: fontHRatio:          2.375
        qml: --
        qml: cellHeight:          63
        qml: tbFontSmall:         23.75
        qml: tbFontNormal:        28.5
        qml: tbFontLarge:         42.75
        qml: tbSpacing:           15.820800000000002

        Nexus 4

        qml: Main Window Width:   1196
        qml: Toolbar height:      79.65360000000001
        qml: Default font:        38
        qml: Font (.75):          28.5
        qml: Font (.85):          32.3
        qml: Font 1.5):           57
        qml: Default Font Width:  20.140625
        qml: Default Font Height: 38
        qml: --
        qml: Real Font Height:    38
        qml: fontHRatio:          2.375
        qml: --
        qml: cellHeight:          59
        qml: tbFontSmall:         23.75
        qml: tbFontNormal:        28.5
        qml: tbFontLarge:         42.75
        qml: tbSpacing:           9.85504

    */

    readonly property real  tbFontSmall:    10 * ScreenTools.fontHRatio
    readonly property real  tbFontNormal:   12 * ScreenTools.fontHRatio
    readonly property real  tbFontLarge:    18 * ScreenTools.fontHRatio
dogmaphobic's avatar
dogmaphobic committed
140

dogmaphobic's avatar
dogmaphobic committed
141 142 143 144 145 146
    readonly property var   colorGreen:     "#05f068"
    readonly property var   colorOrange:    "#f0ab06"
    readonly property var   colorRed:       "#fc4638"
    readonly property var   colorGrey:      "#7f7f7f"
    readonly property var   colorBlue:      "#636efe"
    readonly property var   colorWhite:     "#ffffff"
147

148
    MainToolBarController { id: _controller }
dogmaphobic's avatar
dogmaphobic committed
149

150 151 152
    function showToolbarMessage(message) {
        toolBarMessage.text = message
        toolBarMessageArea.visible = true
Don Gagne's avatar
Don Gagne committed
153 154
    }

155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
    function getBatteryColor() {
        if(activeVehicle) {
            if(activeVehicle.batteryPercent > 75) {
                return colorGreen
            }
            if(activeVehicle.batteryPercent > 50) {
                return colorOrange
            }
            if(activeVehicle.batteryPercent > 0.1) {
                return colorRed
            }
        }
        return colorGrey
    }

dogmaphobic's avatar
dogmaphobic committed
170 171 172 173 174 175 176 177 178 179
    function getRSSIColor(value) {
        if(value >= 0)
            return colorGrey;
        if(value > -60)
            return colorGreen;
        if(value > -90)
            return colorOrange;
        return colorRed;
    }

dogmaphobic's avatar
dogmaphobic committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
    function getGpsLockStatus() {
        if(activeVehicle) {
            if(activeVehicle.satelliteLock == 0) {
                return "No Satellite Link"
            }
            if(activeVehicle.satelliteLock == 1) {
                return "No GPS Lock"
            }
            if(activeVehicle.satelliteLock == 2) {
                return "2D Lock"
            }
            return "3D Lock"
        }
        return "N/A"
    }

dogmaphobic's avatar
dogmaphobic committed
196 197 198 199
    Component.onCompleted: {
        //-- TODO: Get this from the actual state
        flyButton.checked = true
    }
200

dogmaphobic's avatar
dogmaphobic committed
201 202 203 204 205 206
    Connections {
        target:         controller
        onShowFlyView:  { flyButton.checked   = true }
        onShowPlanView: { planButton.checked  = true }
        onShowSetupView:{ setupButton.checked = true }
    }
207

dogmaphobic's avatar
dogmaphobic committed
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
    //---------------------------------------------
    // GPS Info
    Component {
        id: gpsInfo
        Rectangle {
            color:          Qt.rgba(0,0,0,0.75)
            width:          gpsCol.width   + ScreenTools.defaultFontPixelWidth  * 3
            height:         gpsCol.height  + ScreenTools.defaultFontPixelHeight * 2
            radius:         ScreenTools.defaultFontPixelHeight * 0.5
            Column {
                id:                 gpsCol
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                width:              Math.max(gpsGrid.width, gpsLabel.width)
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent
                QGCLabel {
                    id:         gpsLabel
                    text:       (activeVehicle && (activeVehicle.satelliteCount > 0)) ? "GPS Status" : "GPS Data Unavailable"
                    font.weight:Font.DemiBold
227
                    color:      colorWhite
dogmaphobic's avatar
dogmaphobic committed
228 229 230 231 232 233 234 235 236 237 238
                    anchors.horizontalCenter: parent.horizontalCenter
                }
                GridLayout {
                    id:                 gpsGrid
                    visible:            (activeVehicle && (activeVehicle.satelliteCount > 0))
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter: parent.horizontalCenter
                    columns: 2
                    QGCLabel {
                        text:   "GPS Count:"
239
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
240 241 242
                    }
                    QGCLabel {
                        text:   activeVehicle ? (activeVehicle.satelliteCount) : "N/A"
243
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
244 245 246
                    }
                    QGCLabel {
                        text:   "GPS Lock:"
247
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
248 249 250
                    }
                    QGCLabel {
                        text:   getGpsLockStatus()
251
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
252 253 254 255 256 257 258 259 260 261 262
                    }
                }
            }
            Component.onCompleted: {
                var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
                x = pos.x
                y = pos.y + ScreenTools.defaultFontPixelHeight
            }
        }
    }

263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
    //---------------------------------------------
    // Battery Info
    Component {
        id: batteryInfo
        Rectangle {
            color:          Qt.rgba(0,0,0,0.75)
            width:          battCol.width   + ScreenTools.defaultFontPixelWidth  * 3
            height:         battCol.height  + ScreenTools.defaultFontPixelHeight * 2
            radius:         ScreenTools.defaultFontPixelHeight * 0.5
            Column {
                id:                 battCol
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                width:              Math.max(battGrid.width, battLabel.width)
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent
                QGCLabel {
                    id:         battLabel
                    text:       (activeVehicle && (activeVehicle.batteryVoltage > 0)) ? "Battery Status" : "Battery Data Unavailable"
281
                    color:      colorWhite
282 283 284 285 286 287 288 289 290 291 292 293
                    font.weight:Font.DemiBold
                    anchors.horizontalCenter: parent.horizontalCenter
                }
                GridLayout {
                    id:                 battGrid
                    visible:            (activeVehicle && (activeVehicle.batteryVoltage > 0))
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter: parent.horizontalCenter
                    columns: 2
                    QGCLabel {
                        text:   "Voltage:"
294
                        color:  colorWhite
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
                    }
                    QGCLabel {
                        text:   activeVehicle ? (activeVehicle.batteryVoltage.toFixed(1) + " V") : "N/A"
                        color:  getBatteryColor()
                    }
                    // TODO: What "controller" provides "Facts"?
                    /*
                    QGCLabel {
                        text:   "Cell Voltage:"
                    }
                    QGCLabel {
                        text:   (activeVehicle.batteryVoltage / controller.getParameterFact(-1, "BAT_N_CELLS").value) + "V"
                        color:  getBatteryColor()
                    }
                    */
                    QGCLabel {
                        text:   "Accumulated Consumption:"
312
                        color:  colorWhite
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
                    }
                    QGCLabel {
                        text:   activeVehicle ? (activeVehicle.batteryConsumed + " mA") : "N/A"
                        color:  getBatteryColor()
                    }
                }
            }
            Component.onCompleted: {
                var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
                x = pos.x
                y = pos.y + ScreenTools.defaultFontPixelHeight
            }
        }
    }

    //---------------------------------------------
    // RC RSSI Info
    Component {
        id: rcRSSIInfo
        Rectangle {
            color:          Qt.rgba(0,0,0,0.75)
dogmaphobic's avatar
dogmaphobic committed
334 335
            width:          rcrssiCol.width   + ScreenTools.defaultFontPixelWidth  * 3
            height:         rcrssiCol.height  + ScreenTools.defaultFontPixelHeight * 2
336 337
            radius:         ScreenTools.defaultFontPixelHeight * 0.5
            Column {
dogmaphobic's avatar
dogmaphobic committed
338
                id:                 rcrssiCol
339
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
dogmaphobic's avatar
dogmaphobic committed
340
                width:              Math.max(rcrssiGrid.width, rssiLabel.width)
341 342 343 344
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent
                QGCLabel {
                    id:         rssiLabel
dogmaphobic's avatar
dogmaphobic committed
345
                    text:       activeVehicle ? (activeVehicle.rcRSSI > 0 ? "RC RSSI Status" : "RC RSSI Data Unavailable") : "N/A"
346
                    color:      colorWhite
347 348 349 350
                    font.weight:Font.DemiBold
                    anchors.horizontalCenter: parent.horizontalCenter
                }
                GridLayout {
dogmaphobic's avatar
dogmaphobic committed
351 352
                    id:                 rcrssiGrid
                    visible:            activeVehicle && activeVehicle.rcRSSI > 0
353 354 355 356 357 358
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter: parent.horizontalCenter
                    columns: 2
                    QGCLabel {
                        text:   "RSSI:"
359
                        color:  colorWhite
360 361 362
                    }
                    QGCLabel {
                        text:   activeVehicle ? (activeVehicle.rcRSSI + "%") : 0
363
                        color:  colorWhite
364 365 366 367 368 369 370 371 372 373 374
                    }
                }
            }
            Component.onCompleted: {
                var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
                x = pos.x
                y = pos.y + ScreenTools.defaultFontPixelHeight
            }
        }
    }

dogmaphobic's avatar
dogmaphobic committed
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
    //---------------------------------------------
    // Telemetry RSSI Info
    Component {
        id: telemRSSIInfo
        Rectangle {
            color:          Qt.rgba(0,0,0,0.75)
            width:          telemCol.width   + ScreenTools.defaultFontPixelWidth  * 3
            height:         telemCol.height  + ScreenTools.defaultFontPixelHeight * 2
            radius:         ScreenTools.defaultFontPixelHeight * 0.5
            Column {
                id:                 telemCol
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                width:              Math.max(telemGrid.width, telemLabel.width)
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent
                QGCLabel {
                    id:         telemLabel
                    text:       "Telemetry RSSI Status"
393
                    color:      colorWhite
dogmaphobic's avatar
dogmaphobic committed
394 395 396 397 398 399 400 401 402 403 404
                    font.weight:Font.DemiBold
                    anchors.horizontalCenter: parent.horizontalCenter
                }
                GridLayout {
                    id:                 telemGrid
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter: parent.horizontalCenter
                    columns: 2
                    QGCLabel {
                        text:   "Local RSSI:"
405
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
406 407 408
                    }
                    QGCLabel {
                        text:   _controller.telemetryLRSSI + " dBm"
409
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
410 411 412
                    }
                    QGCLabel {
                        text:   "Remote RSSI:"
413
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
414 415 416
                    }
                    QGCLabel {
                        text:   _controller.telemetryRRSSI + " dBm"
417
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
418 419 420
                    }
                    QGCLabel {
                        text:   "RX Errors:"
421
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
422 423 424
                    }
                    QGCLabel {
                        text:   _controller.telemetryRXErrors
425
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
426 427 428
                    }
                    QGCLabel {
                        text:   "Errors Fixed:"
429
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
430 431 432
                    }
                    QGCLabel {
                        text:   _controller.telemetryFixed
433
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
434 435 436
                    }
                    QGCLabel {
                        text:   "TX Buffer:"
437
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
438 439 440
                    }
                    QGCLabel {
                        text:   _controller.telemetryTXBuffer
441
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
442 443 444
                    }
                    QGCLabel {
                        text:   "Local Noise:"
445
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
446 447 448
                    }
                    QGCLabel {
                        text:   _controller.telemetryLNoise
449
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
450 451 452
                    }
                    QGCLabel {
                        text:   "Remote Noise:"
453
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
454 455 456
                    }
                    QGCLabel {
                        text:   _controller.telemetryRNoise
457
                        color:  colorWhite
dogmaphobic's avatar
dogmaphobic committed
458 459 460 461 462 463 464 465 466 467 468
                    }
                }
            }
            Component.onCompleted: {
                var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
                x = pos.x
                y = pos.y + ScreenTools.defaultFontPixelHeight
            }
        }
    }

469 470
    //---------------------------------------------
    // Toolbar Row
dogmaphobic's avatar
dogmaphobic committed
471 472
    Row {
        id:             viewRow
dogmaphobic's avatar
dogmaphobic committed
473 474
        height:         mainWindow.tbCellHeight
        spacing:        mainWindow.tbSpacing
dogmaphobic's avatar
dogmaphobic committed
475
        anchors.left:   parent.left
dogmaphobic's avatar
dogmaphobic committed
476
        anchors.leftMargin:     mainWindow.tbSpacing
dogmaphobic's avatar
dogmaphobic committed
477 478 479 480
        anchors.verticalCenter: parent.verticalCenter

        ExclusiveGroup { id: mainActionGroup }

dogmaphobic's avatar
dogmaphobic committed
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
        QGCToolBarButton {
            id:                 preferencesButton
            width:              mainWindow.tbButtonWidth
            height:             mainWindow.tbCellHeight
            source:             "/qmlimages/Hamburger.svg"
            onClicked: {
                mainWindow.showLeftMenu();
                preferencesButton.checked = false;
            }
        }

        Rectangle {
            height: mainWindow.tbCellHeight
            width:  1
            color: Qt.rgba(1,1,1,0.45)
        }

dogmaphobic's avatar
dogmaphobic committed
498 499
        QGCToolBarButton {
            id:                 setupButton
dogmaphobic's avatar
dogmaphobic committed
500 501
            width:              mainWindow.tbButtonWidth
            height:             mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
502
            exclusiveGroup:     mainActionGroup
dogmaphobic's avatar
dogmaphobic committed
503
            source:             "/qmlimages/Gears.svg"
dogmaphobic's avatar
dogmaphobic committed
504
            onClicked: {
505
                _controller.onSetupView();
dogmaphobic's avatar
dogmaphobic committed
506 507
            }
        }
508

dogmaphobic's avatar
dogmaphobic committed
509
        Rectangle {
dogmaphobic's avatar
dogmaphobic committed
510
            height: mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
511 512 513
            width:  1
            color: Qt.rgba(1,1,1,0.45)
        }
514

dogmaphobic's avatar
dogmaphobic committed
515 516
        QGCToolBarButton {
            id:                 planButton
dogmaphobic's avatar
dogmaphobic committed
517 518
            width:              mainWindow.tbButtonWidth
            height:             mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
519
            exclusiveGroup:     mainActionGroup
dogmaphobic's avatar
dogmaphobic committed
520
            source:             "/qmlimages/Plan.svg"
dogmaphobic's avatar
dogmaphobic committed
521
            onClicked: {
522
                _controller.onPlanView();
dogmaphobic's avatar
dogmaphobic committed
523 524
            }
        }
Don Gagne's avatar
Don Gagne committed
525

dogmaphobic's avatar
dogmaphobic committed
526
        Rectangle {
dogmaphobic's avatar
dogmaphobic committed
527
            height: mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
528 529
            width:  1
            color: Qt.rgba(1,1,1,0.45)
Don Gagne's avatar
Don Gagne committed
530
        }
dogmaphobic's avatar
dogmaphobic committed
531

dogmaphobic's avatar
dogmaphobic committed
532 533
        QGCToolBarButton {
            id:                 flyButton
dogmaphobic's avatar
dogmaphobic committed
534 535
            width:              mainWindow.tbButtonWidth
            height:             mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
536
            exclusiveGroup:     mainActionGroup
dogmaphobic's avatar
dogmaphobic committed
537
            source:             "/qmlimages/PaperPlane.svg"
dogmaphobic's avatar
dogmaphobic committed
538 539
            onClicked: {
                _controller.onFlyView();
540
            }
Don Gagne's avatar
Don Gagne committed
541
        }
542

Don Gagne's avatar
Don Gagne committed
543
        Rectangle {
dogmaphobic's avatar
dogmaphobic committed
544
            height: mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
545 546
            width:  1
            color: Qt.rgba(1,1,1,0.45)
Don Gagne's avatar
Don Gagne committed
547
        }
548

dogmaphobic's avatar
dogmaphobic committed
549
    }
550

dogmaphobic's avatar
dogmaphobic committed
551
    Item {
dogmaphobic's avatar
dogmaphobic committed
552
        id:                     vehicleIndicators
dogmaphobic's avatar
dogmaphobic committed
553 554
        height:                 mainWindow.tbCellHeight
        anchors.leftMargin:     mainWindow.tbSpacing * 2
Don Gagne's avatar
Don Gagne committed
555 556
        anchors.left:           viewRow.right
        anchors.right:          parent.right
dogmaphobic's avatar
dogmaphobic committed
557
        anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
558 559 560

        property bool vehicleInactive: activeVehicle ? activeVehicle.heartbeatTimeout != 0 : false

dogmaphobic's avatar
dogmaphobic committed
561
        Loader {
Don Gagne's avatar
Don Gagne committed
562 563 564
            source:                 activeVehicle && !parent.vehicleInactive ? "MainToolBarIndicators.qml" : ""
            anchors.left:           parent.left
            anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
565
        }
dogmaphobic's avatar
dogmaphobic committed
566

Don Gagne's avatar
Don Gagne committed
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
        QGCLabel {
            id:                     connectionLost
            text:                   "CONNECTION LOST"
            font.pixelSize:         tbFontLarge
            font.weight:            Font.DemiBold
            color:                  colorRed
            anchors.left:           parent.left
            anchors.verticalCenter: parent.verticalCenter
            visible:                parent.vehicleInactive

        }

        QGCButton {
            anchors.rightMargin:     mainWindow.tbSpacing * 2
            anchors.right:          parent.right
            anchors.verticalCenter: parent.verticalCenter
            text:                   "Disconnect"
            visible:                parent.vehicleInactive
            onClicked:              activeVehicle.disconnectInactiveVehicle()
        }
dogmaphobic's avatar
dogmaphobic committed
587
    }
dogmaphobic's avatar
dogmaphobic committed
588

589 590
    // Progress bar
    Rectangle {
Don Gagne's avatar
Don Gagne committed
591
        id:             progressBar
dogmaphobic's avatar
dogmaphobic committed
592 593
        anchors.bottom: parent.bottom
        height:         toolBar.height * 0.05
594
        width:          parent.width * _controller.progressBarValue
dogmaphobic's avatar
dogmaphobic committed
595
        color:          colorGreen
596
    }
dogmaphobic's avatar
dogmaphobic committed
597

Don Gagne's avatar
Don Gagne committed
598 599
    // Toolbar message area
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
600 601 602 603 604 605 606
        id:             toolBarMessageArea
        x:              toolBar.parent.width * 0.225
        y:              toolBar.parent.height - (ScreenTools.defaultFontPixelHeight * ScreenTools.fontHRatio * 6)
        width:          toolBar.parent.width * 0.55
        height:         ScreenTools.defaultFontPixelHeight * ScreenTools.fontHRatio * 6
        color:          Qt.rgba(0,0,0,0.65)
        visible:        false
dogmaphobic's avatar
dogmaphobic committed
607
        ScrollView {
dogmaphobic's avatar
dogmaphobic committed
608 609 610
            width:              toolBarMessageArea.width - toolBarMessageCloseButton.width
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
dogmaphobic's avatar
dogmaphobic committed
611 612 613 614 615 616 617
            frameVisible:       false
            horizontalScrollBarPolicy:  Qt.ScrollBarAlwaysOff
            verticalScrollBarPolicy:    Qt.ScrollBarAlwaysOff
            QGCLabel {
                id:                 toolBarMessage
                width:              toolBarMessageArea.width - toolBarMessageCloseButton.width
                wrapMode:           Text.WordWrap
dogmaphobic's avatar
dogmaphobic committed
618
                color:              "#e4e428"
dogmaphobic's avatar
dogmaphobic committed
619 620
                lineHeightMode:     Text.ProportionalHeight
                lineHeight:         1.15
dogmaphobic's avatar
dogmaphobic committed
621
                anchors.margins:    mainWindow.tbSpacing
dogmaphobic's avatar
dogmaphobic committed
622
            }
Don Gagne's avatar
Don Gagne committed
623 624
        }
        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
625 626
            id:                 toolBarMessageCloseButton
            primary:            true
dogmaphobic's avatar
dogmaphobic committed
627
            text:               "Close"
dogmaphobic's avatar
dogmaphobic committed
628 629
            anchors.right:      parent.right
            anchors.bottom:     parent.bottom
dogmaphobic's avatar
dogmaphobic committed
630
            anchors.margins:    mainWindow.tbSpacing
Don Gagne's avatar
Don Gagne committed
631
            onClicked: {
dogmaphobic's avatar
dogmaphobic committed
632
                toolBarMessageArea.visible = false
633
                _controller.onToolBarMessageClosed()
Don Gagne's avatar
Don Gagne committed
634 635 636
            }
        }
    }
Don Gagne's avatar
Don Gagne committed
637

Don Gagne's avatar
Don Gagne committed
638
} // Rectangle