Browse Source

Merge pull request #3247 from dogmaphobic/offlineMap

Offline map
QGC4.4
Gus Grubba 9 years ago
parent
commit
f7ad3693f3
  1. 2
      android/gradle/wrapper/gradle-wrapper.properties
  2. 2
      src/QmlControls/QGCButton.qml
  3. 1
      src/QmlControls/QGCTextField.qml
  4. 2
      src/QmlControls/ScreenToolsController.cc
  5. 2
      src/QtLocationPlugin/QGCMapEngine.cpp
  6. 503
      src/QtLocationPlugin/QMLControl/OfflineMap.qml
  7. 2
      src/ui/MainWindowLeftPanel.qml

2
android/gradle/wrapper/gradle-wrapper.properties vendored

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip

2
src/QmlControls/QGCButton.qml

@ -60,7 +60,7 @@ Button {
background: Item { background: Item {
property bool down: control.pressed || (control.checkable && control.checked) property bool down: control.pressed || (control.checkable && control.checked)
implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5) implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5)
implicitHeight: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 3 * 0.75 : Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2)) implicitHeight: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 2.5 : Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2))
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent

1
src/QmlControls/QGCTextField.qml

@ -31,6 +31,7 @@ TextField {
} }
style: TextFieldStyle { style: TextFieldStyle {
font.pixelSize: ScreenTools.defaultFontPixelSize
background: Item { background: Item {
id: backgroundItem id: backgroundItem

2
src/QmlControls/ScreenToolsController.cc

@ -31,7 +31,7 @@ const double ScreenToolsController::_defaultFontPixelSizeRatio = 1.0;
#elif __android__ #elif __android__
const double ScreenToolsController::_defaultFontPixelSizeRatio = 1.0; const double ScreenToolsController::_defaultFontPixelSizeRatio = 1.0;
#elif __ios__ #elif __ios__
const double ScreenToolsController::_defaultFontPixelSizeRatio = 0.8; const double ScreenToolsController::_defaultFontPixelSizeRatio = 0.6;
#else #else
const double ScreenToolsController::_defaultFontPixelSizeRatio = 0.8; const double ScreenToolsController::_defaultFontPixelSizeRatio = 0.8;
#endif #endif

2
src/QtLocationPlugin/QGCMapEngine.cpp

@ -266,7 +266,7 @@ QGCTileSet
QGCMapEngine::getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, UrlFactory::MapType mapType) QGCMapEngine::getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, UrlFactory::MapType mapType)
{ {
if(zoom < 1) zoom = 1; if(zoom < 1) zoom = 1;
if(zoom > 18) zoom = 18; if(zoom > MAX_MAP_ZOOM) zoom = MAX_MAP_ZOOM;
QGCTileSet set; QGCTileSet set;
set.tileX0 = long2tileX(topleftLon, zoom); set.tileX0 = long2tileX(topleftLon, zoom);
set.tileY0 = lat2tileY(topleftLat, zoom); set.tileY0 = lat2tileY(topleftLat, zoom);

503
src/QtLocationPlugin/QMLControl/OfflineMap.qml

@ -26,8 +26,8 @@ import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2 import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import QtLocation 5.3 import QtLocation 5.5
import QtPositioning 5.3 import QtPositioning 5.5
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
@ -44,10 +44,14 @@ Rectangle {
property string mapKey: "lastMapType" property string mapKey: "lastMapType"
property string mapType: QGroundControl.mapEngineManager.loadSetting(mapKey, "Google Street Map") property string mapType: QGroundControl.mapEngineManager.loadSetting(mapKey, "Google Street Map")
property int mapMargin: (ScreenTools.defaultFontPixelHeight * 0.2).toFixed(0) property int mapMargin: (ScreenTools.defaultFontPixelHeight * 0.2).toFixed(0)
property real infoWidth: Math.max(Math.max(nameLabel.width, descLabel.width), (ScreenTools.defaultFontPixelWidth * 40)) property real infoWidth: Math.max(infoCol.width, (ScreenTools.defaultFontPixelWidth * 40))
property bool isDefaultSet: _offlineMapRoot._currentSelection && _offlineMapRoot._currentSelection.defaultSet property bool isDefaultSet: _offlineMapRoot._currentSelection && _offlineMapRoot._currentSelection.defaultSet
property bool isMapInteractive: true
property var savedCenter: undefined
property real savedZoom: 3
property string savedMapType: ""
property real oldlon0: 0 property real oldlon0: 0
property real oldlon1: 0 property real oldlon1: 0
@ -64,6 +68,7 @@ Rectangle {
Component.onCompleted: { Component.onCompleted: {
QGroundControl.mapEngineManager.loadTileSets() QGroundControl.mapEngineManager.loadTileSets()
updateMap() updateMap()
savedCenter = _map.toCoordinate(Qt.point(_map.width / 2, _map.height / 2))
} }
Connections { Connections {
@ -79,19 +84,21 @@ Rectangle {
ExclusiveGroup { id: setGroup } ExclusiveGroup { id: setGroup }
function handleChanges() { function handleChanges() {
var xl = mapMargin if(isMapInteractive) {
var yl = mapMargin var xl = mapMargin
var xr = _map.width.toFixed(0) - mapMargin var yl = mapMargin
var yr = _map.height.toFixed(0) - mapMargin var xr = _map.width.toFixed(0) - mapMargin
var c0 = _map.toCoordinate(Qt.point(xl, yl)) var yr = _map.height.toFixed(0) - mapMargin
var c1 = _map.toCoordinate(Qt.point(xr, yr)) var c0 = _map.toCoordinate(Qt.point(xl, yl))
if(oldlon0 !== c0.longitude || oldlat0 !== c0.latitude || oldlon1 !== c1.longitude || oldlat1 !== c1.latitude || oldz0 !== _slider0.value || oldz1 !== _slider1.value) { var c1 = _map.toCoordinate(Qt.point(xr, yr))
QGroundControl.mapEngineManager.updateForCurrentView(c0.longitude, c0.latitude, c1.longitude, c1.latitude, _slider0.value, _slider1.value, mapType) if(oldlon0 !== c0.longitude || oldlat0 !== c0.latitude || oldlon1 !== c1.longitude || oldlat1 !== c1.latitude || oldz0 !== _slider0.value || oldz1 !== _slider1.value) {
QGroundControl.mapEngineManager.updateForCurrentView(c0.longitude, c0.latitude, c1.longitude, c1.latitude, _slider0.value, _slider1.value, mapType)
}
} }
} }
function checkSanity() { function checkSanity() {
if(QGroundControl.mapEngineManager.crazySize) { if(isMapInteractive && QGroundControl.mapEngineManager.crazySize) {
_slider1.value = _slider1.value - 1 _slider1.value = _slider1.value - 1
handleChanges() handleChanges()
} }
@ -108,43 +115,105 @@ Rectangle {
} }
function showOptions() { function showOptions() {
_map.visible = false
_tileSetList.visible = false _tileSetList.visible = false
_infoView.visible = false _infoView.visible = false
_defaultInfoView.visible = false
_mapView.visible = false _mapView.visible = false
_optionsView.visible = true _optionsView.visible = true
} }
function showMap() { function showMap() {
_map.visible = true
_tileSetList.visible = false _tileSetList.visible = false
_infoView.visible = false _infoView.visible = false
_defaultInfoView.visible = false
_mapView.visible = true _mapView.visible = true
_optionsView.visible = false _optionsView.visible = false
} }
function showList() { function showList() {
_map.visible = false
_tileSetList.visible = true _tileSetList.visible = true
_infoView.visible = false _infoView.visible = false
_defaultInfoView.visible = false
_mapView.visible = false _mapView.visible = false
_optionsView.visible = false _optionsView.visible = false
} }
function showInfo() { function showInfo() {
if(_currentSelection && !_offlineMapRoot._currentSelection.deleting) { if(_currentSelection && !_offlineMapRoot._currentSelection.deleting) {
_tileSetList.visible = false enterInfoView()
_mapView.visible = false
_infoView.visible = true
_optionsView.visible = false
} else } else
showList() showList()
} }
function toRadian(deg) {
return deg * Math.PI / 180
}
function toDegree(rad) {
return rad * 180 / Math.PI
}
function midPoint(lat1, lat2, lon1, lon2) {
var dLon = toRadian(lon2 - lon1);
lat1 = toRadian(lat1);
lat2 = toRadian(lat2);
lon1 = toRadian(lon1);
var Bx = Math.cos(lat2) * Math.cos(dLon);
var By = Math.cos(lat2) * Math.sin(dLon);
var lat3 = Math.atan2(Math.sin(lat1) + Math.sin(lat2), Math.sqrt((Math.cos(lat1) + Bx) * (Math.cos(lat1) + Bx) + By * By));
var lon3 = lon1 + Math.atan2(By, Math.cos(lat1) + Bx);
return QtPositioning.coordinate(toDegree(lat3), toDegree(lon3))
}
function enterInfoView() {
if(!isDefaultSet) {
isMapInteractive = false
savedCenter = _map.toCoordinate(Qt.point(_map.width / 2, _map.height / 2))
savedZoom = _map.zoomLevel
savedMapType = mapType
_map.visible = true
mapType = _offlineMapRoot._currentSelection.mapTypeStr
_map.center = midPoint(_offlineMapRoot._currentSelection.topleftLat, _offlineMapRoot._currentSelection.bottomRightLat, _offlineMapRoot._currentSelection.topleftLon, _offlineMapRoot._currentSelection.bottomRightLon)
//-- Delineate Set Region
var x0 = _offlineMapRoot._currentSelection.topleftLon
var x1 = _offlineMapRoot._currentSelection.bottomRightLon
var y0 = _offlineMapRoot._currentSelection.topleftLat
var y1 = _offlineMapRoot._currentSelection.bottomRightLat
mapBoundary.topLeft = QtPositioning.coordinate(y0, x0)
mapBoundary.bottomRight = QtPositioning.coordinate(y1, x1)
mapBoundary.visible = true
_map.fitViewportToMapItems()
}
_tileSetList.visible = false
_mapView.visible = false
_optionsView.visible = false
if(isDefaultSet) {
_defaultInfoView.visible = true
} else {
_infoView.visible= true
}
}
function leaveInfoView() {
mapBoundary.visible = false
_map.center = savedCenter
_map.zoomLevel = savedZoom
mapType = savedMapType
isMapInteractive = true
}
ExclusiveGroup { ExclusiveGroup {
id: _dropButtonsExclusiveGroup id: _dropButtonsExclusiveGroup
} }
onMapTypeChanged: { onMapTypeChanged: {
updateMap() updateMap()
QGroundControl.mapEngineManager.saveSetting(mapKey, mapType) if(isMapInteractive) {
QGroundControl.mapEngineManager.saveSetting(mapKey, mapType)
}
} }
MessageDialog { MessageDialog {
@ -184,6 +253,62 @@ Rectangle {
} }
} }
Map {
id: _map
anchors.top: _offlineMapTopRect.bottom
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: mapMargin
width: parent.width - ScreenTools.defaultFontPixelWidth
center: QGroundControl.defaultMapPosition
visible: false
gesture.flickDeceleration: 3000
gesture.activeGestures: MapGestureArea.ZoomGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture
plugin: Plugin { name: "QGroundControl" }
Rectangle {
color: Qt.rgba(0,0,0,0)
border.color: "black"
border.width: 1
anchors.fill: parent
}
MapRectangle {
id: mapBoundary
border.width: 2
border.color: "red"
color: Qt.rgba(1,0,0,0.05)
smooth: true
antialiasing: true
}
Component.onCompleted: {
center = QGroundControl.flightMapPosition
zoomLevel = QGroundControl.flightMapZoom
}
onCenterChanged: {
handleChanges()
checkSanity()
}
onZoomLevelChanged: {
handleChanges()
checkSanity()
}
onWidthChanged: {
handleChanges()
checkSanity()
}
onHeightChanged: {
handleChanges()
checkSanity()
}
// Used to make pinch zoom work
MouseArea {
anchors.fill: parent
}
}
QGCFlickable { QGCFlickable {
id: _tileSetList id: _tileSetList
clip: true clip: true
@ -240,57 +365,18 @@ Rectangle {
} }
//-- Offline Map Definition //-- Offline Map Definition
Rectangle { Item {
id: _mapView id: _mapView
color: qgcPal.window
width: parent.width width: parent.width
anchors.top: _offlineMapTopRect.bottom anchors.top: _offlineMapTopRect.bottom
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.margins: ScreenTools.defaultFontPixelWidth anchors.margins: ScreenTools.defaultFontPixelWidth
visible: false visible: false
Rectangle { //-- Zoom Preview Maps
Item {
width: parent.width width: parent.width
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: bottomRect.top
color: (qgcPal.globalTheme === QGCPalette.Light) ? "black" : "#98aca4"
Map {
id: _map
anchors.fill: parent
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.15
center: QGroundControl.defaultMapPosition
gesture.flickDeceleration: 3000
gesture.activeGestures: MapGestureArea.ZoomGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture
plugin: Plugin { name: "QGroundControl" }
Component.onCompleted: {
center = QGroundControl.flightMapPosition
zoomLevel = QGroundControl.flightMapZoom
}
onCenterChanged: {
handleChanges()
checkSanity()
}
onZoomLevelChanged: {
handleChanges()
checkSanity()
}
onWidthChanged: {
handleChanges()
checkSanity()
}
onHeightChanged: {
handleChanges()
checkSanity()
}
// Used to make pinch zoom work
MouseArea {
anchors.fill: parent
}
}
Rectangle { Rectangle {
width: ScreenTools.defaultFontPixelHeight * 16 width: ScreenTools.defaultFontPixelHeight * 16
height: ScreenTools.defaultFontPixelHeight * 9 height: ScreenTools.defaultFontPixelHeight * 9
@ -330,11 +416,17 @@ Rectangle {
} }
} }
} }
//-- Tile set settings
Rectangle { Rectangle {
id: bottomRect id: bottomRect
width: parent.width width: _controlRow.width + (ScreenTools.defaultFontPixelWidth * 2)
height: _controlRow.height + (ScreenTools.defaultFontPixelHeight * 2) height: _controlRow.height + (ScreenTools.defaultFontPixelHeight * 2)
color: qgcPal.window color: qgcPal.window
radius: ScreenTools.defaultFontPixelWidth * 0.5
anchors.horizontalCenter: parent.horizontalCenter
Component.onCompleted: {
color = Qt.rgba(color.r, color.g, color.b, 0.85)
}
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
Row { Row {
id: _controlRow id: _controlRow
@ -487,27 +579,27 @@ Rectangle {
Label { Label {
text: qsTr("Tile Count") text: qsTr("Tile Count")
color: "black" color: "black"
width: ScreenTools.defaultFontPixelWidth * 12 width: ScreenTools.defaultFontPixelWidth * 8
font.pixelSize: ScreenTools.smallFontPixelSize font.pixelSize: ScreenTools.smallFontPixelSize
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
Label { Label {
text: QGroundControl.mapEngineManager.tileCountStr text: QGroundControl.mapEngineManager.tileCountStr
color: "black" color: "black"
width: ScreenTools.defaultFontPixelWidth * 12 width: ScreenTools.defaultFontPixelWidth * 8
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
Label { Label {
text: qsTr("Set Size (Est)") text: qsTr("Set Size (Est)")
color: "black" color: "black"
width: ScreenTools.defaultFontPixelWidth * 12 width: ScreenTools.defaultFontPixelWidth * 8
font.pixelSize: ScreenTools.smallFontPixelSize font.pixelSize: ScreenTools.smallFontPixelSize
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
Label { Label {
text: QGroundControl.mapEngineManager.tileSizeStr text: QGroundControl.mapEngineManager.tileSizeStr
color: "black" color: "black"
width: ScreenTools.defaultFontPixelWidth * 12 width: ScreenTools.defaultFontPixelWidth * 8
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
} }
@ -526,7 +618,7 @@ Rectangle {
} }
QGCTextField { QGCTextField {
id: setName id: setName
width: ScreenTools.defaultFontPixelWidth * 24 width: ScreenTools.defaultFontPixelWidth * 20
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
} }
@ -541,7 +633,7 @@ Rectangle {
QGCTextField { QGCTextField {
id: setDescription id: setDescription
text: qsTr("Description") text: qsTr("Description")
width: ScreenTools.defaultFontPixelWidth * 24 width: ScreenTools.defaultFontPixelWidth * 20
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
} }
@ -555,7 +647,7 @@ Rectangle {
} }
QGCComboBox { QGCComboBox {
id: mapCombo id: mapCombo
width: ScreenTools.defaultFontPixelWidth * 24 width: ScreenTools.defaultFontPixelWidth * 20
model: QGroundControl.mapEngineManager.mapList model: QGroundControl.mapEngineManager.mapList
onActivated: { onActivated: {
mapType = textAt(index) mapType = textAt(index)
@ -576,7 +668,7 @@ Rectangle {
} }
Item { Item {
height: 1 height: 1
width: ScreenTools.defaultFontPixelWidth * 1.5 width: ScreenTools.defaultFontPixelWidth
} }
Column { Column {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -621,8 +713,163 @@ Rectangle {
} }
} }
} }
Rectangle {
//-- Show Set Info
Item {
id: _infoView id: _infoView
width: parent.width
anchors.bottom: parent.bottom
anchors.margins: ScreenTools.defaultFontPixelWidth
visible: false
//-- Tile set settings
Rectangle {
id: bottomInfoRect
width: _controlInfoRow.width + (ScreenTools.defaultFontPixelWidth * 2)
height: _controlInfoRow.height + (ScreenTools.defaultFontPixelHeight * 2)
color: qgcPal.window
radius: ScreenTools.defaultFontPixelWidth * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
Component.onCompleted: {
color = Qt.rgba(color.r, color.g, color.b, 0.85)
}
anchors.bottom: parent.bottom
Row {
id: _controlInfoRow
anchors.centerIn: parent
spacing: ScreenTools.defaultFontPixelWidth * 4
Column {
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
anchors.verticalCenter: parent.verticalCenter
spacing: ScreenTools.defaultFontPixelHeight * 0.5
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.name : ""
font.pixelSize: ScreenTools.isAndroid ? ScreenTools.mediumFontPixelSize : ScreenTools.largeFontPixelSize
anchors.horizontalCenter: parent.horizontalCenter
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.description : ""
visible: text !== qsTr("Description")
anchors.horizontalCenter: parent.horizontalCenter
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? "(" + _offlineMapRoot._currentSelection.mapTypeStr + ")" : ""
}
}
GridLayout {
columns: 2
anchors.margins: ScreenTools.defaultFontPixelWidth
rowSpacing: ScreenTools.defaultFontPixelWidth
columnSpacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
text: qsTr("Min Zoom:")
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.minZoom : ""
}
QGCLabel {
text: qsTr("Max Zoom:")
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.maxZoom : ""
}
QGCLabel {
text: qsTr("Total:")
}
QGCLabel {
text: (_offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.numTilesStr : "") + " (" + (_offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.tilesSizeStr : "") + ")"
}
QGCLabel {
text: qsTr("Downloaded:")
visible: _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete
}
QGCLabel {
text: (_offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedTilesStr : "") + " (" + (_offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedSizeStr : "") + ")"
visible: _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete
}
QGCLabel {
text: qsTr("Error Count:")
visible: _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.errorCountStr : ""
visible: _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
spacing: ScreenTools.defaultFontPixelHeight * 0.5
QGCButton {
width: ScreenTools.defaultFontPixelWidth * 18
text: qsTr("Delete")
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting)
onClicked: {
if(_offlineMapRoot._currentSelection)
deleteDialog.visible = true
}
MessageDialog {
id: deleteDialog
visible: false
icon: StandardIcon.Warning
standardButtons: StandardButton.Yes | StandardButton.No
title: qsTr("Delete Tile Set")
text: {
if(_offlineMapRoot._currentSelection) {
var blurb = qsTr("Delete %1 and all its tiles.\nIs this really what you want?").arg(_offlineMapRoot._currentSelection.name)
return blurb
}
return ""
}
onYes: {
leaveInfoView()
if(_offlineMapRoot._currentSelection)
QGroundControl.mapEngineManager.deleteTileSet(_offlineMapRoot._currentSelection)
deleteDialog.visible = false
showList()
}
onNo: {
deleteDialog.visible = false
}
}
}
QGCButton {
text: qsTr("Resume Download")
width: ScreenTools.defaultFontPixelWidth * 18
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting && !_offlineMapRoot._currentSelection.downloading)
visible: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.complete && !_offlineMapRoot._currentSelection.downloading)
onClicked: {
if(_offlineMapRoot._currentSelection)
_offlineMapRoot._currentSelection.resumeDownloadTask()
}
}
QGCButton {
text: qsTr("Cancel Download")
width: ScreenTools.defaultFontPixelWidth * 18
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting && _offlineMapRoot._currentSelection.downloading)
visible: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.complete && _offlineMapRoot._currentSelection.downloading)
onClicked: {
if(_offlineMapRoot._currentSelection)
_offlineMapRoot._currentSelection.cancelDownloadTask()
}
}
QGCButton {
text: qsTr("Back")
width: ScreenTools.defaultFontPixelWidth * 18
onClicked: {
leaveInfoView()
showList()
}
}
}
}
}
}
//-- Show info on default tile set
Rectangle {
id: _defaultInfoView
color: qgcPal.windowShade color: qgcPal.windowShade
width: parent.width width: parent.width
anchors.top: _offlineMapTopRect.bottom anchors.top: _offlineMapTopRect.bottom
@ -644,25 +891,31 @@ Rectangle {
width: 1 width: 1
} }
Rectangle { Rectangle {
id: _infoNameRect
width: infoWidth width: infoWidth
height: nameLabel.height + (ScreenTools.defaultFontPixelHeight * 2) height: infoCol.height + (ScreenTools.defaultFontPixelHeight * 2)
color: qgcPal.window color: qgcPal.window
radius: ScreenTools.defaultFontPixelHeight * 0.5 radius: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { Column {
id: nameLabel id: infoCol
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.name : "" spacing: ScreenTools.defaultFontPixelHeight
font.pixelSize: ScreenTools.isAndroid ? ScreenTools.mediumFontPixelSize : ScreenTools.largeFontPixelSize
anchors.centerIn: parent anchors.centerIn: parent
QGCLabel {
id: nameLabel
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.name : ""
font.pixelSize: ScreenTools.isAndroid ? ScreenTools.mediumFontPixelSize : ScreenTools.largeFontPixelSize
anchors.horizontalCenter: parent.horizontalCenter
}
QGCLabel {
id: descLabel
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.description : ""
anchors.horizontalCenter: parent.horizontalCenter
}
} }
} }
QGCLabel {
id: descLabel
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.description : ""
anchors.horizontalCenter: parent.horizontalCenter
}
Rectangle { Rectangle {
id: infoRect id: _infoRect
width: infoWidth width: infoWidth
height: infoGrid.height + (ScreenTools.defaultFontPixelHeight * 4) height: infoGrid.height + (ScreenTools.defaultFontPixelHeight * 4)
color: qgcPal.window color: qgcPal.window
@ -676,61 +929,29 @@ Rectangle {
rowSpacing: ScreenTools.defaultFontPixelWidth rowSpacing: ScreenTools.defaultFontPixelWidth
columnSpacing: ScreenTools.defaultFontPixelHeight * 2 columnSpacing: ScreenTools.defaultFontPixelHeight * 2
QGCLabel { QGCLabel {
text: qsTr("Map Type:") text: qsTr("Default Set Size:")
visible: !isDefaultSet
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.mapTypeStr : ""
visible: !isDefaultSet
}
QGCLabel {
text: qsTr("Min Zoom:")
visible: !isDefaultSet
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.minZoom : ""
visible: !isDefaultSet
}
QGCLabel {
text: qsTr("Max Zoom:")
visible: !isDefaultSet
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.maxZoom : ""
visible: !isDefaultSet
}
QGCLabel {
text: isDefaultSet ? qsTr("Default Set Size:") : qsTr("Total Size:")
} }
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.tilesSizeStr : "" text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.tilesSizeStr : ""
} }
QGCLabel { QGCLabel {
text: isDefaultSet ? qsTr("Default Set Tile Count:") : qsTr("Total Tile Count:") text: qsTr("Default Set Tile Count:")
} }
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.numTilesStr : "" text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.numTilesStr : ""
} }
QGCLabel { QGCLabel {
text: isDefaultSet ? qsTr("Total Size (All Sets):") : qsTr("Downloaded Size:") text: qsTr("Total Size (All Sets):")
} }
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedSizeStr : "" text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedSizeStr : ""
} }
QGCLabel { QGCLabel {
text: isDefaultSet ? qsTr("Total Count (All Sets):") : qsTr("Downloaded Count:") text: qsTr("Total Count (All Sets):")
} }
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedTilesStr : "" text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedTilesStr : ""
} }
QGCLabel {
text: qsTr("Error Count:")
visible: !isDefaultSet && _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.errorCountStr : ""
visible: !isDefaultSet && _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete
}
} }
} }
Item { Item {
@ -746,64 +967,38 @@ Rectangle {
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting) enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting)
onClicked: { onClicked: {
if(_offlineMapRoot._currentSelection) if(_offlineMapRoot._currentSelection)
deleteDialog.visible = true deleteDefaultDialog.visible = true
} }
MessageDialog { MessageDialog {
id: deleteDialog id: deleteDefaultDialog
visible: false visible: false
icon: StandardIcon.Warning icon: StandardIcon.Warning
standardButtons: StandardButton.Yes | StandardButton.No standardButtons: StandardButton.Yes | StandardButton.No
title: qsTr("Delete Tile Set") title: qsTr("Delete All Tiles")
text: { text: qsTr("Delete all cached tiles.\nIs this really what you want?")
if(_offlineMapRoot._currentSelection) {
var blurb = qsTr("Delete %1 and all its tiles.\nIs this really what you want?").arg(_offlineMapRoot._currentSelection.name)
if(_offlineMapRoot._currentSelection.defaultSet)
return blurb + qsTr("\nNote that deleteting the Default Set deletes all tiles from all sets.")
else
return blurb
}
return ""
}
onYes: { onYes: {
if(_offlineMapRoot._currentSelection) if(_offlineMapRoot._currentSelection)
QGroundControl.mapEngineManager.deleteTileSet(_offlineMapRoot._currentSelection) QGroundControl.mapEngineManager.deleteTileSet(_offlineMapRoot._currentSelection)
deleteDialog.visible = false deleteDefaultDialog.visible = false
showList() showList()
} }
onNo: { onNo: {
deleteDialog.visible = false deleteDefaultDialog.visible = false
} }
} }
} }
QGCButton { QGCButton {
text: qsTr("Resume Download") text: qsTr("Back")
width: ScreenTools.defaultFontPixelWidth * 18
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting && !_offlineMapRoot._currentSelection.downloading)
visible: !isDefaultSet && _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.complete && !_offlineMapRoot._currentSelection.downloading)
onClicked: {
if(_offlineMapRoot._currentSelection)
_offlineMapRoot._currentSelection.resumeDownloadTask()
}
}
QGCButton {
text: qsTr("Cancel Download")
width: ScreenTools.defaultFontPixelWidth * 18 width: ScreenTools.defaultFontPixelWidth * 18
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting && _offlineMapRoot._currentSelection.downloading)
visible: !isDefaultSet && _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.complete && _offlineMapRoot._currentSelection.downloading)
onClicked: { onClicked: {
if(_offlineMapRoot._currentSelection) showList()
_offlineMapRoot._currentSelection.cancelDownloadTask()
} }
} }
QGCButton {
text: qsTr("Back")
width: ScreenTools.defaultFontPixelWidth * 18
onClicked: showList()
}
} }
} }
} }
} }
Rectangle { Rectangle {
id: _optionsView id: _optionsView
color: qgcPal.windowShade color: qgcPal.windowShade

2
src/ui/MainWindowLeftPanel.qml

@ -193,6 +193,7 @@ Item {
anchors.right: parent.right anchors.right: parent.right
text: qsTr("Offline Maps") text: qsTr("Offline Maps")
exclusiveGroup: panelActionGroup exclusiveGroup: panelActionGroup
visible: !ScreenTools.isTinyScreen
onClicked: { onClicked: {
if(__rightPanel.source != "OfflineMap.qml") { if(__rightPanel.source != "OfflineMap.qml") {
__rightPanel.source = "OfflineMap.qml" __rightPanel.source = "OfflineMap.qml"
@ -282,6 +283,7 @@ Item {
//-- Main Setting Display Area //-- Main Setting Display Area
Rectangle { Rectangle {
id: settingDisplayArea
anchors.left: __verticalSeparator.right anchors.left: __verticalSeparator.right
width: mainWindow.width - __leftMenu.width - __verticalSeparator.width width: mainWindow.width - __leftMenu.width - __verticalSeparator.width
height: parent.height - toolBar.height - __topSeparator.height height: parent.height - toolBar.height - __topSeparator.height

Loading…
Cancel
Save