7import QGroundControl.FactControls
8import QGroundControl.Controls
9import QGroundControl.QGCMapEngineManager
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
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
36 Component.onCompleted: {
37 QGroundControl.mapEngineManager.loadTileSets()
41 target: _mapEngineManager
42 function onErrorMessageChanged() { errorDialogFactory.open() }
46 Layout.fillWidth: true
49 label: qsTr("Provider")
50 model: _mapEngineManager.mapProviderList
52 onActivated: (index) => {
53 _mapProviderFact.rawValue = comboBox.textAt(index)
54 _mapTypeFact.rawValue = _mapEngineManager.mapTypeList(comboBox.textAt(index))[0]
57 Component.onCompleted: {
58 var index = comboBox.find(_mapProviderFact.rawValue)
59 if (index < 0) index = 0
60 comboBox.currentIndex = index
66 model: _mapEngineManager.mapTypeList(_mapProviderFact.rawValue)
68 onActivated: (index) => { _mapTypeFact.rawValue = comboBox.textAt(index) }
70 Component.onCompleted: {
71 var index = comboBox.find(_mapTypeFact.rawValue)
72 if (index < 0) index = 0
73 comboBox.currentIndex = index
78 label: qsTr("Elevation Provider")
79 model: _mapEngineManager.elevationProviderList
81 onActivated: (index) => { _elevationProviderFact.rawValue = comboBox.textAt(index) }
83 Component.onCompleted: {
84 var index = comboBox.find(_elevationProviderFact.rawValue)
85 if (index < 0) index = 0
86 comboBox.currentIndex = index
92 Layout.fillWidth: true
93 heading: qsTr("Offline Maps")
94 headingDescription: qsTr("Download map tiles for use when offline")
97 model: QGroundControl.mapEngineManager.tileSets
101 enabled: !object.deleting
102 onClicked: offlineMapEditorComponent.createObject(root, { tileSet: object }).showInfo()
107 label: qsTr("Add New Set")
108 buttonText: qsTr("Add")
109 enabled: !_currentlyImportOrExporting
110 onClicked: offlineMapEditorComponent.createObject(root).addNewSet()
114 label: qsTr("Import Map Tiles")
115 buttonText: qsTr("Import")
116 visible: QGroundControl.corePlugin.options.showOfflineMapImport
117 enabled: !_currentlyImportOrExporting
119 _mapEngineManager.importAction = QGCMapEngineManager.ImportAction.ActionNone
120 importDialogFactory.open()
125 label: qsTr("Export Map Tiles")
126 buttonText: qsTr("Export")
127 visible: QGroundControl.corePlugin.options.showOfflineMapExport
128 enabled: !_currentlyImportOrExporting
129 onClicked: exportDialogFactory.open()
133 spacing: ScreenTools.defaultFontPixelWidth
134 visible: _currentlyImportOrExporting
137 Layout.fillWidth: true
138 text: _mapEngineManager.importAction === QGCMapEngineManager.ImportAction.ActionExporting ? qsTr("Exporting") : qsTr("Importing")
142 width: ScreenTools.defaultFontPixelWidth * 25
145 value: _mapEngineManager.actionProgress
150 SettingsGroupLayout {
151 Layout.fillWidth: true
152 heading: qsTr("Tokens")
153 headingDescription: qsTr("Allows access to additional providers")
155 LabelledFactTextField {
156 textFieldPreferredWidth: _largeTextFieldWidth
157 label: qsTr("TianDiTu")
158 fact: _appSettings.tiandituToken
161 LabelledFactTextField {
162 textFieldPreferredWidth: _largeTextFieldWidth
163 label: qsTr("Mapbox")
164 fact: _appSettings.mapboxToken
167 LabelledFactTextField {
168 textFieldPreferredWidth: _largeTextFieldWidth
170 fact: _appSettings.esriToken
173 LabelledFactTextField {
174 textFieldPreferredWidth: _largeTextFieldWidth
175 label: qsTr("VWorld")
176 fact: _appSettings.vworldToken
179 LabelledFactTextField {
180 textFieldPreferredWidth: _largeTextFieldWidth
181 label: qsTr("OpenAIP")
182 fact: _appSettings.openaipToken
186 SettingsGroupLayout {
187 Layout.fillWidth: true
188 heading: qsTr("Mapbox Login")
190 LabelledFactTextField {
191 textFieldPreferredWidth: _largeTextFieldWidth
192 label: qsTr("Account")
193 fact: _appSettings.mapboxAccount
196 LabelledFactTextField {
197 textFieldPreferredWidth: _largeTextFieldWidth
198 label: qsTr("Map Style")
199 fact: _appSettings.mapboxStyle
203 SettingsGroupLayout {
204 Layout.fillWidth: true
205 heading: qsTr("Custom Map URL")
206 headingDescription: qsTr("URL with {x} {y} {z} or {zoom} substitutions")
208 LabelledFactTextField {
209 textFieldPreferredWidth: _largeTextFieldWidth
210 label: qsTr("Server URL")
211 fact: _appSettings.customURL
215 SettingsGroupLayout {
216 Layout.fillWidth: true
217 heading: qsTr("Tile Cache")
219 LabelledFactTextField {
220 fact: _mapsSettings.maxCacheDiskSize
223 LabelledFactTextField {
224 fact: _mapsSettings.maxCacheMemorySize
230 folder: _appSettings.missionSavePath
231 nameFilters: [ qsTr("Tile Sets (*.%1)").arg(defaultSuffix) ]
232 defaultSuffix: _appSettings.tilesetFileExtension
234 onAcceptedForSave: (file) => {
236 _mapEngineManager.exportSets(file)
239 onAcceptedForLoad: (file) => {
241 _mapEngineManager.importSets(file)
245 QGCPopupDialogFactory {
246 id: exportDialogFactory
248 dialogComponent: exportDialogComponent
252 id: exportDialogComponent
255 title: qsTr("Export Selected Tile Sets")
256 buttons: Dialog.Ok | Dialog.Cancel
260 fileDialog.title = qsTr("Export Tiles")
261 fileDialog.openForSave()
265 spacing: ScreenTools.defaultFontPixelWidth / 2
268 model: _mapEngineManager.tileSets
272 checked: object.selected
273 onClicked: object.selected = checked
280 QGCPopupDialogFactory {
281 id: importDialogFactory
283 dialogComponent: importDialogComponent
287 id: importDialogComponent
290 title: qsTr("Import TileSets")
291 buttons: Dialog.Ok | Dialog.Cancel
295 fileDialog.title = qsTr("Import Tiles")
296 fileDialog.openForLoad()
300 spacing: ScreenTools.defaultFontPixelWidth / 2
303 text: qsTr("Append to existing sets")
304 checked: !_mapEngineManager.importReplace
305 onClicked: _mapEngineManager.importReplace = !checked
308 text: qsTr("Replace existing sets")
309 checked: _mapEngineManager.importReplace
310 onClicked: _mapEngineManager.importReplace = checked
316 QGCPopupDialogFactory {
317 id: errorDialogFactory
319 dialogComponent: errorDialogComponent
323 id: errorDialogComponent
325 QGCSimpleMessageDialog {
326 title: qsTr("Error Message")
327 text: _mapEngineManager.errorMessage
328 buttons: Dialog.Close
334 id: offlineMapEditorComponent