Skip to content

Commit 0cf1f55

Browse files
committed
QtLocationPlugin: Qt Integration Improvements & Fixes
1 parent f7cc8de commit 0cf1f55

40 files changed

+3882
-549
lines changed

src/QmlControls/OfflineMapEditor.qml

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import QtQuick
1111
import QtQuick.Controls
1212
import QtQuick.Layouts
1313
import QtQuick.Dialogs
14-
import QtQuick.Controls
1514
import QtLocation
1615
import QtPositioning
1716

@@ -35,8 +34,9 @@ FlightMap {
3534

3635
property var _settingsManager: QGroundControl.settingsManager
3736
property var _settings: _settingsManager ? _settingsManager.offlineMapsSettings : null
37+
property var _mapsSettings: _settingsManager ? _settingsManager.mapsSettings : null
3838
property var _fmSettings: _settingsManager ? _settingsManager.flightMapSettings : null
39-
property var _appSettings: _settingsManager.appSettings
39+
property var _appSettings: _settingsManager ? _settingsManager.appSettings : null
4040
property Fact _tiandituFact: _settingsManager ? _settingsManager.appSettings.tiandituToken : null
4141
property Fact _mapboxFact: _settingsManager ? _settingsManager.appSettings.mapboxToken : null
4242
property Fact _mapboxAccountFact: _settingsManager ? _settingsManager.appSettings.mapboxAccount : null
@@ -72,18 +72,26 @@ FlightMap {
7272
QGCPalette { id: qgcPal }
7373

7474
Component.onCompleted: {
75-
QGroundControl.mapEngineManager.loadTileSets()
75+
if (QGroundControl.mapEngineManager.tileSets.count === 0) {
76+
QGroundControl.mapEngineManager.loadTileSets()
77+
}
7678
resetMapToDefaults()
7779
updateMap()
7880
savedCenter = _map.toCoordinate(Qt.point(_map.width / 2, _map.height / 2), false /* clipToViewPort */)
7981
settingsPage.enabled = false // Prevent mouse events from bleeding through to the settings page which is below this in hierarchy
8082
}
8183

82-
Component.onDestruction: settingsPage.enabled = true
84+
Component.onDestruction: {
85+
settingsPage.enabled = true
86+
}
8387

8488
Connections {
8589
target: QGroundControl.mapEngineManager
86-
onErrorMessageChanged: errorDialogComponent.createObject(mainWindow).open()
90+
function onErrorMessageChanged() {
91+
var dialog = errorDialogComponent.createObject(mainWindow)
92+
dialog.closing.connect(function() { dialog.destroy() })
93+
dialog.open()
94+
}
8795
}
8896

8997
function handleChanges() {
@@ -212,12 +220,7 @@ FlightMap {
212220
color: Qt.rgba(qgcPal.window.r, qgcPal.window.g, qgcPal.window.b, 0.85)
213221
radius: ScreenTools.defaultFontPixelWidth * 0.5
214222

215-
property bool _extraButton: {
216-
if(!tileSet)
217-
return false;
218-
var curSel = tileSet;
219-
return !_defaultSet && ((!curSel.complete && !curSel.downloading) || (!curSel.complete && curSel.downloading));
220-
}
223+
property bool _extraButton: tileSet && !_defaultSet && !tileSet.complete
221224

222225
property real _labelWidth: ScreenTools.defaultFontPixelWidth * 10
223226
property real _valueWidth: ScreenTools.defaultFontPixelWidth * 14
@@ -309,32 +312,55 @@ FlightMap {
309312
QGCLabel { text: qsTr("Tile Count:"); width: infoView._labelWidth; }
310313
QGCLabel { text: tileSet ? tileSet.savedTileCountStr : ""; horizontalAlignment: Text.AlignRight; width: infoView._valueWidth; }
311314
}
315+
Row {
316+
spacing: ScreenTools.defaultFontPixelWidth
317+
anchors.horizontalCenter: parent.horizontalCenter
318+
visible: tileSet && !_defaultSet
319+
QGCLabel { text: qsTr("Queue:"); width: infoView._labelWidth; }
320+
QGCLabel {
321+
width: infoView._valueWidth
322+
horizontalAlignment: Text.AlignRight
323+
text: tileSet ? qsTr("%1 pending / %2 active / %3 error")
324+
.arg(tileSet.pendingTiles)
325+
.arg(tileSet.downloadingTiles)
326+
.arg(tileSet.errorTiles) : ""
327+
}
328+
}
312329
Row {
313330
spacing: ScreenTools.defaultFontPixelWidth
314331
anchors.horizontalCenter: parent.horizontalCenter
315332
QGCButton {
316333
text: qsTr("Resume Download")
317-
visible: tileSet && tileSet && !_defaultSet && (!tileSet.complete && !tileSet.downloading)
334+
visible: tileSet && !_defaultSet && (!tileSet.complete && !tileSet.downloading)
318335
width: ScreenTools.defaultFontPixelWidth * 16
319336
onClicked: {
320337
if(tileSet)
321338
tileSet.resumeDownloadTask()
322339
}
323340
}
324341
QGCButton {
325-
text: qsTr("Cancel Download")
326-
visible: tileSet && tileSet && !_defaultSet && (!tileSet.complete && tileSet.downloading)
342+
text: qsTr("Pause Download")
343+
visible: tileSet && !_defaultSet && (!tileSet.complete && tileSet.downloading)
327344
width: ScreenTools.defaultFontPixelWidth * 16
328345
onClicked: {
329346
if(tileSet)
330-
tileSet.cancelDownloadTask()
347+
tileSet.pauseDownloadTask()
348+
}
349+
}
350+
QGCButton {
351+
text: qsTr("Retry Failed (%1)").arg(tileSet ? tileSet.errorTiles : 0)
352+
visible: tileSet && !_defaultSet && (tileSet.errorTiles > 0)
353+
width: ScreenTools.defaultFontPixelWidth * 16
354+
onClicked: {
355+
if(tileSet)
356+
tileSet.retryFailedTiles()
331357
}
332358
}
333359
QGCButton {
334360
text: qsTr("Delete")
335361
width: ScreenTools.defaultFontPixelWidth * (infoView._extraButton ? 6 : 10)
336362
onClicked: deleteConfirmationDialogComponent.createObject(mainWindow).open()
337-
enabled: tileSet ? (tileSet.savedTileSize > 0) : false
363+
enabled: tileSet ? (!tileSet.deleting && (_defaultSet ? tileSet.savedTileSize > 0 : true)) : false
338364
}
339365
QGCButton {
340366
text: qsTr("Ok")
@@ -691,10 +717,13 @@ FlightMap {
691717
} // Rectangle - Zoom info
692718

693719
QGCLabel {
694-
text: qsTr("Too many tiles")
720+
text: qsTr("Too many tiles: %1 exceeds limit of %2").arg(QGroundControl.mapEngineManager.tileCountStr).arg(_settings ? _settings.maxTilesForDownload.valueString : "")
695721
visible: _tooManyTiles
696722
color: qgcPal.warningText
697-
anchors.horizontalCenter: parent.horizontalCenter
723+
wrapMode: Text.WordWrap
724+
anchors.left: parent.left
725+
anchors.right: parent.right
726+
horizontalAlignment: Text.AlignHCenter
698727
}
699728

700729
Row {
@@ -765,4 +794,3 @@ FlightMap {
765794
}
766795
}
767796
}
768-

src/QmlControls/OfflineMapInfo.qml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,49 @@ RowLayout {
2424

2525
signal clicked
2626

27-
property int _tileCount: tileSet.totalTileCount
27+
property int _tileCount: tileSet ? tileSet.totalTileCount : 0
28+
29+
QGCPalette { id: qgcPal }
2830

2931
QGCLabel {
3032
Layout.fillWidth: true
31-
text: tileSet.name
33+
text: tileSet ? (tileSet.defaultSet ? qsTr("%1 (System Cache)").arg(tileSet.name) : tileSet.name) : ""
34+
font.italic: tileSet && tileSet.defaultSet
3235
}
3336

3437
QGCLabel {
3538
id: sizeLabel
36-
text: tileSet.downloadStatus + (_tileCount > 0 ? " (" + _tileCount + " tiles)" : "")
39+
text: _computeDisplayText()
40+
function _computeDisplayText() {
41+
if (!tileSet) return ""
42+
if (tileSet.defaultSet) {
43+
return tileSet.savedTileSizeStr + " (" + tileSet.savedTileCount + " tiles)"
44+
}
45+
var result = tileSet.downloadStatus
46+
if (_tileCount > 0) result += " (" + _tileCount + " tiles)"
47+
return result + _queueSuffix()
48+
}
49+
function _queueSuffix() {
50+
if (!tileSet || tileSet.defaultSet) {
51+
return ""
52+
}
53+
var parts = []
54+
if (tileSet.pendingTiles > 0)
55+
parts.push(qsTr("%1 pending").arg(tileSet.pendingTiles))
56+
if (tileSet.downloadingTiles > 0)
57+
parts.push(qsTr("%1 active").arg(tileSet.downloadingTiles))
58+
if (tileSet.errorTiles > 0)
59+
parts.push(qsTr("%1 error").arg(tileSet.errorTiles))
60+
return parts.length ? " [" + parts.join(", ") + "]" : ""
61+
}
3762
}
3863

3964
Rectangle {
4065
width: sizeLabel.height * 0.5
4166
height: sizeLabel.height * 0.5
4267
radius: width / 2
43-
color: tileSet.complete ? "#31f55b" : "#fc5656"
44-
opacity: sizeLabel.text.length > 0 ? 1 : 0
68+
color: tileSet && tileSet.defaultSet ? qgcPal.text : (tileSet && tileSet.complete ? qgcPal.colorGreen : qgcPal.colorRed)
69+
opacity: sizeLabel.text.length > 0 ? (tileSet && tileSet.defaultSet ? 0.4 : 1) : 0
4570
}
4671

4772
QGCButton {

src/QtLocationPlugin/CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ qt_add_plugin(QGCLocation
5454
# ----------------------------------------------------------------------------
5555
# Platform-Specific Configuration
5656
# ----------------------------------------------------------------------------
57-
# Google Maps not available on iOS
57+
# iOS: Disable Google Maps due to App Store licensing restrictions
58+
# Google Maps requires additional licensing agreements for iOS distribution
59+
# through the App Store that differ from other platforms
5860
if(IOS)
5961
target_compile_definitions(QGCLocation PRIVATE QGC_NO_GOOGLE_MAPS)
6062
endif()
@@ -64,18 +66,19 @@ endif()
6466
# ----------------------------------------------------------------------------
6567
target_link_libraries(QGCLocation
6668
PRIVATE
67-
Qt6::Positioning
68-
Qt6::Sql
69-
PUBLIC
7069
Qt6::Core
7170
Qt6::Location
7271
Qt6::LocationPrivate
7372
Qt6::Network
73+
Qt6::Positioning
74+
Qt6::Sql
7475
)
7576

7677
target_include_directories(QGCLocation
7778
PUBLIC
78-
${CMAKE_CURRENT_SOURCE_DIR}
79+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
80+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Providers>
81+
PRIVATE
7982
${CMAKE_CURRENT_SOURCE_DIR}/..
8083
${CMAKE_CURRENT_SOURCE_DIR}/../FactSystem
8184
${CMAKE_CURRENT_SOURCE_DIR}/../QmlControls

0 commit comments

Comments
 (0)