QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
OfflineMapSettings.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.QGCMapEngineManager
8
9/// Offline map tile set management: list, add, import, export, and progress display.
10/// Self-contained component including all dialogs needed for offline map operations.
11Item {
12 id: root
13 implicitHeight: mainLayout.implicitHeight
14
15 property var _mapEngineManager: QGroundControl.mapEngineManager
16 property var _appSettings: QGroundControl.settingsManager.appSettings
17 property bool _currentlyImportOrExporting: _mapEngineManager.importAction === QGCMapEngineManager.ImportAction.ActionExporting ||
18 _mapEngineManager.importAction === QGCMapEngineManager.ImportAction.ActionImporting
19
20 Component.onCompleted: _mapEngineManager.loadTileSets()
21
22 Connections {
23 target: _mapEngineManager
24 function onErrorMessageChanged() { errorDialogFactory.open() }
25 }
26
27 ColumnLayout {
28 id: mainLayout
29 width: parent.width
30
31 SettingsGroupLayout {
32 Layout.fillWidth: true
33 heading: qsTr("Offline Maps")
34 headingDescription: qsTr("Download map tiles for use when offline")
35
36 Repeater {
37 model: _mapEngineManager.tileSets
38
39 OfflineMapInfo {
40 tileSet: object
41 enabled: !object.deleting
42 onClicked: offlineMapEditorComponent.createObject(mainWindow.contentItem, { tileSet: object }).showInfo()
43 }
44 }
45
46 LabelledButton {
47 label: qsTr("Add New Set")
48 buttonText: qsTr("Add")
49 enabled: !_currentlyImportOrExporting
50 onClicked: offlineMapEditorComponent.createObject(mainWindow.contentItem).addNewSet()
51 }
52
53 LabelledButton {
54 label: qsTr("Import Map Tiles")
55 buttonText: qsTr("Import")
56 visible: QGroundControl.corePlugin.options.showOfflineMapImport
57 enabled: !_currentlyImportOrExporting
58 onClicked: {
59 _mapEngineManager.importAction = QGCMapEngineManager.ImportAction.ActionNone
60 importDialogFactory.open()
61 }
62 }
63
64 LabelledButton {
65 label: qsTr("Export Map Tiles")
66 buttonText: qsTr("Export")
67 visible: QGroundControl.corePlugin.options.showOfflineMapExport
68 enabled: !_currentlyImportOrExporting
69 onClicked: exportDialogFactory.open()
70 }
71
72 RowLayout {
73 spacing: ScreenTools.defaultFontPixelWidth
74 visible: _currentlyImportOrExporting
75
76 QGCLabel {
77 Layout.fillWidth: true
78 text: _mapEngineManager.importAction === QGCMapEngineManager.ImportAction.ActionExporting ? qsTr("Exporting") : qsTr("Importing")
79 font.bold: true
80 }
81 ProgressBar {
82 width: ScreenTools.defaultFontPixelWidth * 25
83 from: 0
84 to: 100
85 value: _mapEngineManager.actionProgress
86 }
87 }
88 }
89 }
90
91 QGCFileDialog {
92 id: fileDialog
93 folder: _appSettings.missionSavePath
94 nameFilters: [ qsTr("Tile Sets (*.%1)").arg(defaultSuffix) ]
95 defaultSuffix: _appSettings.tilesetFileExtension
96
97 onAcceptedForSave: (file) => {
98 close()
99 _mapEngineManager.exportSets(file)
100 }
101
102 onAcceptedForLoad: (file) => {
103 close()
104 _mapEngineManager.importSets(file)
105 }
106 }
107
108 QGCPopupDialogFactory {
109 id: exportDialogFactory
110 dialogComponent: exportDialogComponent
111 }
112
113 Component {
114 id: exportDialogComponent
115
116 QGCPopupDialog {
117 title: qsTr("Export Selected Tile Sets")
118 buttons: Dialog.Ok | Dialog.Cancel
119
120 onAccepted: {
121 close()
122 fileDialog.title = qsTr("Export Tiles")
123 fileDialog.openForSave()
124 }
125
126 ColumnLayout {
127 spacing: ScreenTools.defaultFontPixelWidth / 2
128
129 Repeater {
130 model: _mapEngineManager.tileSets
131
132 QGCCheckBox {
133 text: object.name
134 checked: object.selected
135 onClicked: object.selected = checked
136 }
137 }
138 }
139 }
140 }
141
142 QGCPopupDialogFactory {
143 id: importDialogFactory
144 dialogComponent: importDialogComponent
145 }
146
147 Component {
148 id: importDialogComponent
149
150 QGCPopupDialog {
151 title: qsTr("Import TileSets")
152 buttons: Dialog.Ok | Dialog.Cancel
153
154 onAccepted: {
155 close()
156 fileDialog.title = qsTr("Import Tiles")
157 fileDialog.openForLoad()
158 }
159
160 ColumnLayout {
161 spacing: ScreenTools.defaultFontPixelWidth / 2
162
163 QGCRadioButton {
164 text: qsTr("Append to existing sets")
165 checked: !_mapEngineManager.importReplace
166 onClicked: _mapEngineManager.importReplace = !checked
167 }
168 QGCRadioButton {
169 text: qsTr("Replace existing sets")
170 checked: _mapEngineManager.importReplace
171 onClicked: _mapEngineManager.importReplace = checked
172 }
173 }
174 }
175 }
176
177 QGCPopupDialogFactory {
178 id: errorDialogFactory
179 dialogComponent: errorDialogComponent
180 }
181
182 Component {
183 id: errorDialogComponent
184
185 QGCSimpleMessageDialog {
186 title: qsTr("Error Message")
187 text: _mapEngineManager.errorMessage
188 buttons: Dialog.Close
189 }
190 }
191
192 Component {
193 id: offlineMapEditorComponent
194
195 OfflineMapEditor {
196 id: offlineMapEditor
197 anchors.fill: parent
198 z: QGroundControl.zOrderTopMost
199 }
200 }
201}