MainToolBar.qml 6.57 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
dogmaphobic's avatar
dogmaphobic committed
9

10 11 12
import QtQuick          2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts  1.11
dogmaphobic's avatar
dogmaphobic committed
13

Don Gagne's avatar
Don Gagne committed
14
import QGroundControl                       1.0
15 16 17 18
import QGroundControl.Controls              1.0
import QGroundControl.Palette               1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
19
import QGroundControl.Controllers           1.0
dogmaphobic's avatar
dogmaphobic committed
20

21
Item {
22
    id:         toolBar
Don Gagne's avatar
Don Gagne committed
23

dogmaphobic's avatar
dogmaphobic committed
24 25 26 27
    Component.onCompleted: {
        //-- TODO: Get this from the actual state
        flyButton.checked = true
    }
28

Don Gagne's avatar
Don Gagne committed
29
    /// Bottom single pixel divider
30 31 32 33 34 35
    Rectangle {
        anchors.left:   parent.left
        anchors.right:  parent.right
        anchors.bottom: parent.bottom
        height:         1
        color:          "black"
36
        visible:        qgcPal.globalTheme === QGCPalette.Light
dogmaphobic's avatar
dogmaphobic committed
37 38
    }

39 40
    //-- Setup can be invoked from c++ side
    Connections {
Gus Grubba's avatar
Gus Grubba committed
41 42 43
        target: setupWindow
        onVisibleChanged: {
            if(setupWindow.visible) {
44 45 46 47 48
                setupButton.checked = true
            }
        }
    }

Don Gagne's avatar
Don Gagne committed
49
    RowLayout {
50
        anchors.bottomMargin:   1
Don Gagne's avatar
Don Gagne committed
51 52
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth / 2
        anchors.fill:           parent
Don Gagne's avatar
Don Gagne committed
53
        spacing:                ScreenTools.defaultFontPixelWidth * 2
Don Gagne's avatar
Don Gagne committed
54

55 56 57 58
        ButtonGroup {
            buttons:            viewRow.children
        }

Don Gagne's avatar
Don Gagne committed
59 60 61
        //---------------------------------------------
        // Toolbar Row
        Row {
62 63 64
            id:                 viewRow
            Layout.fillHeight:  true
            spacing:            ScreenTools.defaultFontPixelWidth / 2
Don Gagne's avatar
Don Gagne committed
65 66 67 68 69

            QGCToolBarButton {
                id:                 settingsButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
70
                icon.source:        "/res/QGCLogoWhite"
Don Gagne's avatar
Don Gagne committed
71 72
                logo:               true
                visible:            !QGroundControl.corePlugin.options.combineSettingsAndSetup
73 74 75 76
                onClicked: {
                    checked = true
                    mainWindow.showSettingsView()
                }
Don Gagne's avatar
Don Gagne committed
77
            }
78

Don Gagne's avatar
Don Gagne committed
79 80 81 82
            QGCToolBarButton {
                id:                 setupButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
83 84 85 86 87
                icon.source:        "/qmlimages/Gears.svg"
                onClicked: {
                    checked = true
                    mainWindow.showSetupView()
                }
Don Gagne's avatar
Don Gagne committed
88
            }
89

Don Gagne's avatar
Don Gagne committed
90 91 92 93
            QGCToolBarButton {
                id:                 planButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
94 95 96 97 98
                icon.source:        "/qmlimages/Plan.svg"
                onClicked: {
                    checked = true
                    mainWindow.showPlanView()
                }
Don Gagne's avatar
Don Gagne committed
99
            }
Don Gagne's avatar
Don Gagne committed
100

Don Gagne's avatar
Don Gagne committed
101 102 103 104
            QGCToolBarButton {
                id:                 flyButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
105 106 107 108 109
                icon.source:        "/qmlimages/PaperPlane.svg"
                onClicked: {
                    checked = true
                    mainWindow.showFlyView()
                }
Don Gagne's avatar
Don Gagne committed
110
            }
Don Gagne's avatar
Don Gagne committed
111

Don Gagne's avatar
Don Gagne committed
112 113 114 115
            QGCToolBarButton {
                id:                 analyzeButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
116
                icon.source:        "/qmlimages/Analyze.svg"
117
                visible:            QGroundControl.corePlugin.showAdvancedUI
118 119 120 121
                onClicked: {
                    checked = true
                    mainWindow.showAnalyzeView()
                }
Don Gagne's avatar
Don Gagne committed
122
            }
Don Gagne's avatar
Don Gagne committed
123 124 125 126 127 128 129

            Rectangle {
                anchors.margins:    ScreenTools.defaultFontPixelHeight / 2
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                width:              1
                color:              qgcPal.text
130
                visible:            activeVehicle
Don Gagne's avatar
Don Gagne committed
131
            }
132 133
        }

134 135 136 137
        Loader {
            id:                 toolbarIndicators
            height:             parent.height
            source:             "/toolbar/MainToolBarIndicators.qml"
Don Gagne's avatar
Don Gagne committed
138
            Layout.fillWidth:   true
139
        }
dogmaphobic's avatar
dogmaphobic committed
140
    }
dogmaphobic's avatar
dogmaphobic committed
141

142
    // Small parameter download progress bar
143
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
144 145
        anchors.bottom: parent.bottom
        height:         toolBar.height * 0.05
146
        width:          activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0
147
        color:          qgcPal.colorGreen
148 149 150 151 152 153 154 155 156 157 158 159 160
        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

161
        property bool _initialDownloadComplete: activeVehicle ? activeVehicle.parameterManager.parametersReady : true
162 163 164 165 166 167 168 169 170 171 172
        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
173
            width:          activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
            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
        }
196
    }
197
}