MainToolBar.qml 8.9 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.3
import QtQuick.Layouts      1.2
import QtQuick.Controls     1.2
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
Rectangle {
22
    id:         toolBar
23
    color:      qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.8) : Qt.rgba(0,0,0,0.75)
dogmaphobic's avatar
dogmaphobic committed
24

Don Gagne's avatar
Don Gagne committed
25
    QGCPalette { id: qgcPal; colorGroupEnabled: true }
26

Don Gagne's avatar
Don Gagne committed
27 28
    property var  _activeVehicle:       QGroundControl.multiVehicleManager.activeVehicle
    property bool isMessageImportant:   _activeVehicle ? !_activeVehicle.messageTypeNormal && !_activeVehicle.messageTypeNone : false
dogmaphobic's avatar
dogmaphobic committed
29
    property bool isBackgroundDark:     true
dogmaphobic's avatar
dogmaphobic committed
30
    property bool opaqueBackground:     false
31

Don Gagne's avatar
Don Gagne committed
32 33 34 35 36 37
    readonly property color colorGreen:     "#05f068"
    readonly property color colorOrange:    "#f0ab06"
    readonly property color colorRed:       "#fc4638"
    readonly property color colorGrey:      "#7f7f7f"
    readonly property color colorBlue:      "#636efe"
    readonly property color colorWhite:     "#ffffff"
38

Don Gagne's avatar
Don Gagne committed
39 40 41 42 43
    signal showSettingsView
    signal showSetupView
    signal showPlanView
    signal showFlyView
    signal showAnalyzeView
Don Gagne's avatar
Don Gagne committed
44

45
    function checkSettingsButton() {
46
        settingsButton.checked = true
47 48
    }

Don Gagne's avatar
Don Gagne committed
49 50 51 52 53 54 55 56 57 58 59 60
    function checkSetupButton() {
        setupButton.checked = true
    }

    function checkPlanButton() {
        planButton.checked = true
    }

    function checkFlyButton() {
        flyButton.checked = true
    }

Don Gagne's avatar
Don Gagne committed
61 62 63 64
    function checkAnalyzeButton() {
        analyzeButton.checked = true
    }

dogmaphobic's avatar
dogmaphobic committed
65 66 67 68
    Component.onCompleted: {
        //-- TODO: Get this from the actual state
        flyButton.checked = true
    }
69

DonLakeFlyer's avatar
DonLakeFlyer committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
    // Easter egg mechanism
    MouseArea {
        anchors.fill: parent
        onClicked: {
            console.log("easter egg click", ++_clickCount)
            eggTimer.restart()
            if (_clickCount == 5) {
                QGroundControl.showAdvancedUI = true
            } else if (_clickCount == 7) {
                QGroundControl.showTouchAreas = true
            }
        }

        property int _clickCount: 0

        Timer {
            id:             eggTimer
            interval:       1000
            onTriggered:    parent._clickCount = 0
        }
    }

Don Gagne's avatar
Don Gagne committed
92
    /// Bottom single pixel divider
93 94 95 96 97 98
    Rectangle {
        anchors.left:   parent.left
        anchors.right:  parent.right
        anchors.bottom: parent.bottom
        height:         1
        color:          "black"
dogmaphobic's avatar
dogmaphobic committed
99 100 101
        visible:        qgcPal.globalTheme == QGCPalette.Light
    }

Don Gagne's avatar
Don Gagne committed
102
    RowLayout {
103
        anchors.bottomMargin:   1
Don Gagne's avatar
Don Gagne committed
104 105
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth / 2
        anchors.fill:           parent
Don Gagne's avatar
Don Gagne committed
106
        spacing:                ScreenTools.defaultFontPixelWidth * 2
Don Gagne's avatar
Don Gagne committed
107 108 109 110 111 112 113

        //---------------------------------------------
        // Toolbar Row
        Row {
            id:             viewRow
            anchors.top:    parent.top
            anchors.bottom: parent.bottom
Don Gagne's avatar
Don Gagne committed
114
            spacing:        ScreenTools.defaultFontPixelWidth / 2
Don Gagne's avatar
Don Gagne committed
115 116 117 118 119 120 121 122 123 124 125 126 127

            ExclusiveGroup { id: mainActionGroup }

            QGCToolBarButton {
                id:                 settingsButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                exclusiveGroup:     mainActionGroup
                source:             "/res/QGCLogoWhite"
                logo:               true
                onClicked:          toolBar.showSettingsView()
                visible:            !QGroundControl.corePlugin.options.combineSettingsAndSetup
            }
128

Don Gagne's avatar
Don Gagne committed
129 130 131 132 133 134 135 136
            QGCToolBarButton {
                id:                 setupButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                exclusiveGroup:     mainActionGroup
                source:             "/qmlimages/Gears.svg"
                onClicked:          toolBar.showSetupView()
            }
137

Don Gagne's avatar
Don Gagne committed
138 139 140 141 142 143 144 145
            QGCToolBarButton {
                id:                 planButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                exclusiveGroup:     mainActionGroup
                source:             "/qmlimages/Plan.svg"
                onClicked:          toolBar.showPlanView()
            }
Don Gagne's avatar
Don Gagne committed
146

Don Gagne's avatar
Don Gagne committed
147 148 149 150 151 152 153 154
            QGCToolBarButton {
                id:                 flyButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                exclusiveGroup:     mainActionGroup
                source:             "/qmlimages/PaperPlane.svg"
                onClicked:          toolBar.showFlyView()
            }
Don Gagne's avatar
Don Gagne committed
155

Don Gagne's avatar
Don Gagne committed
156 157 158 159 160 161 162 163 164
            QGCToolBarButton {
                id:                 analyzeButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                exclusiveGroup:     mainActionGroup
                source:             "/qmlimages/Analyze.svg"
                visible:            !ScreenTools.isMobile
                onClicked:          toolBar.showAnalyzeView()
            }
Don Gagne's avatar
Don Gagne committed
165 166 167 168 169 170 171 172 173

            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
174
        }
175

Don Gagne's avatar
Don Gagne committed
176 177 178 179 180
        //-------------------------------------------------------------------------
        //-- Vehicle Selector
        QGCButton {
            id:                     vehicleSelectorButton
            width:                  ScreenTools.defaultFontPixelHeight * 8
Don Gagne's avatar
Don Gagne committed
181
            text:                   "Vehicle " + (_activeVehicle ? _activeVehicle.id : "None")
Don Gagne's avatar
Don Gagne committed
182 183
            visible:                QGroundControl.multiVehicleManager.vehicles.count > 1
            anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
184

Don Gagne's avatar
Don Gagne committed
185
            menu: vehicleMenu
Don Gagne's avatar
Don Gagne committed
186

Don Gagne's avatar
Don Gagne committed
187 188 189
            Menu {
                id: vehicleMenu
            }
dogmaphobic's avatar
dogmaphobic committed
190

Don Gagne's avatar
Don Gagne committed
191 192
            Component {
                id: vehicleMenuItemComponent
Don Gagne's avatar
Don Gagne committed
193

Don Gagne's avatar
Don Gagne committed
194
                MenuItem {
Don Gagne's avatar
Don Gagne committed
195
                    onTriggered: QGroundControl.multiVehicleManager.activeVehicle = vehicle
Don Gagne's avatar
Don Gagne committed
196 197 198 199 200 201 202

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

            property var vehicleMenuItems: []
203

Don Gagne's avatar
Don Gagne committed
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
            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<QGroundControl.multiVehicleManager.vehicles.count; i++) {
                    var vehicle = QGroundControl.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:         QGroundControl.multiVehicleManager.vehicles
                onCountChanged: vehicleSelectorButton.updateVehicleMenu()
            }
226 227
        }

Don Gagne's avatar
Don Gagne committed
228
        MainToolBarIndicators {
Don Gagne's avatar
Don Gagne committed
229 230 231 232 233
            anchors.margins:    ScreenTools.defaultFontPixelHeight * 0.66
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
            Layout.fillWidth:   true
            visible:            _activeVehicle
Don Gagne's avatar
Don Gagne committed
234
        }
235 236 237 238 239 240 241 242 243 244

        QGCLabel {
            id:                     waitForVehicle
            anchors.verticalCenter: parent.verticalCenter
            text:                   qsTr("Waiting For Vehicle Connection")
            font.pointSize:         ScreenTools.mediumFontPointSize
            font.family:            ScreenTools.demiboldFontFamily
            color:                  colorRed
            visible:                !_activeVehicle
        }
dogmaphobic's avatar
dogmaphobic committed
245
    }
dogmaphobic's avatar
dogmaphobic committed
246

247 248
    // Progress bar
    Rectangle {
Don Gagne's avatar
Don Gagne committed
249
        id:             progressBar
dogmaphobic's avatar
dogmaphobic committed
250 251
        anchors.bottom: parent.bottom
        height:         toolBar.height * 0.05
Don Gagne's avatar
Don Gagne committed
252
        width:          _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0
dogmaphobic's avatar
dogmaphobic committed
253
        color:          colorGreen
254
    }
dogmaphobic's avatar
dogmaphobic committed
255

256
}