Skip to content
MainToolBar.qml 6.57 KiB
Newer Older
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
import QtQuick          2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts  1.11
Don Gagne's avatar
Don Gagne committed
import QGroundControl                       1.0
import QGroundControl.Controls              1.0
import QGroundControl.Palette               1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.Controllers           1.0
    id:         toolBar
Don Gagne's avatar
Don Gagne committed

dogmaphobic's avatar
dogmaphobic committed
    Component.onCompleted: {
        //-- TODO: Get this from the actual state
        flyButton.checked = true
    }
Don Gagne's avatar
Don Gagne committed
    /// Bottom single pixel divider
    Rectangle {
        anchors.left:   parent.left
        anchors.right:  parent.right
        anchors.bottom: parent.bottom
        height:         1
        color:          "black"
        visible:        qgcPal.globalTheme === QGCPalette.Light
    //-- Setup can be invoked from c++ side
    Connections {
Gus Grubba's avatar
Gus Grubba committed
        target: setupWindow
        onVisibleChanged: {
            if(setupWindow.visible) {
Don Gagne's avatar
Don Gagne committed
    RowLayout {
        anchors.bottomMargin:   1
Don Gagne's avatar
Don Gagne committed
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth / 2
        anchors.fill:           parent
Don Gagne's avatar
Don Gagne committed
        spacing:                ScreenTools.defaultFontPixelWidth * 2
Don Gagne's avatar
Don Gagne committed

        ButtonGroup {
            buttons:            viewRow.children
        }

Don Gagne's avatar
Don Gagne committed
        //---------------------------------------------
        // Toolbar Row
        Row {
            id:                 viewRow
            Layout.fillHeight:  true
            spacing:            ScreenTools.defaultFontPixelWidth / 2
Don Gagne's avatar
Don Gagne committed

            QGCToolBarButton {
                id:                 settingsButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                icon.source:        "/res/QGCLogoWhite"
Don Gagne's avatar
Don Gagne committed
                logo:               true
                visible:            !QGroundControl.corePlugin.options.combineSettingsAndSetup
                onClicked: {
                    checked = true
                    mainWindow.showSettingsView()
                }
Don Gagne's avatar
Don Gagne committed
            }
Don Gagne's avatar
Don Gagne committed
            QGCToolBarButton {
                id:                 setupButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                icon.source:        "/qmlimages/Gears.svg"
                onClicked: {
                    checked = true
                    mainWindow.showSetupView()
                }
Don Gagne's avatar
Don Gagne committed
            }
Don Gagne's avatar
Don Gagne committed
            QGCToolBarButton {
                id:                 planButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                icon.source:        "/qmlimages/Plan.svg"
                onClicked: {
                    checked = true
                    mainWindow.showPlanView()
                }
Don Gagne's avatar
Don Gagne committed
            }
Don Gagne's avatar
Don Gagne committed
            QGCToolBarButton {
                id:                 flyButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                icon.source:        "/qmlimages/PaperPlane.svg"
                onClicked: {
                    checked = true
                    mainWindow.showFlyView()
                }
Don Gagne's avatar
Don Gagne committed
            }
Don Gagne's avatar
Don Gagne committed

Don Gagne's avatar
Don Gagne committed
            QGCToolBarButton {
                id:                 analyzeButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                icon.source:        "/qmlimages/Analyze.svg"
                visible:            QGroundControl.corePlugin.showAdvancedUI
                onClicked: {
                    checked = true
                    mainWindow.showAnalyzeView()
                }
Don Gagne's avatar
Don Gagne committed
            }
Don Gagne's avatar
Don Gagne committed

            Rectangle {
                anchors.margins:    ScreenTools.defaultFontPixelHeight / 2
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                width:              1
                color:              qgcPal.text
                visible:            activeVehicle
Don Gagne's avatar
Don Gagne committed
            }
        Loader {
            id:                 toolbarIndicators
            height:             parent.height
            source:             "/toolbar/MainToolBarIndicators.qml"
Don Gagne's avatar
Don Gagne committed
            Layout.fillWidth:   true
dogmaphobic's avatar
dogmaphobic committed
    }
    // Small parameter download progress bar
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
        anchors.bottom: parent.bottom
        height:         toolBar.height * 0.05
        width:          activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0
        color:          qgcPal.colorGreen
        visible:        !largeProgressBar.visible
    }

    // Large parameter download progress bar
    Rectangle {
        id:             largeProgressBar
        anchors.bottom: parent.bottom
        anchors.left:   parent.left
        anchors.right:  parent.right
        height:         parent.height
        color:          qgcPal.window
        visible:        _showLargeProgress

        property bool _initialDownloadComplete: activeVehicle ? activeVehicle.parameterManager.parametersReady : true
        property bool _userHide:                false
        property bool _showLargeProgress:       !_initialDownloadComplete && !_userHide && qgcPal.globalTheme === QGCPalette.Light

        Connections {
            target:                 QGroundControl.multiVehicleManager
            onActiveVehicleChanged: largeProgressBar._userHide = false
        }

        Rectangle {
            anchors.top:    parent.top
            anchors.bottom: parent.bottom
            width:          activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0
            color:          qgcPal.colorGreen
        }

        QGCLabel {
            anchors.centerIn:   parent
            text:               qsTr("Downloading Parameters")
            font.pointSize:     ScreenTools.largeFontPointSize
        }

        QGCLabel {
            anchors.margins:    _margin
            anchors.right:      parent.right
            anchors.bottom:     parent.bottom
            text:               qsTr("Click anywhere to hide")

            property real _margin: ScreenTools.defaultFontPixelWidth / 2
        }

        MouseArea {
            anchors.fill:   parent
            onClicked:      largeProgressBar._userHide = true
        }