MainToolBar.qml 24.9 KB
Newer Older
dogmaphobic's avatar
dogmaphobic committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QGROUNDCONTROL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief QGC Main Tool Bar
 *   @author Gus Grubba <mavlink@grubba.com>
 */

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2

import QGroundControl.Controls 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.MainToolBar 1.0
38
import QGroundControl.ScreenTools 1.0
dogmaphobic's avatar
dogmaphobic committed
39 40

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

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

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

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

55 56 57 58 59
    property var colorOrangeText: (qgcPal.globalTheme === QGCPalette.Light) ? "#b75711" : "#ea8225"
    property var colorRedText:    (qgcPal.globalTheme === QGCPalette.Light) ? "#ee1112" : "#ef2526"
    property var colorGreenText:  (qgcPal.globalTheme === QGCPalette.Light) ? "#046b1b" : "#00d930"
    property var colorWhiteText:  (qgcPal.globalTheme === QGCPalette.Light) ? "#343333" : "#f0f0f0"

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

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

dogmaphobic's avatar
dogmaphobic committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    function getMessageColor() {
        if(mainToolBar.messageType === MainToolBar.MessageNone)
            return qgcPal.button;
        if(mainToolBar.messageType === MainToolBar.MessageNormal)
            return colorBlue;
        if(mainToolBar.messageType === MainToolBar.MessageWarning)
            return colorOrange;
        if(mainToolBar.messageType === MainToolBar.MessageError)
            return colorRed;
        // Cannot be so make make it obnoxious to show error
        return "purple";
    }

    function getMessageIcon() {
        if(mainToolBar.messageType === MainToolBar.MessageNormal || mainToolBar.messageType === MainToolBar.MessageNone)
Don Gagne's avatar
Don Gagne committed
81
            return "qrc:/res/Megaphone";
dogmaphobic's avatar
dogmaphobic committed
82
        else
Don Gagne's avatar
Don Gagne committed
83
            return "qrc:/res/Yield";
dogmaphobic's avatar
dogmaphobic committed
84 85 86 87
    }

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

dogmaphobic's avatar
dogmaphobic committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    function getBatteryColor() {
        if (mainToolBar.batteryPercent > 40.0)
            return colorGreen;
        if(mainToolBar.batteryPercent > 0.01)
            return colorRed;
        // This means there is no battery level data
        return colorBlue;
    }

    function getSatelliteColor() {
        // No GPS data
        if (mainToolBar.satelliteCount < 0)
            return qgcPal.button
        // No Lock
        if(mainToolBar.satelliteLock < 2)
            return colorRed;
        // 2D Lock
        if(mainToolBar.satelliteLock === 2)
            return colorBlue;
        // Lock is 3D or more
        return colorGreen;
    }

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

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

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

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

159 160 161 162
            ExclusiveGroup { id: mainActionGroup }

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

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

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

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

        }

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

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

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

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

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

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

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

            }

298 299 300 301 302
            Rectangle {
                id: mavIcon
                width: cellHeight
                height: cellHeight
                visible: showMavStatus() &&  (mainToolBar.showMav)
dogmaphobic's avatar
dogmaphobic committed
303
                anchors.verticalCenter: parent.verticalCenter
304 305 306 307 308 309 310 311 312 313
                color: colorBlue
                border.color: "#00000000"
                border.width: 0
                Image {
                    source: mainToolBar.systemPixmap
                    height: cellHeight * 0.75
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                }
dogmaphobic's avatar
dogmaphobic committed
314 315
            }

316 317
            Rectangle {
                id: satelitte
318
                width:  getProportionalDimmension(50)
319 320
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showGPS)
dogmaphobic's avatar
dogmaphobic committed
321
                anchors.verticalCenter: parent.verticalCenter
322 323 324 325 326
                color:  getSatelliteColor();
                border.color: "#00000000"
                border.width: 0

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

337
                QGCLabel {
338
                    id: satelitteText
dogmaphobic's avatar
dogmaphobic committed
339
                    text: mainToolBar.satelliteCount
340
                    font.pointSize: screenTools.dpiAdjustedPointSize(14);
341 342 343
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
344
                    anchors.rightMargin: getProportionalDimmension(6)
345 346 347
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
dogmaphobic's avatar
dogmaphobic committed
348 349
            }

350
            Rectangle {
351 352
                id: rssiRC
                width:  getProportionalDimmension(55)
353
                height: cellHeight
354
                visible: showMavStatus() && mainToolBar.showRSSI
355
                anchors.verticalCenter: parent.verticalCenter
356
                color:  getRSSIColor(mainToolBar.remoteRSSI);
357 358 359
                border.color: "#00000000"
                border.width: 0
                Image {
360 361
                    source: "qrc:/res/AntennaRC";
                    width: cellHeight * 0.7
362 363 364 365 366 367 368
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }
369 370 371 372 373 374 375 376 377 378 379
                QGCLabel {
                    text: mainToolBar.remoteRSSI
                    anchors.right: parent.right
                    anchors.rightMargin: getProportionalDimmension(6)
                    anchors.verticalCenter: parent.verticalCenter
                    horizontalAlignment: Text.AlignRight
                    font.pointSize: screenTools.dpiAdjustedPointSize(12);
                    font.weight: Font.DemiBold
                    color: colorWhite
                }
            }
380

381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
            Rectangle {
                id: rssiTelemetry
                width:  getProportionalDimmension(80)
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showRSSI) && ((mainToolBar.telemetryRRSSI > 0) && (mainToolBar.telemetryLRSSI > 0))
                anchors.verticalCenter: parent.verticalCenter
                color:  getRSSIColor(Math.min(mainToolBar.telemetryRRSSI,mainToolBar.telemetryLRSSI));
                border.color: "#00000000"
                border.width: 0
                Image {
                    source: "qrc:/res/AntennaT";
                    width: cellHeight * 0.7
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }
400 401 402 403 404 405 406 407
                Column {
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right:          parent.right
                    anchors.rightMargin:    getProportionalDimmension(6)
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
                            text: 'R '
408
                            font.pointSize: screenTools.dpiAdjustedPointSize(11);
409 410 411 412
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
413 414
                            text: mainToolBar.telemetryRRSSI + 'dB'
                            width: getProportionalDimmension(30)
415
                            horizontalAlignment: Text.AlignRight
416
                            font.pointSize: screenTools.dpiAdjustedPointSize(11);
417 418 419 420 421 422 423
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
424 425
                            text: 'L '
                            font.pointSize: screenTools.dpiAdjustedPointSize(11);
426 427 428 429
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
430 431
                            text: mainToolBar.telemetryLRSSI + 'dB'
                            width: getProportionalDimmension(30)
432
                            horizontalAlignment: Text.AlignRight
433
                            font.pointSize: screenTools.dpiAdjustedPointSize(11);
434 435 436 437 438 439 440
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                }
            }

441 442
            Rectangle {
                id: battery
443
                width: getProportionalDimmension(60)
444 445
                height: cellHeight
                visible: showMavStatus() && (mainToolBar.showBattery)
dogmaphobic's avatar
dogmaphobic committed
446
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
447
                color:  getBatteryColor();
448 449 450 451 452
                border.color: "#00000000"
                border.width: 0

                Image {
                    source: getBatteryIcon();
dogmaphobic's avatar
dogmaphobic committed
453
                    height: getProportionalDimmension(20)
454 455 456
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
dogmaphobic's avatar
dogmaphobic committed
457
                    anchors.leftMargin: getProportionalDimmension(6)
458 459 460 461
                    mipmap: true
                    smooth: true
                }

462
                QGCLabel {
463
                    id: batteryText
464 465
                    text: mainToolBar.batteryVoltage.toFixed(1) + 'V';
                    font.pointSize: screenTools.dpiAdjustedPointSize(12);
466 467 468
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
469
                    anchors.rightMargin: getProportionalDimmension(6)
470 471 472
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
dogmaphobic's avatar
dogmaphobic committed
473 474
            }

475 476 477
            Column {
                visible: showMavStatus()
                height:  cellHeight * 0.85
dogmaphobic's avatar
dogmaphobic committed
478
                width:   getProportionalDimmension(80)
dogmaphobic's avatar
dogmaphobic committed
479 480
                anchors.verticalCenter: parent.verticalCenter

481 482 483 484 485 486 487 488 489
                Rectangle {
                    id: armedStatus
                    width: parent.width
                    height: parent.height / 2
                    anchors.horizontalCenter: parent.horizontalCenter
                    color: "#00000000"
                    border.color: "#00000000"
                    border.width: 0

490
                    QGCLabel {
491 492
                        id: armedStatusText
                        text: (mainToolBar.systemArmed) ? qsTr("ARMED") :  qsTr("DISARMED")
493
                        font.pointSize: screenTools.dpiAdjustedPointSize(12);
494 495
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
496
                        color: (mainToolBar.systemArmed) ? colorOrangeText : colorGreenText
497 498 499 500 501 502 503 504 505 506 507 508
                    }
                }

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

509
                    QGCLabel {
510 511
                        id: stateStatusText
                        text: mainToolBar.currentState
512
                        font.pointSize: screenTools.dpiAdjustedPointSize(12);
513 514
                        font.weight: Font.DemiBold
                        anchors.centerIn: parent
515
                        color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRedText
516 517 518 519
                    }
                }

            }
dogmaphobic's avatar
dogmaphobic committed
520 521

            Rectangle {
522
                id: modeStatus
dogmaphobic's avatar
dogmaphobic committed
523
                width: getProportionalDimmension(90)
524 525
                height: cellHeight
                visible: showMavStatus()
dogmaphobic's avatar
dogmaphobic committed
526 527 528 529
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

530
                QGCLabel {
531 532
                    id: modeStatusText
                    text: mainToolBar.currentMode
533
                    font.pointSize: screenTools.dpiAdjustedPointSize(12);
dogmaphobic's avatar
dogmaphobic committed
534
                    font.weight: Font.DemiBold
535 536
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
537
                    color: colorWhiteText
dogmaphobic's avatar
dogmaphobic committed
538 539 540 541
                }
            }

            Rectangle {
542
                id: connectionStatus
dogmaphobic's avatar
dogmaphobic committed
543
                width: getProportionalDimmension(160)
544 545 546
                height: cellHeight
                visible: (mainToolBar.connectionCount > 0 && mainToolBar.mavPresent && mainToolBar.heartbeatTimeout != 0)
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
547 548 549 550
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

551
                QGCLabel {
552 553
                    id: connectionStatusText
                    text: qsTr("CONNECTION LOST")
554
                    font.pointSize: screenTools.dpiAdjustedPointSize(14);
dogmaphobic's avatar
dogmaphobic committed
555
                    font.weight: Font.DemiBold
556 557
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
558
                    color: colorRedText
dogmaphobic's avatar
dogmaphobic committed
559 560 561 562 563 564 565 566 567 568 569
                }
            }
        }
    }

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

dogmaphobic's avatar
dogmaphobic committed
573 574
        Menu {
            id: connectMenu
dogmaphobic's avatar
dogmaphobic committed
575
            Component.onCompleted: {
dogmaphobic's avatar
dogmaphobic committed
576 577
                mainToolBar.configListChanged.connect(connectMenu.updateConnectionList);
                connectMenu.updateConnectionList();
dogmaphobic's avatar
dogmaphobic committed
578
            }
dogmaphobic's avatar
dogmaphobic committed
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
            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
597 598 599 600
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
601
            id:         connectButton
dogmaphobic's avatar
dogmaphobic committed
602
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
603 604 605 606 607 608 609 610
            visible:    mainToolBar.connectionCount === 0
            text:       qsTr("Connect")
            menu:       connectMenu
            anchors.verticalCenter: parent.verticalCenter
        }

        QGCButton {
            id:         disconnectButton
dogmaphobic's avatar
dogmaphobic committed
611
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
612 613
            visible:    mainToolBar.connectionCount === 1
            text:       qsTr("Disconnect")
dogmaphobic's avatar
dogmaphobic committed
614 615
            anchors.verticalCenter: parent.verticalCenter
            onClicked: {
dogmaphobic's avatar
dogmaphobic committed
616
                mainToolBar.onDisconnect("");
dogmaphobic's avatar
dogmaphobic committed
617 618 619 620 621 622 623 624
            }
        }

        Menu {
            id: disconnectMenu
            Component.onCompleted: {
                mainToolBar.connectedListChanged.connect(disconnectMenu.onConnectedListChanged)
            }
dogmaphobic's avatar
dogmaphobic committed
625 626 627 628 629
            function addMenuEntry(name) {
                var mItem = disconnectMenu.addItem(name);
                var menuSlot = function() {mainToolBar.onDisconnect(name)};
                mItem.triggered.connect(menuSlot);
            }
dogmaphobic's avatar
dogmaphobic committed
630 631 632
            function onConnectedListChanged(conList) {
                disconnectMenu.clear();
                for(var i = 0; i < conList.length; i++) {
dogmaphobic's avatar
dogmaphobic committed
633
                    disconnectMenu.addMenuEntry(conList[i]);
dogmaphobic's avatar
dogmaphobic committed
634 635 636 637 638
                }
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
639
            id:         multidisconnectButton
dogmaphobic's avatar
dogmaphobic committed
640
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
641 642 643
            text:       "Disconnect"
            visible:    mainToolBar.connectionCount > 1
            menu:       disconnectMenu
dogmaphobic's avatar
dogmaphobic committed
644 645 646 647
            anchors.verticalCenter: parent.verticalCenter
        }

    }
648 649 650

    // Progress bar
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
651
        readonly property int progressBarHeight: getProportionalDimmension(3)
652 653 654 655 656
        y:      parent.height  - progressBarHeight
        height: progressBarHeight
        width:  parent.width * mainToolBar.progressBarValue
        color:  qgcPal.text
    }
dogmaphobic's avatar
dogmaphobic committed
657 658
}