MainToolBar.qml 26.1 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 45
    property ScreenTools screenTools: ScreenTools { }

dogmaphobic's avatar
dogmaphobic committed
46 47 48
    property int cellSpacerSize: getProportionalDimmension(4)
    property int cellHeight:     getProportionalDimmension(30)
    property int cellRadius:     getProportionalDimmension(3)
dogmaphobic's avatar
dogmaphobic committed
49

dogmaphobic's avatar
dogmaphobic committed
50 51 52 53 54
    property var colorBlue:       "#1a6eaa"
    property var colorGreen:      "#079527"
    property var colorRed:        "#a81a1b"
    property var colorOrange:     "#a76f26"
    property var colorWhite:      "#f0f0f0"
dogmaphobic's avatar
dogmaphobic committed
55

56 57 58 59 60
    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"

61
    color:  qgcPal.windowShade
dogmaphobic's avatar
dogmaphobic committed
62

dogmaphobic's avatar
dogmaphobic committed
63 64 65 66 67 68 69 70
    Component.onCompleted: {
        console.log(cellSpacerSize, cellHeight, cellRadius);
    }

    function getProportionalDimmension(val) {
        return toolBarHolder.height * val / 40
    }

dogmaphobic's avatar
dogmaphobic committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
    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
86
            return "qrc:/res/Megaphone";
dogmaphobic's avatar
dogmaphobic committed
87
        else
Don Gagne's avatar
Don Gagne committed
88
            return "qrc:/res/Yield";
dogmaphobic's avatar
dogmaphobic committed
89 90 91 92
    }

    function getBatteryIcon() {
        if(mainToolBar.batteryPercent < 20.0)
Don Gagne's avatar
Don Gagne committed
93
            return "qrc:/res/Battery_0";
dogmaphobic's avatar
dogmaphobic committed
94
        else if(mainToolBar.batteryPercent < 40.0)
Don Gagne's avatar
Don Gagne committed
95
            return "qrc:/res/Battery_20";
dogmaphobic's avatar
dogmaphobic committed
96
        else if(mainToolBar.batteryPercent < 60.0)
Don Gagne's avatar
Don Gagne committed
97
            return "qrc:/res/Battery_40";
dogmaphobic's avatar
dogmaphobic committed
98
        else if(mainToolBar.batteryPercent < 80.0)
Don Gagne's avatar
Don Gagne committed
99
            return "qrc:/res/Battery_60";
dogmaphobic's avatar
dogmaphobic committed
100
        else if(mainToolBar.batteryPercent < 90.0)
Don Gagne's avatar
Don Gagne committed
101
            return "qrc:/res/Battery_80";
dogmaphobic's avatar
dogmaphobic committed
102
        else
Don Gagne's avatar
Don Gagne committed
103
            return "qrc:/res/Battery_100";
dogmaphobic's avatar
dogmaphobic committed
104 105
    }

dogmaphobic's avatar
dogmaphobic committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
    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;
    }

129 130 131 132 133
    function getRSSIColor() {
        // TODO: Figure out RSSI threshold values
        return colorBlue;
    }

dogmaphobic's avatar
dogmaphobic committed
134 135 136 137 138
    function showMavStatus() {
         return (mainToolBar.mavPresent && mainToolBar.heartbeatTimeout === 0 && mainToolBar.connectionCount > 0);
    }

    Row {
139 140 141
        id:                     row1
        height:                 cellHeight
        anchors.left:           parent.left
dogmaphobic's avatar
dogmaphobic committed
142
        spacing:                getProportionalDimmension(4)
dogmaphobic's avatar
dogmaphobic committed
143
        anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
144
        anchors.leftMargin:     getProportionalDimmension(10)
dogmaphobic's avatar
dogmaphobic committed
145

146 147 148
        Row {
            id:                     row11
            height:                 cellHeight
dogmaphobic's avatar
dogmaphobic committed
149
            spacing:                -getProportionalDimmension(12)
dogmaphobic's avatar
dogmaphobic committed
150
            anchors.verticalCenter: parent.verticalCenter
151
            Connections {
152
                target: screenTools
153
                onRepaintRequestedChanged: {
154 155 156
                    setupButton.repaintChevron   = true;
                    planButton.repaintChevron    = true;
                    flyButton.repaintChevron     = true;
157 158
                    analyzeButton.repaintChevron = true;
                }
dogmaphobic's avatar
dogmaphobic committed
159 160
            }

161 162 163 164
            ExclusiveGroup { id: mainActionGroup }

            QGCToolBarButton {
                id: setupButton
dogmaphobic's avatar
dogmaphobic committed
165
                width: getProportionalDimmension(90)
166 167
                height: cellHeight
                exclusiveGroup: mainActionGroup
168
                text: qsTr("Setup")
169 170 171 172 173 174
                anchors.verticalCenter: parent.verticalCenter
                checked: (mainToolBar.currentView === MainToolBar.ViewSetup)
                onClicked: {
                    mainToolBar.onSetupView();
                }
                z: 1000
dogmaphobic's avatar
dogmaphobic committed
175 176
            }

177 178
            QGCToolBarButton {
                id: planButton
dogmaphobic's avatar
dogmaphobic committed
179
                width: getProportionalDimmension(90)
180 181
                height: cellHeight
                exclusiveGroup: mainActionGroup
182
                text: qsTr("Plan")
183 184 185 186 187 188
                anchors.verticalCenter: parent.verticalCenter
                checked: (mainToolBar.currentView === MainToolBar.ViewPlan)
                onClicked: {
                    mainToolBar.onPlanView();
                }
                z: 900
dogmaphobic's avatar
dogmaphobic committed
189 190
            }

191 192
            QGCToolBarButton {
                id: flyButton
dogmaphobic's avatar
dogmaphobic committed
193
                width: getProportionalDimmension(90)
194 195
                height: cellHeight
                exclusiveGroup: mainActionGroup
196
                text: qsTr("Fly")
197 198 199 200 201 202 203 204 205 206
                anchors.verticalCenter: parent.verticalCenter
                checked: (mainToolBar.currentView === MainToolBar.ViewFly)
                onClicked: {
                    mainToolBar.onFlyView();
                }
                z: 800
            }

            QGCToolBarButton {
                id: analyzeButton
dogmaphobic's avatar
dogmaphobic committed
207
                width: getProportionalDimmension(90)
208 209
                height: cellHeight
                exclusiveGroup: mainActionGroup
210
                text: qsTr("Analyze")
211 212 213 214 215 216
                anchors.verticalCenter: parent.verticalCenter
                checked: (mainToolBar.currentView === MainToolBar.ViewAnalyze)
                onClicked: {
                    mainToolBar.onAnalyzeView();
                }
                z: 700
dogmaphobic's avatar
dogmaphobic committed
217 218 219 220
            }

        }

221 222 223 224
        Row {
            id:                     row12
            height:                 cellHeight
            spacing:                cellSpacerSize
dogmaphobic's avatar
dogmaphobic committed
225 226 227
            anchors.verticalCenter: parent.verticalCenter

            Rectangle {
228
                id: messages
dogmaphobic's avatar
dogmaphobic committed
229
                width: (mainToolBar.messageCount > 99) ? getProportionalDimmension(70) : getProportionalDimmension(60)
230 231
                height: cellHeight
                visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages)
dogmaphobic's avatar
dogmaphobic committed
232
                anchors.verticalCenter: parent.verticalCenter
233 234 235 236 237 238 239 240 241
                color:  getMessageColor()
                radius: cellRadius
                border.color: "#00000000"
                border.width: 0
                property bool showTriangle: false

                Image {
                    id: messageIcon
                    source: getMessageIcon();
dogmaphobic's avatar
dogmaphobic committed
242
                    height: getProportionalDimmension(16)
243
                    fillMode: Image.PreserveAspectFit
dogmaphobic's avatar
dogmaphobic committed
244
                    anchors.verticalCenter: parent.verticalCenter
245
                    anchors.left: parent.left
246
                    anchors.leftMargin: getProportionalDimmension(8)
dogmaphobic's avatar
dogmaphobic committed
247 248
                }

249 250 251 252 253
                Rectangle {
                    id: messageTextRect
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
                    width: messages.width - messageIcon.width
254
                    QGCLabel {
255 256
                        id: messageText
                        text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : ''
257
                        font.pointSize: screenTools.dpiAdjustedPointSize(14);
258 259 260 261 262 263 264
                        font.weight: Font.DemiBold
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.horizontalCenter: parent.horizontalCenter
                        horizontalAlignment: Text.AlignHCenter
                        color: colorWhite
                    }
                }
dogmaphobic's avatar
dogmaphobic committed
265

266 267 268 269 270 271
                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
272 273
                    anchors.bottomMargin: getProportionalDimmension(3)
                    anchors.rightMargin:  getProportionalDimmension(3)
dogmaphobic's avatar
dogmaphobic committed
274 275
                }

276 277 278 279 280 281 282 283
                Timer {
                    id: mouseOffTimer
                    interval: 2000;
                    running: false;
                    repeat: false
                    onTriggered: {
                        messages.showTriangle = false;
                    }
dogmaphobic's avatar
dogmaphobic committed
284
                }
285 286 287 288 289 290 291 292 293

                MouseArea {
                    anchors.fill: parent
                    hoverEnabled: true
                    onEntered: {
                        messages.showTriangle = true;
                        mouseOffTimer.start();
                    }
                    onClicked: {
dogmaphobic's avatar
dogmaphobic committed
294 295 296
                        var p = mapToItem(toolBarHolder, mouseX, mouseY);
                        mainToolBar.onEnterMessageArea(p.x, p.y);
                    }
dogmaphobic's avatar
dogmaphobic committed
297 298 299 300
                }

            }

301 302 303 304 305
            Rectangle {
                id: mavIcon
                width: cellHeight
                height: cellHeight
                visible: showMavStatus() &&  (mainToolBar.showMav)
dogmaphobic's avatar
dogmaphobic committed
306
                anchors.verticalCenter: parent.verticalCenter
307 308 309 310 311 312 313 314 315 316 317
                color: colorBlue
                radius: cellRadius
                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
318 319
            }

320 321
            Rectangle {
                id: satelitte
322
                width:  getProportionalDimmension(50)
323 324
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showGPS)
dogmaphobic's avatar
dogmaphobic committed
325
                anchors.verticalCenter: parent.verticalCenter
326 327 328 329 330 331
                color:  getSatelliteColor();
                radius: cellRadius
                border.color: "#00000000"
                border.width: 0

                Image {
Don Gagne's avatar
Don Gagne committed
332
                    source: "qrc:/res/Gps";
dogmaphobic's avatar
dogmaphobic committed
333
                    height: getProportionalDimmension(24)
334 335 336
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
337
                    anchors.leftMargin: getProportionalDimmension(6)
338 339 340 341
                    mipmap: true
                    smooth: true
                }

342
                QGCLabel {
343 344
                    id: satelitteText
                    text: (mainToolBar.satelliteCount > 0) ? mainToolBar.satelliteCount : ''
345
                    font.pointSize: screenTools.dpiAdjustedPointSize(14);
346 347 348
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
349
                    anchors.rightMargin: getProportionalDimmension(6)
350 351 352
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
dogmaphobic's avatar
dogmaphobic committed
353 354
            }

355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
            Rectangle {
                id: rssi
                width:  getProportionalDimmension(70)
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showRSSI) && ((mainToolBar.remoteRSSI > 0) || (mainToolBar.telemetryRSSI > 0))
                anchors.verticalCenter: parent.verticalCenter
                color:  getRSSIColor();
                radius: cellRadius
                border.color: "#00000000"
                border.width: 0

                Image {
                    source: "qrc:/res/Antenna";
                    height: cellHeight * 0.65
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }

                Column {
                    id: rssiCombined
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right:          parent.right
                    anchors.rightMargin:    getProportionalDimmension(6)
                    visible:                (mainToolBar.remoteRSSI > 0) && (mainToolBar.telemetryRSSI > 0)
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
                            text: 'R '
                            font.pointSize: screenTools.dpiAdjustedPointSize(12);
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
                            text: (mainToolBar.remoteRSSI * 100).toFixed(0)
                            width: getProportionalDimmension(20)
                            horizontalAlignment: Text.AlignRight
                            font.pointSize: screenTools.dpiAdjustedPointSize(12);
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
                            text: 'T '
                            font.pointSize: screenTools.dpiAdjustedPointSize(12);
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
                            text: mainToolBar.telemetryRSSI
                            width: getProportionalDimmension(20)
                            horizontalAlignment: Text.AlignRight
                            font.pointSize: screenTools.dpiAdjustedPointSize(12);
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                }

                Row {
                    id: telemetryRSSISingle
                    anchors.right: parent.right
                    anchors.rightMargin: getProportionalDimmension(6)
                    visible: (mainToolBar.remoteRSSI < 0.01) && (mainToolBar.telemetryRSSI > 0)
                    anchors.verticalCenter: parent.verticalCenter
                    QGCLabel {
                        text: 'T '
                        font.pointSize: screenTools.dpiAdjustedPointSize(12);
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                    QGCLabel {
                        text: mainToolBar.telemetryRSSI
                        width: getProportionalDimmension(20)
                        horizontalAlignment: Text.AlignRight
                        font.pointSize: screenTools.dpiAdjustedPointSize(12);
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                }

                Row {
                    id: remoteRSSISingle
                    anchors.right: parent.right
                    anchors.rightMargin: getProportionalDimmension(6)
                    visible: (mainToolBar.remoteRSSI > 0) && (mainToolBar.telemetryRSSI === 0)
                    anchors.verticalCenter: parent.verticalCenter
                    QGCLabel {
                        text: 'R '
                        font.pointSize: screenTools.dpiAdjustedPointSize(12);
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                    QGCLabel {
                        text: (mainToolBar.remoteRSSI * 100).toFixed(0)
                        width: getProportionalDimmension(20)
                        horizontalAlignment: Text.AlignRight
                        font.pointSize: screenTools.dpiAdjustedPointSize(12);
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                }
            }

464 465
            Rectangle {
                id: battery
466
                width: getProportionalDimmension(60)
467 468
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showBattery)
dogmaphobic's avatar
dogmaphobic committed
469
                anchors.verticalCenter: parent.verticalCenter
470 471 472 473 474 475 476
                color:  (mainToolBar.batteryPercent > 40.0 || mainToolBar.batteryPercent < 0.01) ? colorBlue : colorRed
                radius: cellRadius
                border.color: "#00000000"
                border.width: 0

                Image {
                    source: getBatteryIcon();
dogmaphobic's avatar
dogmaphobic committed
477
                    height: getProportionalDimmension(20)
478 479 480
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
dogmaphobic's avatar
dogmaphobic committed
481
                    anchors.leftMargin: getProportionalDimmension(6)
482 483 484 485
                    mipmap: true
                    smooth: true
                }

486
                QGCLabel {
487
                    id: batteryText
488 489
                    text: mainToolBar.batteryVoltage.toFixed(1) + 'V';
                    font.pointSize: screenTools.dpiAdjustedPointSize(12);
490 491 492
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
493
                    anchors.rightMargin: getProportionalDimmension(6)
494 495 496
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
dogmaphobic's avatar
dogmaphobic committed
497 498
            }

499 500 501
            Column {
                visible: showMavStatus()
                height:  cellHeight * 0.85
dogmaphobic's avatar
dogmaphobic committed
502
                width:   getProportionalDimmension(80)
dogmaphobic's avatar
dogmaphobic committed
503 504
                anchors.verticalCenter: parent.verticalCenter

505 506 507 508 509 510 511 512 513
                Rectangle {
                    id: armedStatus
                    width: parent.width
                    height: parent.height / 2
                    anchors.horizontalCenter: parent.horizontalCenter
                    color: "#00000000"
                    border.color: "#00000000"
                    border.width: 0

514
                    QGCLabel {
515 516
                        id: armedStatusText
                        text: (mainToolBar.systemArmed) ? qsTr("ARMED") :  qsTr("DISARMED")
517
                        font.pointSize: screenTools.dpiAdjustedPointSize(12);
518 519
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
520
                        color: (mainToolBar.systemArmed) ? colorOrangeText : colorGreenText
521 522 523 524 525 526 527 528 529 530 531 532
                    }
                }

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

533
                    QGCLabel {
534 535
                        id: stateStatusText
                        text: mainToolBar.currentState
536
                        font.pointSize: screenTools.dpiAdjustedPointSize(12);
537 538
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
539
                        color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRedText
540 541 542 543
                    }
                }

            }
dogmaphobic's avatar
dogmaphobic committed
544 545

            Rectangle {
546
                id: modeStatus
dogmaphobic's avatar
dogmaphobic committed
547
                width: getProportionalDimmension(90)
548 549
                height: cellHeight
                visible: showMavStatus()
dogmaphobic's avatar
dogmaphobic committed
550 551 552 553
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

554
                QGCLabel {
555 556
                    id: modeStatusText
                    text: mainToolBar.currentMode
557
                    font.pointSize: screenTools.dpiAdjustedPointSize(12);
dogmaphobic's avatar
dogmaphobic committed
558
                    font.weight: Font.DemiBold
559 560
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
561
                    color: colorWhiteText
dogmaphobic's avatar
dogmaphobic committed
562 563 564 565
                }
            }

            Rectangle {
566
                id: connectionStatus
dogmaphobic's avatar
dogmaphobic committed
567
                width: getProportionalDimmension(160)
568 569 570
                height: cellHeight
                visible: (mainToolBar.connectionCount > 0 && mainToolBar.mavPresent && mainToolBar.heartbeatTimeout != 0)
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
571 572 573 574
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

575
                QGCLabel {
576 577
                    id: connectionStatusText
                    text: qsTr("CONNECTION LOST")
578
                    font.pointSize: screenTools.dpiAdjustedPointSize(14);
dogmaphobic's avatar
dogmaphobic committed
579
                    font.weight: Font.DemiBold
580 581
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
582
                    color: colorRedText
dogmaphobic's avatar
dogmaphobic committed
583 584 585 586 587 588 589 590 591 592 593
                }
            }
        }
    }

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

dogmaphobic's avatar
dogmaphobic committed
597 598
        Menu {
            id: connectMenu
dogmaphobic's avatar
dogmaphobic committed
599
            Component.onCompleted: {
dogmaphobic's avatar
dogmaphobic committed
600 601
                mainToolBar.configListChanged.connect(connectMenu.updateConnectionList);
                connectMenu.updateConnectionList();
dogmaphobic's avatar
dogmaphobic committed
602
            }
dogmaphobic's avatar
dogmaphobic committed
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
            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
621 622 623 624
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
625
            id:         connectButton
dogmaphobic's avatar
dogmaphobic committed
626
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
627 628 629 630 631 632 633 634
            visible:    mainToolBar.connectionCount === 0
            text:       qsTr("Connect")
            menu:       connectMenu
            anchors.verticalCenter: parent.verticalCenter
        }

        QGCButton {
            id:         disconnectButton
dogmaphobic's avatar
dogmaphobic committed
635
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
636 637
            visible:    mainToolBar.connectionCount === 1
            text:       qsTr("Disconnect")
dogmaphobic's avatar
dogmaphobic committed
638 639
            anchors.verticalCenter: parent.verticalCenter
            onClicked: {
dogmaphobic's avatar
dogmaphobic committed
640
                mainToolBar.onDisconnect("");
dogmaphobic's avatar
dogmaphobic committed
641 642 643 644 645 646 647 648
            }
        }

        Menu {
            id: disconnectMenu
            Component.onCompleted: {
                mainToolBar.connectedListChanged.connect(disconnectMenu.onConnectedListChanged)
            }
dogmaphobic's avatar
dogmaphobic committed
649 650 651 652 653
            function addMenuEntry(name) {
                var mItem = disconnectMenu.addItem(name);
                var menuSlot = function() {mainToolBar.onDisconnect(name)};
                mItem.triggered.connect(menuSlot);
            }
dogmaphobic's avatar
dogmaphobic committed
654 655 656
            function onConnectedListChanged(conList) {
                disconnectMenu.clear();
                for(var i = 0; i < conList.length; i++) {
dogmaphobic's avatar
dogmaphobic committed
657
                    disconnectMenu.addMenuEntry(conList[i]);
dogmaphobic's avatar
dogmaphobic committed
658 659 660 661 662
                }
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
663
            id:         multidisconnectButton
dogmaphobic's avatar
dogmaphobic committed
664
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
665 666 667
            text:       "Disconnect"
            visible:    mainToolBar.connectionCount > 1
            menu:       disconnectMenu
dogmaphobic's avatar
dogmaphobic committed
668 669 670 671
            anchors.verticalCenter: parent.verticalCenter
        }

    }
672 673 674

    // Progress bar
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
675
        readonly property int progressBarHeight: getProportionalDimmension(3)
676 677 678 679 680
        y:      parent.height  - progressBarHeight
        height: progressBarHeight
        width:  parent.width * mainToolBar.progressBarValue
        color:  qgcPal.text
    }
dogmaphobic's avatar
dogmaphobic committed
681 682
}