CustomMainToolBar.qml 11.8 KB
Newer Older
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
/****************************************************************************
 *
 * (c) 2009-2019 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.
 *
 * @file
 *   @author Gus Grubba <gus@auterion.com>
 */

import QtQuick          2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts  1.11

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

import Custom.Widgets                       1.0

Item {
    id:                                     toolBar
    anchors.fill:                           parent
    property string sectionTitle:           qsTr("Fly")
    property bool   inPlanView:             planViewLoader.visible
    property bool   inFlyView:              rootBackground.visible
Gus Grubba's avatar
Gus Grubba committed
31
    property color  menuSeparatorColor:     qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
    //-------------------------------------------------------------------------
    //-- Setup can be invoked from c++ side
    Connections {
        target: setupWindow
        onVisibleChanged: {
            if(setupWindow.visible) {
                vehicleSetup.checked = true
                sectionTitle = vehicleSetup.text
            }
        }
    }
    //-------------------------------------------------------------------------
    //-- Initial State
    Component.onCompleted: {
        flyButton.checked = true
        sectionTitle = flyButton.text
    }
    //-------------------------------------------------------------------------
    //-- Fly/Plan state toggle
    onInPlanViewChanged: {
        if(inPlanView) {
            planButton.checked = true
            sectionTitle = planButton.text
        }
    }
    onInFlyViewChanged: {
        if(inFlyView) {
            flyButton.checked = true
            sectionTitle = flyButton.text
        }
    }
    Row {
        id:                                 iconRow
        height:                             parent.height
        anchors.left:                       parent.left
        spacing:                            ScreenTools.defaultFontPixelWidth * 2

        CustomIconButton {
            height:                         parent.height
            onPressed: {
                if(drawer.visible) {
                    drawer.close()
                } else {
                    drawer.open()
                }
                // Easter egg mechanism
                _pressCount++
                eggTimer.restart()
                if (_pressCount == 5) {
                    QGroundControl.corePlugin.showAdvancedUI = !QGroundControl.corePlugin.showAdvancedUI
                }
            }
            property int _pressCount: 0
            Timer {
                id:             eggTimer
                interval:       1000
                onTriggered:    parent._pressCount = 0
            }
        }
        Rectangle {
            width:                          1
            height:                         parent.height
            color:                          qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.15) : Qt.rgba(1,1,1,0.15)
        }
        //-------------------------------------------------------------------------
        //-- Multi Vehicle Selector
        Loader {
            anchors.top:                    parent.top
            anchors.bottom:                 parent.bottom
            source:                         "/custom/CustomMultiVehicleSelector.qml"
            visible:                        activeVehicle && !inPlanView
        }
        Rectangle {
            width:                          1
            height:                         parent.height
Gus Grubba's avatar
Gus Grubba committed
107
            color:                          menuSeparatorColor
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
            visible:                        activeVehicle && !inPlanView
        }
        //-------------------------------------------------------------------------
        //-- Flight Mode
        Loader {
            anchors.top:                    parent.top
            anchors.bottom:                 parent.bottom
            source:                         "/custom/CustomModeIndicator.qml"
            visible:                        activeVehicle && !inPlanView
        }
    }
    //-------------------------------------------------------------------------
    //-- Arm/Disarm
    Loader {
        anchors.top:                        parent.top
        anchors.bottom:                     parent.bottom
        anchors.horizontalCenter:           parent.horizontalCenter
        source:                             "/custom/CustomArmedIndicator.qml"
        visible:                            activeVehicle && !inPlanView
    }
    //-------------------------------------------------------------------------
    // Indicators
    Loader {
        source:                             inPlanView ? "/qml/PlanToolBarIndicators.qml" : "/custom/CustomMainToolBarIndicators.qml"
        anchors.left:                       iconRow.right
        anchors.leftMargin:                 ScreenTools.defaultFontPixelWidth * 2
        anchors.right:                      parent.right
        anchors.top:                        parent.top
        anchors.bottom:                     parent.bottom
    }
    //-------------------------------------------------------------------------
    // Parameter download progress bar
    Rectangle {
        anchors.bottom:                     parent.bottom
        height:                             ScreenTools.defaultFontPixelheight * 0.25
        width:                              activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0
        color:                              qgcPal.colorGreen
    }
    //-------------------------------------------------------------------------
    // Bottom single pixel divider
    Rectangle {
        anchors.left:                       parent.left
        anchors.right:                      parent.right
        anchors.bottom:                     parent.bottom
        height:                             1
Gus Grubba's avatar
Gus Grubba committed
153
        color:                              menuSeparatorColor
154 155 156 157 158 159 160 161 162 163
    }
    //-------------------------------------------------------------------------
    //-- Navigation Drawer (Left to Right, on command or using touch gestures)
    Drawer {
        id:                                 drawer
        y:                                  header.height
        width:                              navButtonWidth
        height:                             mainWindow.height - header.height
        closePolicy:                        Popup.CloseOnEscape | Popup.CloseOnPressOutside
        background: Rectangle {
Gus Grubba's avatar
Gus Grubba committed
164
            color:                          qgcPal.window
165 166 167 168 169 170 171
        }
        ButtonGroup {
            id:                             buttonGroup
            buttons:                        buttons.children
        }
        ColumnLayout {
            id:                             buttons
172
            spacing:                        0
173 174 175 176 177 178 179
            anchors.top:                    parent.top
            anchors.left:                   parent.left
            anchors.right:                  parent.right
            Rectangle {
                Layout.alignment:           Qt.AlignVCenter
                width:                      parent.width
                height:                     1
Gus Grubba's avatar
Gus Grubba committed
180
                color:                      menuSeparatorColor
181 182 183
            }
            CustomToolBarButton {
                id:                         flyButton
184
                spacing:                    1
185 186 187 188 189 190 191 192 193 194 195 196 197 198
                text:                       qsTr("Fly")
                icon.source:                "/qmlimages/PaperPlane.svg"
                Layout.fillWidth:           true
                onClicked: {
                    checked = true
                    drawer.close()
                    sectionTitle = text
                    mainWindow.showFlyView()
                }
            }
            Rectangle {
                Layout.alignment:           Qt.AlignVCenter
                width:                      parent.width
                height:                     1
Gus Grubba's avatar
Gus Grubba committed
199
                color:                      menuSeparatorColor
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
            }
            CustomToolBarButton {
                id:                         planButton
                text:                       qsTr("Plan")
                icon.source:                "/qmlimages/Plan.svg"
                Layout.fillWidth:           true
                onClicked: {
                    checked = true
                    drawer.close()
                    sectionTitle = text
                    mainWindow.showPlanView()
                }
            }
            Rectangle {
                Layout.alignment:           Qt.AlignVCenter
                width:                      parent.width
                height:                     1
Gus Grubba's avatar
Gus Grubba committed
217
                color:                      menuSeparatorColor
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
            }
            CustomToolBarButton {
                text:                       qsTr("Analyze")
                icon.source:                "/qmlimages/Analyze.svg"
                Layout.fillWidth:           true
                onClicked: {
                    checked = true
                    drawer.close()
                    sectionTitle = text
                    mainWindow.showAnalyzeView()
                }
            }
            Rectangle {
                Layout.alignment:           Qt.AlignVCenter
                width:                      parent.width
                height:                     1
Gus Grubba's avatar
Gus Grubba committed
234
                color:                      menuSeparatorColor
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
            }
            CustomToolBarButton {
                id:                         vehicleSetup
                text:                       qsTr("Vehicle Setup")
                icon.source:                "/qmlimages/Gears.svg"
                Layout.fillWidth:           true
                onClicked: {
                    checked = true
                    drawer.close()
                    sectionTitle = text
                    mainWindow.showSetupView()
                }
            }
            Rectangle {
                Layout.alignment:           Qt.AlignVCenter
                width:                      parent.width
                height:                     1
Gus Grubba's avatar
Gus Grubba committed
252
                color:                      menuSeparatorColor
253 254 255 256 257 258 259
            }
        }
        ColumnLayout {
            id:                             lowerButtons
            anchors.bottom:                 parent.bottom
            anchors.left:                   parent.left
            anchors.right:                  parent.right
260
            spacing:                        0
261 262 263 264
            Rectangle {
                Layout.alignment:           Qt.AlignVCenter
                width:                      parent.width
                height:                     1
Gus Grubba's avatar
Gus Grubba committed
265
                color:                      menuSeparatorColor
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
            }
            CustomToolBarButton {
                id:                         settingsButton
                text:                       qsTr("Settings")
                icon.source:                "/qmlimages/Gears.svg"
                Layout.fillWidth:           true
                onClicked: {
                    checked = true
                    buttonGroup.checkState = Qt.Unchecked
                    drawer.close()
                    sectionTitle = text
                    mainWindow.showSettingsView()
                }
            }
            Connections {
                target:                     buttonGroup
                onClicked:                  settingsButton.checked = false
            }
        }
    }
}