CustomMainToolBar.qml 11.9 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
    //-------------------------------------------------------------------------
    //-- 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
Gus Grubba's avatar
Gus Grubba committed
48 49
        //-- Show full screen
        mainWindow.showFullScreen()
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 107 108
    }
    //-------------------------------------------------------------------------
    //-- 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
109
            color:                          menuSeparatorColor
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 153 154
            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
155
        color:                              menuSeparatorColor
156 157 158 159 160 161 162 163 164 165
    }
    //-------------------------------------------------------------------------
    //-- 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
166
            color:                          qgcPal.window
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
        }
        ButtonGroup {
            id:                             buttonGroup
            buttons:                        buttons.children
        }
        ColumnLayout {
            id:                             buttons
            anchors.top:                    parent.top
            anchors.left:                   parent.left
            anchors.right:                  parent.right
            spacing:                        ScreenTools.defaultFontPixelHeight * 0.125
            Rectangle {
                Layout.alignment:           Qt.AlignVCenter
                width:                      parent.width
                height:                     1
Gus Grubba's avatar
Gus Grubba committed
182
                color:                      menuSeparatorColor
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
            }
            CustomToolBarButton {
                id:                         flyButton
                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
200
                color:                      menuSeparatorColor
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
            }
            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
218
                color:                      menuSeparatorColor
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
            }
            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
235
                color:                      menuSeparatorColor
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
            }
            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
253
                color:                      menuSeparatorColor
254 255 256 257 258 259 260 261 262 263 264 265 266
            }
        }
        ColumnLayout {
            id:                             lowerButtons
            anchors.bottom:                 parent.bottom
            anchors.bottomMargin:           ScreenTools.defaultFontPixelHeight * 0.125
            anchors.left:                   parent.left
            anchors.right:                  parent.right
            spacing:                        ScreenTools.defaultFontPixelHeight * 0.125
            Rectangle {
                Layout.alignment:           Qt.AlignVCenter
                width:                      parent.width
                height:                     1
Gus Grubba's avatar
Gus Grubba committed
267
                color:                      menuSeparatorColor
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
            }
            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
            }
        }
    }
}