QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MapSettings.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4import QtQuick.Layouts
5
6import QGroundControl
7import QGroundControl.FactControls
8import QGroundControl.Controls
9import QGroundControl.QGCMapEngineManager
10
11Item {
12 id: root
13
14 property var _settingsManager: QGroundControl.settingsManager
15 property var _appSettings: _settingsManager.appSettings
16 property var _mapsSettings: _settingsManager.mapsSettings
17 property var _mapEngineManager: QGroundControl.mapEngineManager
18 property bool _currentlyImportOrExporting: _mapEngineManager.importAction === QGCMapEngineManager.ImportAction.ActionExporting || _mapEngineManager.importAction === QGCMapEngineManager.ImportAction.ActionImporting
19 property real _largeTextFieldWidth: ScreenTools.defaultFontPixelWidth * 30
20
21 property Fact _mapProviderFact: _settingsManager.flightMapSettings.mapProvider
22 property Fact _mapTypeFact: _settingsManager.flightMapSettings.mapType
23 property Fact _elevationProviderFact: _settingsManager.flightMapSettings.elevationMapProvider
24 property Fact _tiandituFac: _settingsManager ? _settingsManager.appSettings.tiandituToken : null
25 property Fact _mapboxFact: _settingsManager ? _settingsManager.appSettings.mapboxToken : null
26 property Fact _mapboxAccountFact: _settingsManager ? _settingsManager.appSettings.mapboxAccount : null
27 property Fact _mapboxStyleFact: _settingsManager ? _settingsManager.appSettings.mapboxStyle : null
28 property Fact _esriFact: _settingsManager ? _settingsManager.appSettings.esriToken : null
29 property Fact _customURLFact: _settingsManager ? _settingsManager.appSettings.customURL : null
30 property Fact _vworldFact: _settingsManager ? _settingsManager.appSettings.vworldToken : null
31
32 SettingsPage {
33 id: settingsPage
34 anchors.fill: parent
35
36 Component.onCompleted: {
37 QGroundControl.mapEngineManager.loadTileSets()
38 }
39
40 Connections {
41 target: _mapEngineManager
42 function onErrorMessageChanged() { errorDialogFactory.open() }
43 }
44
45 SettingsGroupLayout {
46 Layout.fillWidth: true
47
48 LabelledComboBox {
49 label: qsTr("Provider")
50 model: _mapEngineManager.mapProviderList
51
52 onActivated: (index) => {
53 _mapProviderFact.rawValue = comboBox.textAt(index)
54 _mapTypeFact.rawValue = _mapEngineManager.mapTypeList(comboBox.textAt(index))[0]
55 }
56
57 Component.onCompleted: {
58 var index = comboBox.find(_mapProviderFact.rawValue)
59 if (index < 0) index = 0
60 comboBox.currentIndex = index
61 }
62 }
63
64 LabelledComboBox {
65 label: qsTr("Type")
66 model: _mapEngineManager.mapTypeList(_mapProviderFact.rawValue)
67
68 onActivated: (index) => { _mapTypeFact.rawValue = comboBox.textAt(index) }
69
70 Component.onCompleted: {
71 var index = comboBox.find(_mapTypeFact.rawValue)
72 if (index < 0) index = 0
73 comboBox.currentIndex = index
74 }
75 }
76
77 LabelledComboBox {
78 label: qsTr("Elevation Provider")
79 model: _mapEngineManager.elevationProviderList
80
81 onActivated: (index) => { _elevationProviderFact.rawValue = comboBox.textAt(index) }
82
83 Component.onCompleted: {
84 var index = comboBox.find(_elevationProviderFact.rawValue)
85 if (index < 0) index = 0
86 comboBox.currentIndex = index
87 }
88 }
89 }
90
91 SettingsGroupLayout {
92 Layout.fillWidth: true
93 heading: qsTr("Offline Maps")
94 headingDescription: qsTr("Download map tiles for use when offline")
95
96 Repeater {
97 model: QGroundControl.mapEngineManager.tileSets
98
99 OfflineMapInfo {
100 tileSet: object
101 enabled: !object.deleting
102 onClicked: offlineMapEditorComponent.createObject(root, { tileSet: object }).showInfo()
103 }
104 }
105
106 LabelledButton {
107 label: qsTr("Add New Set")
108 buttonText: qsTr("Add")
109 enabled: !_currentlyImportOrExporting
110 onClicked: offlineMapEditorComponent.createObject(root).addNewSet()
111 }
112
113 LabelledButton {
114 label: qsTr("Import Map Tiles")
115 buttonText: qsTr("Import")
116 visible: QGroundControl.corePlugin.options.showOfflineMapImport
117 enabled: !_currentlyImportOrExporting
118 onClicked: {
119 _mapEngineManager.importAction = QGCMapEngineManager.ImportAction.ActionNone
120 importDialogFactory.open()
121 }
122 }
123
124 LabelledButton {
125 label: qsTr("Export Map Tiles")
126 buttonText: qsTr("Export")
127 visible: QGroundControl.corePlugin.options.showOfflineMapExport
128 enabled: !_currentlyImportOrExporting
129 onClicked: exportDialogFactory.open()
130 }
131
132 RowLayout {
133 spacing: ScreenTools.defaultFontPixelWidth
134 visible: _currentlyImportOrExporting
135
136 QGCLabel {
137 Layout.fillWidth: true
138 text: _mapEngineManager.importAction === QGCMapEngineManager.ImportAction.ActionExporting ? qsTr("Exporting") : qsTr("Importing")
139 font.bold: true
140 }
141 ProgressBar {
142 width: ScreenTools.defaultFontPixelWidth * 25
143 from: 0
144 to: 100
145 value: _mapEngineManager.actionProgress
146 }
147 }
148 }
149
150 SettingsGroupLayout {
151 Layout.fillWidth: true
152 heading: qsTr("Tokens")
153 headingDescription: qsTr("Allows access to additional providers")
154
155 LabelledFactTextField {
156 textFieldPreferredWidth: _largeTextFieldWidth
157 label: qsTr("TianDiTu")
158 fact: _appSettings.tiandituToken
159 }
160
161 LabelledFactTextField {
162 textFieldPreferredWidth: _largeTextFieldWidth
163 label: qsTr("Mapbox")
164 fact: _appSettings.mapboxToken
165 }
166
167 LabelledFactTextField {
168 textFieldPreferredWidth: _largeTextFieldWidth
169 label: qsTr("Esri")
170 fact: _appSettings.esriToken
171 }
172
173 LabelledFactTextField {
174 textFieldPreferredWidth: _largeTextFieldWidth
175 label: qsTr("VWorld")
176 fact: _appSettings.vworldToken
177 }
178
179 LabelledFactTextField {
180 textFieldPreferredWidth: _largeTextFieldWidth
181 label: qsTr("OpenAIP")
182 fact: _appSettings.openaipToken
183 }
184 }
185
186 SettingsGroupLayout {
187 Layout.fillWidth: true
188 heading: qsTr("Mapbox Login")
189
190 LabelledFactTextField {
191 textFieldPreferredWidth: _largeTextFieldWidth
192 label: qsTr("Account")
193 fact: _appSettings.mapboxAccount
194 }
195
196 LabelledFactTextField {
197 textFieldPreferredWidth: _largeTextFieldWidth
198 label: qsTr("Map Style")
199 fact: _appSettings.mapboxStyle
200 }
201 }
202
203 SettingsGroupLayout {
204 Layout.fillWidth: true
205 heading: qsTr("Custom Map URL")
206 headingDescription: qsTr("URL with {x} {y} {z} or {zoom} substitutions")
207
208 LabelledFactTextField {
209 textFieldPreferredWidth: _largeTextFieldWidth
210 label: qsTr("Server URL")
211 fact: _appSettings.customURL
212 }
213 }
214
215 SettingsGroupLayout {
216 Layout.fillWidth: true
217 heading: qsTr("Tile Cache")
218
219 LabelledFactTextField {
220 fact: _mapsSettings.maxCacheDiskSize
221 }
222
223 LabelledFactTextField {
224 fact: _mapsSettings.maxCacheMemorySize
225 }
226 }
227
228 QGCFileDialog {
229 id: fileDialog
230 folder: _appSettings.missionSavePath
231 nameFilters: [ qsTr("Tile Sets (*.%1)").arg(defaultSuffix) ]
232 defaultSuffix: _appSettings.tilesetFileExtension
233
234 onAcceptedForSave: (file) => {
235 close()
236 _mapEngineManager.exportSets(file)
237 }
238
239 onAcceptedForLoad: (file) => {
240 close()
241 _mapEngineManager.importSets(file)
242 }
243 }
244
245 QGCPopupDialogFactory {
246 id: exportDialogFactory
247
248 dialogComponent: exportDialogComponent
249 }
250
251 Component {
252 id: exportDialogComponent
253
254 QGCPopupDialog {
255 title: qsTr("Export Selected Tile Sets")
256 buttons: Dialog.Ok | Dialog.Cancel
257
258 onAccepted: {
259 close()
260 fileDialog.title = qsTr("Export Tiles")
261 fileDialog.openForSave()
262 }
263
264 ColumnLayout {
265 spacing: ScreenTools.defaultFontPixelWidth / 2
266
267 Repeater {
268 model: _mapEngineManager.tileSets
269
270 QGCCheckBox {
271 text: object.name
272 checked: object.selected
273 onClicked: object.selected = checked
274 }
275 }
276 }
277 }
278 }
279
280 QGCPopupDialogFactory {
281 id: importDialogFactory
282
283 dialogComponent: importDialogComponent
284 }
285
286 Component {
287 id: importDialogComponent
288
289 QGCPopupDialog {
290 title: qsTr("Import TileSets")
291 buttons: Dialog.Ok | Dialog.Cancel
292
293 onAccepted: {
294 close()
295 fileDialog.title = qsTr("Import Tiles")
296 fileDialog.openForLoad()
297 }
298
299 ColumnLayout {
300 spacing: ScreenTools.defaultFontPixelWidth / 2
301
302 QGCRadioButton {
303 text: qsTr("Append to existing sets")
304 checked: !_mapEngineManager.importReplace
305 onClicked: _mapEngineManager.importReplace = !checked
306 }
307 QGCRadioButton {
308 text: qsTr("Replace existing sets")
309 checked: _mapEngineManager.importReplace
310 onClicked: _mapEngineManager.importReplace = checked
311 }
312 }
313 }
314 }
315
316 QGCPopupDialogFactory {
317 id: errorDialogFactory
318
319 dialogComponent: errorDialogComponent
320 }
321
322 Component {
323 id: errorDialogComponent
324
325 QGCSimpleMessageDialog {
326 title: qsTr("Error Message")
327 text: _mapEngineManager.errorMessage
328 buttons: Dialog.Close
329 }
330 }
331 }
332
333 Component {
334 id: offlineMapEditorComponent
335
336 OfflineMapEditor {
337 id: offlineMapEditor
338 anchors.fill: parent
339 }
340 }
341}