Skip to content
MainToolBar.qml 32.7 KiB
Newer Older
dogmaphobic's avatar
dogmaphobic committed
/*=====================================================================

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.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.Controllers           1.0
Item {
    id:     toolBarHolder
    height: toolBarHeight
dogmaphobic's avatar
dogmaphobic committed

    property var qgcPal: QGCPalette { id: palette; colorGroupEnabled: true }
    property var activeVehicle: multiVehicleManager.activeVehicle

Don Gagne's avatar
Don Gagne committed
    readonly property real toolBarHeight:   ScreenTools.defaultFontPixelHeight * 3
    property int cellSpacerSize:            ScreenTools.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4)
Don Gagne's avatar
Don Gagne committed
    readonly property int cellHeight:       toolBarHeight * 0.75

    readonly property real horizontalMargins:   ScreenTools.defaultFontPixelWidth / 2
    readonly property real verticalMargins:     ScreenTools.defaultFontPixelHeight / 4
Don Gagne's avatar
Don Gagne committed
    readonly property var colorBlue:    "#1a6eaa"
    readonly property var colorGreen:   "#329147"
    readonly property var colorRed:     "#942324"
    readonly property var colorOrange:  "#a76f26"
    readonly property var colorWhite:   "#f0f0f0"
    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"

    MainToolBarController { id: _controller }
    function showToolbarMessage(message) {
        toolBarMessage.text = message
        if (toolBarMessage.contentHeight > toolBarMessageCloseButton.height) {
Don Gagne's avatar
Don Gagne committed
            toolBarHolder.height = toolBarHeight + toolBarMessage.contentHeight + (verticalMargins * 2)
Don Gagne's avatar
Don Gagne committed
            toolBarHolder.height = toolBarHeight + toolBarMessageCloseButton.height + (verticalMargins * 2)
Don Gagne's avatar
Don Gagne committed
        }
        toolBarMessageArea.visible = true
Don Gagne's avatar
Don Gagne committed
    }

dogmaphobic's avatar
dogmaphobic committed
    function getProportionalDimmension(val) {
Don Gagne's avatar
Don Gagne committed
        return toolBarHeight * val / 40
dogmaphobic's avatar
dogmaphobic committed
    function getMessageColor() {
        if (activeVehicle.messageTypeNone)
dogmaphobic's avatar
dogmaphobic committed
            return qgcPal.button;
        if (activeVehicle.messageTypeNorma)
dogmaphobic's avatar
dogmaphobic committed
            return colorBlue;
        if (activeVehicle.messageTypeWarning)
dogmaphobic's avatar
dogmaphobic committed
            return colorOrange;
        if (activeVehicle.messageTypeError)
dogmaphobic's avatar
dogmaphobic committed
            return colorRed;
        // Cannot be so make make it obnoxious to show error
        return "purple";
    }

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

    function getBatteryIcon() {
        if(activeVehicle.batteryPercent < 20.0)
Don Gagne's avatar
Don Gagne committed
            return "qrc:/res/Battery_0";
        else if(activeVehicle.batteryPercent < 40.0)
Don Gagne's avatar
Don Gagne committed
            return "qrc:/res/Battery_20";
        else if(activeVehicle.batteryPercent < 60.0)
Don Gagne's avatar
Don Gagne committed
            return "qrc:/res/Battery_40";
        else if(activeVehicle.batteryPercent < 80.0)
Don Gagne's avatar
Don Gagne committed
            return "qrc:/res/Battery_60";
        else if(activeVehicle.batteryPercent < 90.0)
Don Gagne's avatar
Don Gagne committed
            return "qrc:/res/Battery_80";
dogmaphobic's avatar
dogmaphobic committed
        else
Don Gagne's avatar
Don Gagne committed
            return "qrc:/res/Battery_100";
dogmaphobic's avatar
dogmaphobic committed
    function getBatteryColor() {
        if (activeVehicle.batteryPercent > 40.0)
dogmaphobic's avatar
dogmaphobic committed
            return colorGreen;
        if(activeVehicle.batteryPercent > 0.01)
dogmaphobic's avatar
dogmaphobic committed
            return colorRed;
        // This means there is no battery level data
        return colorBlue;
    }

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

    function getRSSIColor(value) {
        if(value < 10)
            return colorRed;
        if(value < 50)
            return colorOrange;
        return colorGreen;
dogmaphobic's avatar
dogmaphobic committed
    function showMavStatus() {
         return (multiVehicleManager.activeVehicleAvailable && activeVehicle.heartbeatTimeout === 0 && _controller.connectionCount > 0);
dogmaphobic's avatar
dogmaphobic committed
    //-------------------------------------------------------------------------
    //-- Main menu for Mobile Devices
    Menu {
        id: maintMenu
dogmaphobic's avatar
dogmaphobic committed
        ExclusiveGroup { id: mainMenuGroup }
dogmaphobic's avatar
dogmaphobic committed
        MenuItem {
            id:             flyViewShowing
            text:           "Fly"
            checkable:      true
            checked:        true
dogmaphobic's avatar
dogmaphobic committed
            exclusiveGroup: mainMenuGroup

            onTriggered: {
                checked = true
                _controller.onFlyView();
dogmaphobic's avatar
dogmaphobic committed
            }
        }
dogmaphobic's avatar
dogmaphobic committed
        MenuItem {
            id:             setupViewShowing
            text:           "Setup"
            checkable:      true
dogmaphobic's avatar
dogmaphobic committed
            exclusiveGroup: mainMenuGroup

            onTriggered: {
                checked = true
                _controller.onSetupView();
dogmaphobic's avatar
dogmaphobic committed
            }
        }
dogmaphobic's avatar
dogmaphobic committed
        MenuItem {
            id:             planViewShowing
            text:           "Plan"
            checkable:      true
dogmaphobic's avatar
dogmaphobic committed
            exclusiveGroup: mainMenuGroup

            onTriggered: {
                checked = true
                _controller.onPlanView();
dogmaphobic's avatar
dogmaphobic committed
            }
        }
Don Gagne's avatar
Don Gagne committed

        MenuSeparator { }


        MenuItem {
            text:           "QGroundControl Settings"

            onTriggered: controller.showSettings()
        }
Don Gagne's avatar
Don Gagne committed
    } // Menu
dogmaphobic's avatar
dogmaphobic committed

    Component {
        id: activeVehicleComponent
            height:     cellHeight
            spacing:    cellSpacerSize
dogmaphobic's avatar
dogmaphobic committed

dogmaphobic's avatar
dogmaphobic committed
            Rectangle {
                id: messages
                width: (activeVehicle.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60)
                height: cellHeight
dogmaphobic's avatar
dogmaphobic committed
                anchors.verticalCenter: parent.verticalCenter
                color:  getMessageColor()
                border.color: "#00000000"
                border.width: 0
                property bool showTriangle: false

                Image {
                    id: messageIcon
                    source: getMessageIcon();
dogmaphobic's avatar
dogmaphobic committed
                    height: getProportionalDimmension(16)
                    fillMode: Image.PreserveAspectFit
dogmaphobic's avatar
dogmaphobic committed
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(8)
dogmaphobic's avatar
dogmaphobic committed
                Item {
                    id: messageTextRect
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
                    width: messages.width - messageIcon.width
                        id: messageText
                        text: (activeVehicle.messageCount > 0) ? activeVehicle.messageCount : ''
Don Gagne's avatar
Don Gagne committed
                        font.pixelSize: ScreenTools.smallFontPixelSize
                        font.weight: Font.DemiBold
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.horizontalCenter: parent.horizontalCenter
                        horizontalAlignment: Text.AlignHCenter
                        color: colorWhite
                    }
                }
                Image {
                    id: dropDown
                    source: "/qmlimages/arrow-down.png"
                    visible: (messages.showTriangle) && (activeVehicle.messageCount > 0)
                    anchors.bottom: parent.bottom
                    anchors.right: parent.right
dogmaphobic's avatar
dogmaphobic committed
                    anchors.bottomMargin: getProportionalDimmension(3)
                    anchors.rightMargin:  getProportionalDimmension(3)
                Timer {
                    id: mouseOffTimer
                    interval: 2000;
                    running: false;
                    repeat: false
                    onTriggered: {
                        messages.showTriangle = false;
                    }
dogmaphobic's avatar
dogmaphobic committed
                }

                MouseArea {
                    anchors.fill: parent
                    hoverEnabled: true
                    onEntered: {
                        messages.showTriangle = true;
                        mouseOffTimer.start();
                    }
                    onClicked: {
dogmaphobic's avatar
dogmaphobic committed
                        var p = mapToItem(toolBarHolder, mouseX, mouseY);
                        _controller.onEnterMessageArea(p.x, p.y);
dogmaphobic's avatar
dogmaphobic committed
                    }
Don Gagne's avatar
Don Gagne committed
            QGCButton {
                width:                  ScreenTools.defaultFontPixelWidth * 12
                height:                 cellHeight
dogmaphobic's avatar
dogmaphobic committed
                anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
                text:                   "Vehicle " + activeVehicle.id

                menu: vehicleMenu

                Menu {
                    id: vehicleMenu
                }

                Component {
                    id: vehicleMenuItemComponent

                    MenuItem {
                        checkable:      true
                        checked:        vehicle.active
                        onTriggered:    multiVehicleManager.activeVehicle = vehicle

                        property int vehicleId: Number(text.split(" ")[1])
                        property var vehicle:   multiVehicleManager.getVehicleById(vehicleId)
                    }
                }

                property var vehicleMenuItems: []

                function updateVehicleMenu() {
                    // Remove old menu items
                    for (var i=0; i<vehicleMenuItems.length; i++) {
                        vehicleMenu.removeItem(vehicleMenuItems[i])
                    }
                    vehicleMenuItems.length = 0

                    // Add new items
                    for (var i=0; i<multiVehicleManager.vehicles.count; i++) {
                        var vehicle = multiVehicleManager.vehicles.get(i)
                        var menuItem = vehicleMenuItemComponent.createObject(null, { "text": "Vehicle " + vehicle.id })
                        vehicleMenuItems.push(menuItem)
                        vehicleMenu.insertItem(i, menuItem)
                    }
                }

                Component.onCompleted: updateVehicleMenu()

                Connections {
                    target:         multiVehicleManager.vehicles
                    onCountChanged: parent.updateVehicleMenu
            Rectangle {
                id: satelitte
                width:  getProportionalDimmension(55)
                height: cellHeight
dogmaphobic's avatar
dogmaphobic committed
                anchors.verticalCenter: parent.verticalCenter
                color:  getSatelliteColor();
                border.color: "#00000000"
                border.width: 0

                Image {
Don Gagne's avatar
Don Gagne committed
                    source: "qrc:/res/Gps";
dogmaphobic's avatar
dogmaphobic committed
                    height: getProportionalDimmension(24)
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }

                    id: satelitteText
                    text: activeVehicle.satelliteCount >= 0 ? activeVehicle.satelliteCount : 'NA'
                    font.pixelSize: activeVehicle.satelliteCount >= 0 ? ScreenTools.defaultFontPixelSize : ScreenTools.smallFontPixelSize
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right: parent.right
                    anchors.rightMargin: getProportionalDimmension(6)
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }
            Rectangle {
                id: rssiRC
                width:  getProportionalDimmension(55)
                height: cellHeight
                visible: _controller.remoteRSSI <= 100
                anchors.verticalCenter: parent.verticalCenter
                color:  getRSSIColor(_controller.remoteRSSI);
                border.color: "#00000000"
                border.width: 0
                Image {
                    source: "qrc:/res/AntennaRC";
                    width: cellHeight * 0.7
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }
                QGCLabel {
                    text: _controller.remoteRSSI
                    anchors.right: parent.right
                    anchors.rightMargin: getProportionalDimmension(6)
                    anchors.verticalCenter: parent.verticalCenter
                    horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
                    font.pixelSize: ScreenTools.smallFontPixelSize
                    font.weight: Font.DemiBold
                    color: colorWhite
                }
            }
            Rectangle {
                id: rssiTelemetry
                width:  getProportionalDimmension(80)
                height: cellHeight
                visible: (_controller.telemetryRRSSI > 0) && (_controller.telemetryLRSSI > 0)
                anchors.verticalCenter: parent.verticalCenter
                color:  getRSSIColor(Math.min(_controller.telemetryRRSSI,_controller.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
                }
                Column {
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right:          parent.right
                    anchors.rightMargin:    getProportionalDimmension(6)
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
                            text: 'R '
Don Gagne's avatar
Don Gagne committed
                            font.pixelSize: ScreenTools.smallFontPixelSize
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
                            text: _controller.telemetryRRSSI + 'dB'
                            width: getProportionalDimmension(30)
                            horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
                            font.pixelSize: ScreenTools.smallFontPixelSize
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                    Row {
                        anchors.right: parent.right
                        QGCLabel {
                            text: 'L '
Don Gagne's avatar
Don Gagne committed
                            font.pixelSize: ScreenTools.smallFontPixelSize
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                        QGCLabel {
                            text: _controller.telemetryLRSSI + 'dB'
                            width: getProportionalDimmension(30)
                            horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
                            font.pixelSize: ScreenTools.smallFontPixelSize
                            font.weight: Font.DemiBold
                            color: colorWhite
                        }
                    }
                }
            }

            Rectangle {
                id: batteryStatus
                width:  activeVehicle.batteryConsumed < 0.0 ? getProportionalDimmension(60) : getProportionalDimmension(80)
                height: cellHeight
dogmaphobic's avatar
dogmaphobic committed
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
                color:  getBatteryColor();
                border.color: "#00000000"
                border.width: 0
                Image {
                    source: getBatteryIcon();
dogmaphobic's avatar
dogmaphobic committed
                    height: getProportionalDimmension(20)
                    fillMode: Image.PreserveAspectFit
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
dogmaphobic's avatar
dogmaphobic committed
                    anchors.leftMargin: getProportionalDimmension(6)
                    mipmap: true
                    smooth: true
                }

                    visible: batteryStatus.visible && activeVehicle.batteryConsumed < 0.0
                    text: (activeVehicle.batteryVoltage > 0) ? activeVehicle.batteryVoltage.toFixed(1) + 'V' : '---';
Don Gagne's avatar
Don Gagne committed
                    font.pixelSize: ScreenTools.smallFontPixelSize
                    font.weight: Font.DemiBold
                    anchors.right: parent.right
                    anchors.rightMargin: getProportionalDimmension(6)
dogmaphobic's avatar
dogmaphobic committed
                    anchors.verticalCenter: parent.verticalCenter
                    horizontalAlignment: Text.AlignRight
                    color: colorWhite
                }

                Column {
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.right:          parent.right
                    anchors.rightMargin:    getProportionalDimmension(6)
                    visible: batteryStatus.visible && activeVehicle.batteryConsumed >= 0.0
                        text: (activeVehicle.batteryVoltage > 0) ? activeVehicle.batteryVoltage.toFixed(1) + 'V' : '---';
                        width: getProportionalDimmension(30)
                        horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
                        font.pixelSize: ScreenTools.smallFontPixelSize
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                    QGCLabel {
                        text: (activeVehicle.batteryConsumed > 0) ? activeVehicle.batteryConsumed.toFixed(0) + 'mAh' : '---';
                        width: getProportionalDimmension(30)
                        horizontalAlignment: Text.AlignRight
Don Gagne's avatar
Don Gagne committed
                        font.pixelSize: ScreenTools.smallFontPixelSize
                        font.weight: Font.DemiBold
                        color: colorWhite
                    }
                }
Don Gagne's avatar
Don Gagne committed
            QGCButton {
                width:                  ScreenTools.defaultFontPixelWidth * 11
                height:                 cellHeight
dogmaphobic's avatar
dogmaphobic committed
                anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
                text:                   activeVehicle.armed ? "Armed" : "Disarmed"
Don Gagne's avatar
Don Gagne committed
                menu: Menu {
                    MenuItem {
                        enabled: !activeVehicle.armed
                        text: "Arm"
Don Gagne's avatar
Don Gagne committed
                        onTriggered: activeVehicle.armed = true
                    }

                    MenuItem {
                        enabled: activeVehicle.armed
                        text: "Disarm"

                        onTriggered: activeVehicle.armed = false
Don Gagne's avatar
Don Gagne committed
            QGCButton {
                width:                  ScreenTools.defaultFontPixelWidth * 15
                height:                 cellHeight
                anchors.verticalCenter: parent.verticalCenter
                text:                   activeVehicle.flightMode
                menu: activeVehicle.flightModeSetAvailable ? flightModesMenu : null
Don Gagne's avatar
Don Gagne committed

                Menu {
                    id: flightModesMenu
                }

                Component {
                    id: flightModeMenuItemComponent

                    MenuItem {
                        checkable:      true
                        checked:        activeVehicle.flightMode == text
                        onTriggered:    activeVehicle.flightMode = text
Don Gagne's avatar
Don Gagne committed
                property var flightModesMenuItems: []

                function updateFlightModesMenu() {
                    if (activeVehicle.flightModeSetAvailable) {
                        // Remove old menu items
                        for (var i=0; i<flightModesMenuItems.length; i++) {
                            flightModesMenu.removeItem(flightModesMenuItems[i])
                        }
                        flightModesMenuItems.length = 0

                            // Add new items
                            for (var i=0; i<activeVehicle.flightModes.length; i++) {
                                var menuItem = flightModeMenuItemComponent.createObject(null, { "text": activeVehicle.flightModes[i] })
                                flightModesMenuItems.push(menuItem)
                                flightModesMenu.insertItem(i, menuItem)
                            }
Don Gagne's avatar
Don Gagne committed
                    }
                }

                Component.onCompleted: updateFlightModesMenu()

                Connections {
                    target:                 multiVehicleManager
                    onActiveVehicleChanged: parent.updateFlightModesMenu
                }
dogmaphobic's avatar
dogmaphobic committed

            Rectangle {
Don Gagne's avatar
Don Gagne committed
                width:                  ScreenTools.defaultFontPixelWidth * 4
                height:                 cellHeight
                anchors.verticalCenter: parent.verticalCenter
                color:                  colorBlue
                border.width:           0
                visible:                activeVehicle.hilMode
Don Gagne's avatar
Don Gagne committed
                    anchors.fill:           parent
                    horizontalAlignment:    Text.AlignHCenter
                    verticalAlignment:      Text.AlignVCenter
                    text:                   "HIL"
        } // Row
    } // Component - activeVehicleComponent

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

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

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

            ExclusiveGroup { id: mainActionGroup }

            QGCToolBarButton {
                id:             setupButton
                width:          getProportionalDimmension(90)
                height:         cellHeight
                exclusiveGroup: mainActionGroup
                    checked = true
                    _controller.onSetupView();
                }
                z: 1000
            }

            QGCToolBarButton {
                id:             planButton
                width:          getProportionalDimmension(90)
                height:         cellHeight
                exclusiveGroup: mainActionGroup
                    checked = true
                    _controller.onPlanView();
                id:             flyButton
                width:          getProportionalDimmension(90)
                height:         cellHeight
                exclusiveGroup: mainActionGroup
                text:           "Fly"
                checked:        true

                    checked = true
                    _controller.onFlyView();
                }
                z: 800
            }
        } // Row

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

            //-- "Hamburger" menu for Mobile Devices
            Item {
                id:         actionButton
                visible:    ScreenTools.isMobile
                height:     cellHeight
                width:      cellHeight
                Image {
                    id:             buttomImg
                    anchors.fill:   parent
                    source:         "/qmlimages/buttonMore.svg"
                    mipmap:         true
                    smooth:         true
                    antialiasing:   true
                    fillMode:       Image.PreserveAspectFit
                }
                MouseArea {
                    anchors.fill: parent
                    acceptedButtons: Qt.LeftButton
                    onClicked: {
                        if (mouse.button == Qt.LeftButton)
                        {
                            maintMenu.popup();
                        }
                    }
                }
            }

            //-- Separator if Hamburger menu is visible
            Rectangle {
                visible:    actionButton.visible
                height:     cellHeight
                width:      cellHeight
                color:      "#00000000"
                anchors.verticalCenter: parent.verticalCenter
            }

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

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

            Rectangle {
                id: connectionStatus
dogmaphobic's avatar
dogmaphobic committed
                width: getProportionalDimmension(160)
                height: cellHeight
                visible: (_controller.connectionCount > 0 && multiVehicleManager.activeVehicleAvailable && activeVehicle.heartbeatTimeout != 0)
                anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0

                    id: connectionStatusText
                    text: qsTr("CONNECTION LOST")
Don Gagne's avatar
Don Gagne committed
                    font.pixelSize: ScreenTools.defaultFontPixelSize
dogmaphobic's avatar
dogmaphobic committed
                    font.weight: Font.DemiBold
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                    color: colorRedText
Don Gagne's avatar
Don Gagne committed
        } // Row
    } // Row
dogmaphobic's avatar
dogmaphobic committed

    Row {
Don Gagne's avatar
Don Gagne committed
        id:                     connectRow
        anchors.rightMargin:    verticalMargins
        anchors.right:          parent.right
        anchors.top:            toolRow.top
        anchors.verticalCenter: toolRow.verticalCenter
        height:                 toolRow.height
        spacing:                cellSpacerSize
dogmaphobic's avatar
dogmaphobic committed
        Menu {
            id: connectMenu
dogmaphobic's avatar
dogmaphobic committed
            Component.onCompleted: {
                _controller.configListChanged.connect(connectMenu.updateConnectionList);
dogmaphobic's avatar
dogmaphobic committed
                connectMenu.updateConnectionList();
dogmaphobic's avatar
dogmaphobic committed
            }
dogmaphobic's avatar
dogmaphobic committed
            function addMenuEntry(name) {
                var label = "Add Connection"
                if(name !== "")
                    label = name;
                var mItem = connectMenu.addItem(label);
                var menuSlot = function() {_controller.onConnect(name)};
dogmaphobic's avatar
dogmaphobic committed
                mItem.triggered.connect(menuSlot);
            }
            function updateConnectionList() {
                connectMenu.clear();
                for(var i = 0; i < _controller.configList.length; i++) {
                    connectMenu.addMenuEntry(_controller.configList[i]);
dogmaphobic's avatar
dogmaphobic committed
                }
                if(_controller.configList.length > 0) {
dogmaphobic's avatar
dogmaphobic committed
                    connectMenu.addSeparator();
                }
                // Add "Add Connection" to the list
                connectMenu.addMenuEntry("");
dogmaphobic's avatar
dogmaphobic committed
            }
        }

        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
            id:         connectButton
dogmaphobic's avatar
dogmaphobic committed
            width:      getProportionalDimmension(100)
            visible:    _controller.connectionCount === 0
dogmaphobic's avatar
dogmaphobic committed
            text:       qsTr("Connect")
            menu:       connectMenu
        }

        QGCButton {
            id:         disconnectButton
dogmaphobic's avatar
dogmaphobic committed
            width:      getProportionalDimmension(100)
            visible:    _controller.connectionCount === 1
dogmaphobic's avatar
dogmaphobic committed
            text:       qsTr("Disconnect")
dogmaphobic's avatar
dogmaphobic committed
            onClicked: {
                _controller.onDisconnect("");
dogmaphobic's avatar
dogmaphobic committed
            }
        }

        Menu {
            id: disconnectMenu
            Component.onCompleted: {
                _controller.connectedListChanged.connect(disconnectMenu.onConnectedListChanged)
dogmaphobic's avatar
dogmaphobic committed
            }
dogmaphobic's avatar
dogmaphobic committed
            function addMenuEntry(name) {
                var mItem = disconnectMenu.addItem(name);
                var menuSlot = function() {_controller.onDisconnect(name)};
dogmaphobic's avatar
dogmaphobic committed
                mItem.triggered.connect(menuSlot);
            }
dogmaphobic's avatar
dogmaphobic committed
            function onConnectedListChanged(conList) {
                disconnectMenu.clear();
                for(var i = 0; i < conList.length; i++) {
dogmaphobic's avatar
dogmaphobic committed
                    disconnectMenu.addMenuEntry(conList[i]);
dogmaphobic's avatar
dogmaphobic committed
            id:         multidisconnectButton
dogmaphobic's avatar
dogmaphobic committed
            width:      getProportionalDimmension(100)
dogmaphobic's avatar
dogmaphobic committed
            text:       "Disconnect"
            visible:    _controller.connectionCount > 1
dogmaphobic's avatar
dogmaphobic committed
            menu:       disconnectMenu
dogmaphobic's avatar
dogmaphobic committed
        }
Don Gagne's avatar
Don Gagne committed
    } // Row

    // Progress bar
    Rectangle {
Don Gagne's avatar
Don Gagne committed
        id:             progressBar
        anchors.top:    toolRow.bottom
        height:         getProportionalDimmension(3)
        width:          parent.width * _controller.progressBarValue
Don Gagne's avatar
Don Gagne committed
        color:          qgcPal.text
Don Gagne's avatar
Don Gagne committed
    // Toolbar message area
    Rectangle {
        id:                     toolBarMessageArea
        anchors.leftMargin:     horizontalMargins
        anchors.rightMargin:    horizontalMargins
        anchors.topMargin:      verticalMargins
        anchors.bottomMargin:   verticalMargins
        anchors.top:            progressBar.bottom
        anchors.bottom:         parent.bottom
        anchors.left:           parent.left
        anchors.right:          parent.right
        color:                  qgcPal.windowShadeDark
        visible:                false
Don Gagne's avatar
Don Gagne committed

        QGCLabel {
            id:             toolBarMessage
            anchors.fill:   parent
            wrapMode:       Text.WordWrap
			color:			qgcPal.warningText
Don Gagne's avatar
Don Gagne committed
        }

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

            onClicked: {
                parent.visible = false
Don Gagne's avatar
Don Gagne committed
                toolBarHolder.height = toolBarHeight
                _controller.onToolBarMessageClosed()
Don Gagne's avatar
Don Gagne committed
            }
        }
    }
} // Rectangle