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 @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
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 { @@ -60,7 +60,7 @@ Button {
background: Item {
property bool down: control.pressed || (control.checkable && control.checked)
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 {
anchors.fill: parent

1
src/QmlControls/QGCTextField.qml

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

2
src/QmlControls/ScreenToolsController.cc

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

2
src/QtLocationPlugin/QGCMapEngine.cpp

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

503
src/QtLocationPlugin/QMLControl/OfflineMap.qml

@ -26,8 +26,8 @@ import QtQuick.Controls 1.2 @@ -26,8 +26,8 @@ import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QtLocation 5.5
import QtPositioning 5.5
import QGroundControl 1.0
import QGroundControl.Controls 1.0
@ -44,10 +44,14 @@ Rectangle { @@ -44,10 +44,14 @@ Rectangle {
property string mapKey: "lastMapType"
property string mapType: QGroundControl.mapEngineManager.loadSetting(mapKey, "Google Street Map")
property int mapMargin: (ScreenTools.defaultFontPixelHeight * 0.2).toFixed(0)
property real infoWidth: Math.max(Math.max(nameLabel.width, descLabel.width), (ScreenTools.defaultFontPixelWidth * 40))
property bool isDefaultSet: _offlineMapRoot._currentSelection && _offlineMapRoot._currentSelection.defaultSet
property string mapType: QGroundControl.mapEngineManager.loadSetting(mapKey, "Google Street Map")
property int mapMargin: (ScreenTools.defaultFontPixelHeight * 0.2).toFixed(0)
property real infoWidth: Math.max(infoCol.width, (ScreenTools.defaultFontPixelWidth * 40))
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 oldlon1: 0
@ -64,6 +68,7 @@ Rectangle { @@ -64,6 +68,7 @@ Rectangle {
Component.onCompleted: {
QGroundControl.mapEngineManager.loadTileSets()
updateMap()
savedCenter = _map.toCoordinate(Qt.point(_map.width / 2, _map.height / 2))
}
Connections {
@ -79,19 +84,21 @@ Rectangle { @@ -79,19 +84,21 @@ Rectangle {
ExclusiveGroup { id: setGroup }
function handleChanges() {
var xl = mapMargin
var yl = mapMargin
var xr = _map.width.toFixed(0) - mapMargin
var yr = _map.height.toFixed(0) - mapMargin
var c0 = _map.toCoordinate(Qt.point(xl, yl))
var c1 = _map.toCoordinate(Qt.point(xr, yr))
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)
if(isMapInteractive) {
var xl = mapMargin
var yl = mapMargin
var xr = _map.width.toFixed(0) - mapMargin
var yr = _map.height.toFixed(0) - mapMargin
var c0 = _map.toCoordinate(Qt.point(xl, yl))
var c1 = _map.toCoordinate(Qt.point(xr, yr))
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() {
if(QGroundControl.mapEngineManager.crazySize) {
if(isMapInteractive && QGroundControl.mapEngineManager.crazySize) {
_slider1.value = _slider1.value - 1
handleChanges()
}
@ -108,43 +115,105 @@ Rectangle { @@ -108,43 +115,105 @@ Rectangle {
}
function showOptions() {
_map.visible = false
_tileSetList.visible = false
_infoView.visible = false
_defaultInfoView.visible = false
_mapView.visible = false
_optionsView.visible = true
}
function showMap() {
_map.visible = true
_tileSetList.visible = false
_infoView.visible = false
_defaultInfoView.visible = false
_mapView.visible = true
_optionsView.visible = false
}
function showList() {
_map.visible = false
_tileSetList.visible = true
_infoView.visible = false
_defaultInfoView.visible = false
_mapView.visible = false
_optionsView.visible = false
}
function showInfo() {
if(_currentSelection && !_offlineMapRoot._currentSelection.deleting) {
_tileSetList.visible = false
_mapView.visible = false
_infoView.visible = true
_optionsView.visible = false
enterInfoView()
} else
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 {
id: _dropButtonsExclusiveGroup
}
onMapTypeChanged: {
updateMap()
QGroundControl.mapEngineManager.saveSetting(mapKey, mapType)
if(isMapInteractive) {
QGroundControl.mapEngineManager.saveSetting(mapKey, mapType)
}
}
MessageDialog {
@ -184,6 +253,62 @@ Rectangle { @@ -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 {
id: _tileSetList
clip: true
@ -240,57 +365,18 @@ Rectangle { @@ -240,57 +365,18 @@ Rectangle {
}
//-- Offline Map Definition
Rectangle {
Item {
id: _mapView
color: qgcPal.window
width: parent.width
anchors.top: _offlineMapTopRect.bottom
anchors.bottom: parent.bottom
anchors.margins: ScreenTools.defaultFontPixelWidth
visible: false
Rectangle {
//-- Zoom Preview Maps
Item {
width: parent.width
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 {
width: ScreenTools.defaultFontPixelHeight * 16
height: ScreenTools.defaultFontPixelHeight * 9
@ -330,11 +416,17 @@ Rectangle { @@ -330,11 +416,17 @@ Rectangle {
}
}
}
//-- Tile set settings
Rectangle {
id: bottomRect
width: parent.width
width: _controlRow.width + (ScreenTools.defaultFontPixelWidth * 2)
height: _controlRow.height + (ScreenTools.defaultFontPixelHeight * 2)
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
Row {
id: _controlRow
@ -487,27 +579,27 @@ Rectangle { @@ -487,27 +579,27 @@ Rectangle {
Label {
text: qsTr("Tile Count")
color: "black"
width: ScreenTools.defaultFontPixelWidth * 12
width: ScreenTools.defaultFontPixelWidth * 8
font.pixelSize: ScreenTools.smallFontPixelSize
horizontalAlignment: Text.AlignHCenter
}
Label {
text: QGroundControl.mapEngineManager.tileCountStr
color: "black"
width: ScreenTools.defaultFontPixelWidth * 12
width: ScreenTools.defaultFontPixelWidth * 8
horizontalAlignment: Text.AlignHCenter
}
Label {
text: qsTr("Set Size (Est)")
color: "black"
width: ScreenTools.defaultFontPixelWidth * 12
width: ScreenTools.defaultFontPixelWidth * 8
font.pixelSize: ScreenTools.smallFontPixelSize
horizontalAlignment: Text.AlignHCenter
}
Label {
text: QGroundControl.mapEngineManager.tileSizeStr
color: "black"
width: ScreenTools.defaultFontPixelWidth * 12
width: ScreenTools.defaultFontPixelWidth * 8
horizontalAlignment: Text.AlignHCenter
}
}
@ -526,7 +618,7 @@ Rectangle { @@ -526,7 +618,7 @@ Rectangle {
}
QGCTextField {
id: setName
width: ScreenTools.defaultFontPixelWidth * 24
width: ScreenTools.defaultFontPixelWidth * 20
anchors.verticalCenter: parent.verticalCenter
}
}
@ -541,7 +633,7 @@ Rectangle { @@ -541,7 +633,7 @@ Rectangle {
QGCTextField {
id: setDescription
text: qsTr("Description")
width: ScreenTools.defaultFontPixelWidth * 24
width: ScreenTools.defaultFontPixelWidth * 20
anchors.verticalCenter: parent.verticalCenter
}
}
@ -555,7 +647,7 @@ Rectangle { @@ -555,7 +647,7 @@ Rectangle {
}
QGCComboBox {
id: mapCombo
width: ScreenTools.defaultFontPixelWidth * 24
width: ScreenTools.defaultFontPixelWidth * 20
model: QGroundControl.mapEngineManager.mapList
onActivated: {
mapType = textAt(index)
@ -576,7 +668,7 @@ Rectangle { @@ -576,7 +668,7 @@ Rectangle {
}
Item {
height: 1
width: ScreenTools.defaultFontPixelWidth * 1.5
width: ScreenTools.defaultFontPixelWidth
}
Column {
anchors.verticalCenter: parent.verticalCenter
@ -621,8 +713,163 @@ Rectangle { @@ -621,8 +713,163 @@ Rectangle {
}
}
}
Rectangle {
//-- Show Set Info
Item {
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
width: parent.width
anchors.top: _offlineMapTopRect.bottom
@ -644,25 +891,31 @@ Rectangle { @@ -644,25 +891,31 @@ Rectangle {
width: 1
}
Rectangle {
id: _infoNameRect
width: infoWidth
height: nameLabel.height + (ScreenTools.defaultFontPixelHeight * 2)
height: infoCol.height + (ScreenTools.defaultFontPixelHeight * 2)
color: qgcPal.window
radius: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
id: nameLabel
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.name : ""
font.pixelSize: ScreenTools.isAndroid ? ScreenTools.mediumFontPixelSize : ScreenTools.largeFontPixelSize
Column {
id: infoCol
spacing: ScreenTools.defaultFontPixelHeight
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 {
id: infoRect
id: _infoRect
width: infoWidth
height: infoGrid.height + (ScreenTools.defaultFontPixelHeight * 4)
color: qgcPal.window
@ -676,61 +929,29 @@ Rectangle { @@ -676,61 +929,29 @@ Rectangle {
rowSpacing: ScreenTools.defaultFontPixelWidth
columnSpacing: ScreenTools.defaultFontPixelHeight * 2
QGCLabel {
text: qsTr("Map Type:")
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:")
text: qsTr("Default Set Size:")
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.tilesSizeStr : ""
}
QGCLabel {
text: isDefaultSet ? qsTr("Default Set Tile Count:") : qsTr("Total Tile Count:")
text: qsTr("Default Set Tile Count:")
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.numTilesStr : ""
}
QGCLabel {
text: isDefaultSet ? qsTr("Total Size (All Sets):") : qsTr("Downloaded Size:")
text: qsTr("Total Size (All Sets):")
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedSizeStr : ""
}
QGCLabel {
text: isDefaultSet ? qsTr("Total Count (All Sets):") : qsTr("Downloaded Count:")
text: qsTr("Total Count (All Sets):")
}
QGCLabel {
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 {
@ -746,64 +967,38 @@ Rectangle { @@ -746,64 +967,38 @@ Rectangle {
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting)
onClicked: {
if(_offlineMapRoot._currentSelection)
deleteDialog.visible = true
deleteDefaultDialog.visible = true
}
MessageDialog {
id: deleteDialog
id: deleteDefaultDialog
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)
if(_offlineMapRoot._currentSelection.defaultSet)
return blurb + qsTr("\nNote that deleteting the Default Set deletes all tiles from all sets.")
else
return blurb
}
return ""
}
title: qsTr("Delete All Tiles")
text: qsTr("Delete all cached tiles.\nIs this really what you want?")
onYes: {
if(_offlineMapRoot._currentSelection)
QGroundControl.mapEngineManager.deleteTileSet(_offlineMapRoot._currentSelection)
deleteDialog.visible = false
deleteDefaultDialog.visible = false
showList()
}
onNo: {
deleteDialog.visible = false
deleteDefaultDialog.visible = false
}
}
}
QGCButton {
text: qsTr("Resume Download")
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")
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.cancelDownloadTask()
showList()
}
}
QGCButton {
text: qsTr("Back")
width: ScreenTools.defaultFontPixelWidth * 18
onClicked: showList()
}
}
}
}
}
Rectangle {
id: _optionsView
color: qgcPal.windowShade

2
src/ui/MainWindowLeftPanel.qml

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

Loading…
Cancel
Save