QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AppSettings.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.AppSettings
8
9Rectangle {
10 id: settingsView
11 color: qgcPal.window
12 z: QGroundControl.zOrderTopMost
13
14 readonly property real _defaultTextHeight: ScreenTools.defaultFontPixelHeight
15 readonly property real _defaultTextWidth: ScreenTools.defaultFontPixelWidth
16 readonly property real _horizontalMargin: _defaultTextWidth / 2
17 readonly property real _verticalMargin: _defaultTextHeight / 2
18
19 property bool _first: true
20
21 property bool _commingFromRIDSettings: false
22
23 function showSettingsPage(settingsPage) {
24 for (var i=0; i<buttonRepeater.count; i++) {
25 var loader = buttonRepeater.itemAt(i)
26 if (loader && loader.item && loader.item.text === settingsPage) {
27 loader.item.clicked()
28 break
29 }
30 }
31 }
32
33 // This need to block click event leakage to underlying map.
34 DeadMouseArea {
35 anchors.fill: parent
36 }
37
38 QGCPalette { id: qgcPal }
39
40 Component.onCompleted: {
41 //-- Default Settings
42 if (globals.commingFromRIDIndicator) {
43 rightPanel.source = "qrc:/qml/QGroundControl/AppSettings/RemoteIDSettings.qml"
44 globals.commingFromRIDIndicator = false
45 } else {
46 rightPanel.source = "qrc:/qml/QGroundControl/AppSettings/GeneralSettings.qml"
47 }
48 }
49
50 SettingsPagesModel { id: settingsPagesModel }
51
52 ButtonGroup { id: buttonGroup }
53
54 QGCFlickable {
55 id: buttonList
56 width: buttonColumn.width
57 anchors.topMargin: _verticalMargin
58 anchors.top: parent.top
59 anchors.bottom: parent.bottom
60 anchors.leftMargin: _horizontalMargin
61 anchors.left: parent.left
62 contentHeight: buttonColumn.height + _verticalMargin
63 flickableDirection: Flickable.VerticalFlick
64 clip: true
65
66 ColumnLayout {
67 id: buttonColumn
68 spacing: 0
69
70 property real _maxButtonWidth: 0
71
72 Component {
73 id: dividerComponent
74
75 Item { height: ScreenTools.defaultFontPixelHeight / 2 }
76 }
77
78 Component {
79 id: buttonComponent
80
81 SettingsButton {
82 text: modelName
83 icon.source: modelIconUrl
84 visible: modelPageVisible()
85 ButtonGroup.group: buttonGroup
86
87 onClicked: {
88 if (mainWindow.allowViewSwitch()) {
89 if (rightPanel.source !== modelUrl) {
90 rightPanel.source = modelUrl
91 }
92 checked = true
93 }
94 }
95
96 Component.onCompleted: {
97 if (globals.commingFromRIDIndicator) {
98 _commingFromRIDSettings = true
99 }
100 if(_first) {
101 _first = false
102 checked = true
103 }
104 if (_commingFromRIDSettings) {
105 checked = false
106 _commingFromRIDSettings = false
107 if (modelUrl == "qrc:/qml/QGroundControl/AppSettings/RemoteIDSettings.qml") {
108 checked = true
109 }
110 }
111 }
112 }
113 }
114
115 Repeater {
116 id: buttonRepeater
117 model: settingsPagesModel
118
119 Loader {
120 Layout.fillWidth: true
121 sourceComponent: _sourceComponent()
122
123 property var modelName: name
124 property var modelIconUrl: iconUrl
125 property var modelUrl: url
126 property var modelPageVisible: pageVisible
127
128 function _sourceComponent() {
129 if (name === "Divider") {
130 return dividerComponent
131 } else if (pageVisible()) {
132 return buttonComponent
133 } else {
134 return undefined
135 }
136 }
137 }
138 }
139 }
140 }
141
142 Rectangle {
143 id: divider
144 anchors.topMargin: _verticalMargin
145 anchors.bottomMargin: _verticalMargin
146 anchors.leftMargin: _horizontalMargin
147 anchors.left: buttonList.right
148 anchors.top: parent.top
149 anchors.bottom: parent.bottom
150 width: 1
151 color: qgcPal.windowShade
152 }
153
154 //-- Panel Contents
155 Loader {
156 id: rightPanel
157 anchors.leftMargin: _horizontalMargin
158 anchors.rightMargin: _horizontalMargin
159 anchors.topMargin: _verticalMargin
160 anchors.bottomMargin: _verticalMargin
161 anchors.left: divider.right
162 anchors.right: parent.right
163 anchors.top: parent.top
164 anchors.bottom: parent.bottom
165 }
166}