Newer
Older
/****************************************************************************
*
* (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
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
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
}
//-------------------------------------------------------------------------
//-- 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 {
}
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
}
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
}
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
}
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
}
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
}
}
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
}
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
}
}
}
}