Commit 28b482e6 authored by Don Gagne's avatar Don Gagne

Small screen re-work

parent eeed8ab7
...@@ -20,21 +20,18 @@ import QGroundControl 1.0 ...@@ -20,21 +20,18 @@ import QGroundControl 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
import QGroundControl.FlightMap 1.0
Rectangle { QGCView {
id: _offlineMapRoot id: offlineMapView
color: qgcPal.window viewPanel: panel
anchors.fill: parent anchors.fill: parent
anchors.margins: ScreenTools.defaultFontPixelWidth
property var _currentSelection: null property var _currentSelection: null
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 real infoWidth: Math.max(infoCol.width, (ScreenTools.defaultFontPixelWidth * 40))
property bool isDefaultSet: _offlineMapRoot._currentSelection && _offlineMapRoot._currentSelection.defaultSet
property bool isMapInteractive: true property bool isMapInteractive: true
property var savedCenter: undefined property var savedCenter: undefined
property real savedZoom: 3 property real savedZoom: 3
...@@ -51,10 +48,13 @@ Rectangle { ...@@ -51,10 +48,13 @@ Rectangle {
property int oldz0: 0 property int oldz0: 0
property int oldz1: 0 property int oldz1: 0
property bool _saveRealEstate: ScreenTools.isTinyScreen || ScreenTools.isShortScreen
property real _adjustableFontPointSize: _saveRealEstate ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
readonly property real minZoomLevel: 3 readonly property real minZoomLevel: 3
readonly property real maxZoomLevel: 20 readonly property real maxZoomLevel: 20
QGCPalette { id: qgcpal } QGCPalette { id: qgcPal }
Component.onCompleted: { Component.onCompleted: {
QGroundControl.mapEngineManager.loadTileSets() QGroundControl.mapEngineManager.loadTileSets()
...@@ -76,21 +76,21 @@ Rectangle { ...@@ -76,21 +76,21 @@ Rectangle {
function handleChanges() { function handleChanges() {
if(isMapInteractive) { if(isMapInteractive) {
var xl = mapMargin var xl = 0
var yl = mapMargin var yl = 0
var xr = _map.width.toFixed(0) - mapMargin var xr = _map.width.toFixed(0)
var yr = _map.height.toFixed(0) - mapMargin var yr = _map.height.toFixed(0)
var c0 = _map.toCoordinate(Qt.point(xl, yl)) var c0 = _map.toCoordinate(Qt.point(xl, yl))
var c1 = _map.toCoordinate(Qt.point(xr, yr)) 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) { if(oldlon0 !== c0.longitude || oldlat0 !== c0.latitude || oldlon1 !== c1.longitude || oldlat1 !== c1.latitude || oldz0 !== sliderMinZoom.value || oldz1 !== sliderMaxZoom.value) {
QGroundControl.mapEngineManager.updateForCurrentView(c0.longitude, c0.latitude, c1.longitude, c1.latitude, _slider0.value, _slider1.value, mapType) QGroundControl.mapEngineManager.updateForCurrentView(c0.longitude, c0.latitude, c1.longitude, c1.latitude, sliderMinZoom.value, sliderMaxZoom.value, mapType)
} }
} }
} }
function checkSanity() { function checkSanity() {
if(isMapInteractive && QGroundControl.mapEngineManager.crazySize) { if(isMapInteractive && QGroundControl.mapEngineManager.crazySize) {
_slider1.value = _slider1.value - 1 sliderMaxZoom.value = sliderMaxZoom.value - 1
handleChanges() handleChanges()
} }
} }
...@@ -105,35 +105,24 @@ Rectangle { ...@@ -105,35 +105,24 @@ Rectangle {
} }
} }
function showOptions() { function addNewSet() {
_map.visible = false
_tileSetList.visible = false
_infoView.visible = false
_defaultInfoView.visible = false
_mapView.visible = false
_optionsView.visible = true
}
function showMap() {
_map.visible = true _map.visible = true
_tileSetList.visible = false _tileSetList.visible = false
_infoView.visible = false infoView.visible = false
_defaultInfoView.visible = false defaultInfoView.visible = false
_mapView.visible = true addNewSetView.visible = true
_optionsView.visible = false
} }
function showList() { function showList() {
_map.visible = false _map.visible = false
_tileSetList.visible = true _tileSetList.visible = true
_infoView.visible = false infoView.visible = false
_defaultInfoView.visible = false defaultInfoView.visible = false
_mapView.visible = false addNewSetView.visible = false
_optionsView.visible = false
} }
function showInfo() { function showInfo() {
if(_currentSelection && !_offlineMapRoot._currentSelection.deleting) { if(_currentSelection && !offlineMapView._currentSelection.deleting) {
enterInfoView() enterInfoView()
} else } else
showList() showList()
...@@ -160,31 +149,31 @@ Rectangle { ...@@ -160,31 +149,31 @@ Rectangle {
} }
function enterInfoView() { function enterInfoView() {
if(!isDefaultSet) { var isDefaultSet = offlineMapView._currentSelection.defaultSet
_map.visible = true
isMapInteractive = false isMapInteractive = false
savedCenter = _map.toCoordinate(Qt.point(_map.width / 2, _map.height / 2)) savedCenter = _map.toCoordinate(Qt.point(_map.width / 2, _map.height / 2))
savedZoom = _map.zoomLevel savedZoom = _map.zoomLevel
savedMapType = mapType savedMapType = mapType
_map.visible = true if(!isDefaultSet) {
mapType = _offlineMapRoot._currentSelection.mapTypeStr mapType = offlineMapView._currentSelection.mapTypeStr
_map.center = midPoint(_offlineMapRoot._currentSelection.topleftLat, _offlineMapRoot._currentSelection.bottomRightLat, _offlineMapRoot._currentSelection.topleftLon, _offlineMapRoot._currentSelection.bottomRightLon) _map.center = midPoint(offlineMapView._currentSelection.topleftLat, offlineMapView._currentSelection.bottomRightLat, offlineMapView._currentSelection.topleftLon, offlineMapView._currentSelection.bottomRightLon)
//-- Delineate Set Region //-- Delineate Set Region
var x0 = _offlineMapRoot._currentSelection.topleftLon var x0 = offlineMapView._currentSelection.topleftLon
var x1 = _offlineMapRoot._currentSelection.bottomRightLon var x1 = offlineMapView._currentSelection.bottomRightLon
var y0 = _offlineMapRoot._currentSelection.topleftLat var y0 = offlineMapView._currentSelection.topleftLat
var y1 = _offlineMapRoot._currentSelection.bottomRightLat var y1 = offlineMapView._currentSelection.bottomRightLat
mapBoundary.topLeft = QtPositioning.coordinate(y0, x0) mapBoundary.topLeft = QtPositioning.coordinate(y0, x0)
mapBoundary.bottomRight = QtPositioning.coordinate(y1, x1) mapBoundary.bottomRight = QtPositioning.coordinate(y1, x1)
mapBoundary.visible = true mapBoundary.visible = true
_map.fitViewportToMapItems() _map.fitViewportToMapItems()
} }
_tileSetList.visible = false _tileSetList.visible = false
_mapView.visible = false addNewSetView.visible = false
_optionsView.visible = false
if(isDefaultSet) { if(isDefaultSet) {
_defaultInfoView.visible = true defaultInfoView.visible = true
} else { } else {
_infoView.visible= true infoView.visible= true
} }
} }
...@@ -213,55 +202,128 @@ Rectangle { ...@@ -213,55 +202,128 @@ Rectangle {
text: QGroundControl.mapEngineManager.errorMessage text: QGroundControl.mapEngineManager.errorMessage
icon: StandardIcon.Critical icon: StandardIcon.Critical
standardButtons: StandardButton.Ok standardButtons: StandardButton.Ok
title: qsTr("Errror Message") title: qsTr("Error Message")
onYes: { onYes: {
errorDialog.visible = false errorDialog.visible = false
} }
} }
Rectangle { Component {
id: _offlineMapTopRect id: optionsDialogComponent
width: parent.width
height: labelTitle.height + ScreenTools.defaultFontPixelHeight QGCViewDialog {
color: qgcPal.window id: optionDialog
function accept() {
QGroundControl.mapEngineManager.mapboxToken = mapBoxToken.text
QGroundControl.mapEngineManager.maxDiskCache = parseInt(maxCacheSize.text)
QGroundControl.mapEngineManager.maxMemCache = parseInt(maxCacheMemSize.text)
optionDialog.hideDialog()
}
QGCFlickable {
anchors.fill: parent
contentHeight: optionsColumn.height
Column {
id: optionsColumn
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
Row { spacing: ScreenTools.defaultFontPixelHeight / 2
spacing: ScreenTools.defaultFontPixelHeight * 2
anchors.verticalCenter: parent.verticalCenter QGCLabel { text: qsTr("Max Cache Disk Size (MB):") }
QGCTextField {
id: maxCacheSize
maximumLength: 6
inputMethodHints: Qt.ImhDigitsOnly
validator: IntValidator {bottom: 1; top: 262144;}
text: QGroundControl.mapEngineManager.maxDiskCache
}
Item { width: 1; height: 1 }
QGCLabel { text: qsTr("Max Cache Memory Size (MB):") }
QGCTextField {
id: maxCacheMemSize
maximumLength: 4
inputMethodHints: Qt.ImhDigitsOnly
validator: IntValidator {bottom: 1; top: 4096;}
text: QGroundControl.mapEngineManager.maxMemCache
}
QGCLabel {
font.pointSize: _adjustableFontPointSize
text: qsTr("Memory cache changes require a restart to take effect.")
}
Item { width: 1; height: 1 }
QGCLabel { text: qsTr("MapBox Access Token") }
QGCTextField {
id: mapBoxToken
maximumLength: 256
width: ScreenTools.defaultFontPixelWidth * 30
text: QGroundControl.mapEngineManager.mapboxToken
}
QGCLabel { QGCLabel {
id: labelTitle text: qsTr("With an access token, you can use MapBox Maps.")
text: qsTr("Offline Maps") font.pointSize: _adjustableFontPointSize
font.pointSize: ScreenTools.mediumFontPointSize }
anchors.verticalCenter: parent.verticalCenter } // GridLayout
} // QGCFlickable
} // QGCViewDialog - optionsDialog
} // Component - optionsDialogComponent
Component {
id: deleteConfirmationDialogComponent
QGCViewMessage {
id: deleteConfirmationDialog
message: qsTr("Delete %1 and all its tiles.\n\nIs this really what you want?").arg(offlineMapView._currentSelection.name)
function accept() {
QGroundControl.mapEngineManager.deleteTileSet(offlineMapView._currentSelection)
deleteConfirmationDialog.hideDialog()
leaveInfoView()
showList()
}
}
} }
QGCCheckBox {
id: showTilePreview Component {
text: qsTr("Show tile min/max zoom level preview") id: deleteSystemSetConfirmationDialogComponent
checked: false
visible: _mapView.visible && !ScreenTools.isTinyScreen QGCViewMessage {
anchors.verticalCenter: parent.verticalCenter id: deleteSystemSetConfirmationDialog
message: qsTr("This will delete all tiles INCLUDING the tile sets you have created yourself.\n\nIs this really what you want?")
function accept() {
QGroundControl.mapEngineManager.deleteTileSet(offlineMapView._currentSelection)
deleteSystemSetConfirmationDialog.hideDialog()
leaveInfoView()
showList()
} }
} }
} }
QGCViewPanel {
id: panel
anchors.fill: parent
Map { Map {
id: _map id: _map
anchors.top: _offlineMapTopRect.bottom anchors.fill: parent
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: mapMargin
width: parent.width - ScreenTools.defaultFontPixelWidth
center: QGroundControl.defaultMapPosition center: QGroundControl.defaultMapPosition
visible: false visible: false
gesture.flickDeceleration: 3000 gesture.flickDeceleration: 3000
plugin: Plugin { name: "QGroundControl" }
Rectangle { plugin: Plugin { name: "QGroundControl" }
color: Qt.rgba(0,0,0,0)
border.color: "black"
border.width: 1
anchors.fill: parent
}
MapRectangle { MapRectangle {
id: mapBoundary id: mapBoundary
...@@ -293,364 +355,352 @@ Rectangle { ...@@ -293,364 +355,352 @@ Rectangle {
handleChanges() handleChanges()
checkSanity() checkSanity()
} }
// Used to make pinch zoom work
MouseArea {
anchors.fill: parent
}
}
QGCFlickable { MapScale {
id: _tileSetList anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
clip: true anchors.bottomMargin: anchors.leftMargin
anchors.top: _offlineMapTopRect.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.bottom: parent.bottom
anchors.bottom: _optionsButton.top mapControl: _map
contentHeight: _cacheList.height }
flickableDirection: Flickable.VerticalFlick
Column { //-- Show Set Info
id: _cacheList Rectangle {
width: Math.min(parent.width, (ScreenTools.defaultFontPixelWidth * 50).toFixed(0)) id: infoView
anchors.margins: ScreenTools.defaultFontPixelWidth anchors.margins: ScreenTools.defaultFontPixelWidth
spacing: ScreenTools.defaultFontPixelHeight * 0.5 y: Math.max(anchors.margins, (parent.height - (anchors.margins * 2) - height) / 2)
anchors.horizontalCenter: parent.horizontalCenter anchors.right: parent.right
width: Math.max(ScreenTools.defaultFontPixelWidth * 20, controlInfoFlickable.width + (infoView._margins * 2))
height: Math.min(parent.height - (anchors.margins * 2), controlInfoFlickable.y + controlInfoColumn.height + ScreenTools.defaultFontPixelHeight)
color: qgcPal.window
opacity: 0.85
radius: ScreenTools.defaultFontPixelWidth * 0.5
visible: false
OfflineMapButton { readonly property real _margins: ScreenTools.defaultFontPixelHeight / 2
text: qsTr("Add new set")
anchors.left: parent.left QGCLabel {
anchors.margins: ScreenTools.defaultFontPixelHeight / 4
anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight * 2 text: "X"
onClicked: {
_offlineMapRoot._currentSelection = null
showMap()
}
} }
Repeater {
model: QGroundControl.mapEngineManager.tileSets Column {
delegate: OfflineMapButton { id: titleColumn
text: object.name anchors.margins: infoView._margins
size: object.downloadStatus anchors.top: parent.top
complete: object.complete
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight * 2
onClicked: {
_offlineMapRoot._currentSelection = object
showInfo()
}
}
}
}
}
QGCButton { QGCLabel {
id: _optionsButton anchors.left: parent.left
text: qsTr("Options")
visible: _tileSetList.visible
anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelWidth wrapMode: Text.WordWrap
onClicked: showOptions() text: offlineMapView._currentSelection ? offlineMapView._currentSelection.name : ""
font.pointSize: _saveRealEstate ? ScreenTools.defaultFontPointSize : ScreenTools.mediumFontPointSize
horizontalAlignment: Text.AlignHCenter
} }
//-- Offline Map Definition QGCLabel {
Item {
id: _mapView
width: parent.width
anchors.top: _offlineMapTopRect.bottom
anchors.bottom: parent.bottom
anchors.margins: ScreenTools.defaultFontPixelWidth
visible: false
//-- Zoom Preview Maps
Item {
width: parent.width
anchors.top: parent.top
visible: showTilePreview.checked
Rectangle {
width: ScreenTools.defaultFontPixelHeight * 16
height: ScreenTools.defaultFontPixelHeight * 9
anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.margins: ScreenTools.defaultFontPixelHeight anchors.right: parent.right
color: "black" wrapMode: Text.WordWrap
Map { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.description : ""
id: _mapMin visible: text !== qsTr("Description")
anchors.fill: parent horizontalAlignment: Text.AlignHCenter
anchors.margins: 2
zoomLevel: _slider0.value
center: _map.center
gesture.enabled: false
activeMapType: _map.activeMapType
plugin: Plugin { name: "QGroundControl" }
}
} }
Rectangle {
width: ScreenTools.defaultFontPixelHeight * 16 QGCLabel {
height: ScreenTools.defaultFontPixelHeight * 9 anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelHeight wrapMode: Text.WordWrap
color: "black" text: offlineMapView._currentSelection ? "(" + offlineMapView._currentSelection.mapTypeStr + ")" : ""
Map { horizontalAlignment: Text.AlignHCenter
id: _mapMax
anchors.fill: parent
anchors.margins: 2
zoomLevel: _slider1.value
center: _map.center
gesture.enabled: false
activeMapType: _map.activeMapType
plugin: Plugin { name: "QGroundControl" }
} }
} }
MouseArea {
anchors.fill: titleColumn
preventStealing: true
onClicked: {
leaveInfoView()
showList()
} }
//-- Tile set settings
Rectangle {
id: bottomRect
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)
} }
QGCFlickable {
id: controlInfoFlickable
anchors.margins: infoView._margins
anchors.top: titleColumn.bottom
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
Row { anchors.left: parent.left
id: _controlRow width: controlInfoColumn.width
anchors.centerIn: parent clip: true
spacing: ScreenTools.defaultFontPixelWidth * 0.5 contentHeight: controlInfoColumn.height
Rectangle {
height: _zoomRow.height + ScreenTools.defaultFontPixelHeight * 1.5
width: _zoomRow.width + ScreenTools.defaultFontPixelWidth
color: "#98aca4"
border.color: "black"
border.width: 2
radius: ScreenTools.defaultFontPixelWidth * 0.5
anchors.verticalCenter: parent.verticalCenter
Row {
id: _zoomRow
anchors.centerIn: parent
Column {
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.verticalCenter: parent.verticalCenter
Row {
spacing: ScreenTools.defaultFontPixelWidth * 0.5
Column { Column {
anchors.verticalCenter: parent.verticalCenter id: controlInfoColumn
Label { spacing: ScreenTools.defaultFontPixelHeight
text: qsTr("Min")
color: "black" GridLayout {
width: ScreenTools.defaultFontPixelWidth * 4 columns: 2
font.pointSize: ScreenTools.smallFontPointSize rowSpacing: 0
horizontalAlignment: Text.AlignHCenter
font.family: ScreenTools.normalFontFamily QGCLabel { text: qsTr("Min Zoom:") }
} QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.minZoom : "" }
Label {
text: qsTr("Zoom") QGCLabel { text: qsTr("Max Zoom:") }
color: "black" QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.maxZoom : "" }
width: ScreenTools.defaultFontPixelWidth * 4
font.family: ScreenTools.normalFontFamily QGCLabel { text: qsTr("Total:") }
font.pointSize: ScreenTools.smallFontPointSize QGCLabel { text: (offlineMapView._currentSelection ? offlineMapView._currentSelection.numTilesStr : "") + " (" + (offlineMapView._currentSelection ? offlineMapView._currentSelection.tilesSizeStr : "") + ")" }
horizontalAlignment: Text.AlignHCenter
QGCLabel {
text: qsTr("Downloaded:")
visible: offlineMapView._currentSelection && !offlineMapView._currentSelection.complete
} }
QGCLabel {
text: (offlineMapView._currentSelection ? offlineMapView._currentSelection.savedTilesStr : "") + " (" + (offlineMapView._currentSelection ? offlineMapView._currentSelection.savedSizeStr : "") + ")"
visible: offlineMapView._currentSelection && !offlineMapView._currentSelection.complete
} }
Slider {
id: _slider0 QGCLabel {
minimumValue: minZoomLevel text: qsTr("Error Count:")
maximumValue: maxZoomLevel visible: offlineMapView._currentSelection && !offlineMapView._currentSelection.complete
stepSize: 1
tickmarksEnabled: false
orientation: Qt.Horizontal
updateValueWhileDragging: true
anchors.verticalCenter: parent.verticalCenter
style: SliderStyle {
groove: Rectangle {
implicitWidth: _netSetSliderWidth
implicitHeight: 4
color: "gray"
radius: 4
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "lightgray"
border.color: "gray"
border.width: 2
implicitWidth: ScreenTools.defaultFontPixelWidth * 3
implicitHeight: ScreenTools.defaultFontPixelWidth * 3
radius: 10
Label {
text: _slider0.value
anchors.centerIn: parent
font.family: ScreenTools.normalFontFamily
font.pointSize: ScreenTools.smallFontPointSize
} }
QGCLabel {
text: offlineMapView._currentSelection ? offlineMapView._currentSelection.errorCountStr : ""
visible: offlineMapView._currentSelection && !offlineMapView._currentSelection.complete
} }
} }
Component.onCompleted: {
_slider0.value = _map.zoomLevel - 2 QGCButton {
text: qsTr("Resume Download")
visible: offlineMapView._currentSelection && (!offlineMapView._currentSelection.complete && !offlineMapView._currentSelection.downloading)
onClicked: {
if(offlineMapView._currentSelection)
offlineMapView._currentSelection.resumeDownloadTask()
} }
onValueChanged: {
if(_slider1) {
if(_slider0.value > _slider1.value)
_slider1.value = _slider0.value
else {
handleChanges()
checkSanity()
} }
QGCButton {
text: qsTr("Cancel Download")
visible: offlineMapView._currentSelection && (!offlineMapView._currentSelection.complete && offlineMapView._currentSelection.downloading)
onClicked: {
if(offlineMapView._currentSelection)
offlineMapView._currentSelection.cancelDownloadTask()
} }
} }
QGCButton {
text: qsTr("Delete")
onClicked: showDialog(deleteConfirmationDialogComponent, qsTr("Confirm Delete"), qgcView.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
} }
} // Column
} // QGCFlickable
} // Rectangle - infoView
//-- Show Default Set Info
Rectangle {
id: defaultInfoView
anchors.margins: ScreenTools.defaultFontPixelWidth
y: Math.max(anchors.margins, (parent.height - (anchors.margins * 2) - height) / 2)
anchors.right: parent.right
width: ScreenTools.defaultFontPixelWidth * 20
height: Math.min(parent.height - (anchors.margins * 2), defaultControlInfoFlickable.y + defaultControlInfoColumn.height + ScreenTools.defaultFontPixelHeight)
color: qgcPal.window
opacity: 0.85
radius: ScreenTools.defaultFontPixelWidth * 0.5
visible: false
QGCLabel {
anchors.margins: ScreenTools.defaultFontPixelHeight / 4
anchors.top: parent.top
anchors.right: parent.right
text: "X"
} }
Row {
spacing: ScreenTools.defaultFontPixelWidth * 0.5
Column { Column {
anchors.verticalCenter: parent.verticalCenter id: defaultTitleColumn
Label { anchors.margins: ScreenTools.defaultFontPixelHeight / 2
text: qsTr("Max") anchors.top: parent.top
color: "black" anchors.left: parent.left
width: ScreenTools.defaultFontPixelWidth * 4 anchors.right: parent.right
font.pointSize: ScreenTools.smallFontPointSize
font.family: ScreenTools.normalFontFamily QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: offlineMapView._currentSelection ? offlineMapView._currentSelection.name : ""
font.pointSize: _saveRealEstate ? ScreenTools.defaultFontPointSize : ScreenTools.mediumFontPointSize
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
Label {
text: qsTr("Zoom") QGCLabel {
color: "black" anchors.left: parent.left
width: ScreenTools.defaultFontPixelWidth * 4 anchors.right: parent.right
font.pointSize: ScreenTools.smallFontPointSize wrapMode: Text.WordWrap
font.family: ScreenTools.normalFontFamily text: qsTr("System Wide Tile Cache")
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
} }
Slider {
id: _slider1 MouseArea {
minimumValue: minZoomLevel anchors.fill: defaultTitleColumn
maximumValue: maxZoomLevel preventStealing: true
stepSize: 1
tickmarksEnabled: false onClicked: {
orientation: Qt.Horizontal leaveInfoView()
updateValueWhileDragging: true showList()
anchors.verticalCenter: parent.verticalCenter
style: SliderStyle {
groove: Rectangle {
implicitWidth: _netSetSliderWidth
implicitHeight: 4
color: "gray"
radius: 4
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "lightgray"
border.color: "gray"
border.width: 2
implicitWidth: ScreenTools.defaultFontPixelWidth * 3
implicitHeight: ScreenTools.defaultFontPixelWidth * 3
radius: 10
Label {
text: _slider1.value
anchors.centerIn: parent
font.family: ScreenTools.normalFontFamily
font.pointSize: ScreenTools.smallFontPointSize
}
}
}
Component.onCompleted: {
_slider1.value = _map.zoomLevel + 2
}
onValueChanged: {
if(_slider1.value < _slider0.value)
_slider0.value = _slider1.value
else {
handleChanges()
checkSanity()
} }
} }
QGCFlickable {
id: defaultControlInfoFlickable
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.top: defaultTitleColumn.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
clip: true
contentHeight: defaultControlInfoColumn.height
Column {
id: defaultControlInfoColumn
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight
GridLayout {
columns: 2
rowSpacing: 0
QGCLabel {
Layout.columnSpan: 2
text: qsTr("System Cache")
} }
QGCLabel { text: qsTr("Size:") }
QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.tilesSizeStr : "" }
QGCLabel { text: qsTr("Tile Count:") }
QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.numTilesStr : "" }
Item {
width: 1
height: ScreenTools.defaultFontPixelHeight
Layout.columnSpan: 2
} }
QGCLabel {
Layout.columnSpan: 2
text: qsTr("All Sets")
} }
Column {
spacing: ScreenTools.defaultFontPixelHeight * 0.5 QGCLabel { text: qsTr("Size:") }
anchors.verticalCenter: parent.verticalCenter QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.savedSizeStr : "" }
Label {
text: qsTr("Tile Count") QGCLabel { text: qsTr("Tile Count:") }
color: "black" QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.savedTilesStr : ""}
width: ScreenTools.defaultFontPixelWidth * 12
font.pointSize: ScreenTools.smallFontPointSize
font.family: ScreenTools.normalFontFamily
horizontalAlignment: Text.AlignHCenter
} }
Label {
text: QGroundControl.mapEngineManager.tileCountStr QGCButton {
color: "black" text: qsTr("Delete All")
width: ScreenTools.defaultFontPixelWidth * 12 onClicked: showDialog(deleteSystemSetConfirmationDialogComponent, qsTr("Confirm Delete All"), qgcView.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
font.family: ScreenTools.normalFontFamily
font.pointSize: ScreenTools.defaultFontPointSize
horizontalAlignment: Text.AlignHCenter
} }
Label { } // Column
text: qsTr("Set Size (Est)") } // QGCFlickable
color: "black" } // Rectangle - defaultInfoView
width: ScreenTools.defaultFontPixelWidth * 12
font.pointSize: ScreenTools.smallFontPointSize //-- Add New Set View
font.family: ScreenTools.normalFontFamily Rectangle {
horizontalAlignment: Text.AlignHCenter id: addNewSetView
anchors.margins: ScreenTools.defaultFontPixelWidth
y: Math.max(anchors.margins, (parent.height - (anchors.margins * 2) - height) / 2)
anchors.right: parent.right
width: ScreenTools.defaultFontPixelWidth * 20
height: Math.min(parent.height - (anchors.margins * 2), addNewSetFlickable.y + addNewSetColumn.height + ScreenTools.defaultFontPixelHeight)
color: qgcPal.window
opacity: 0.85
radius: ScreenTools.defaultFontPixelWidth * 0.5
visible: false
QGCLabel {
anchors.margins: ScreenTools.defaultFontPixelHeight / 4
anchors.top: parent.top
anchors.right: parent.right
text: "X"
} }
Label {
text: QGroundControl.mapEngineManager.tileSizeStr QGCLabel {
color: "black" id: addNewSetLabel
width: ScreenTools.defaultFontPixelWidth * 12 anchors.margins: ScreenTools.defaultFontPixelHeight / 2
font.family: ScreenTools.normalFontFamily anchors.top: parent.top
font.pointSize: ScreenTools.defaultFontPointSize anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: qsTr("Add New Set")
font.pointSize: _saveRealEstate ? ScreenTools.defaultFontPointSize : ScreenTools.mediumFontPointSize
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
MouseArea {
anchors.fill: addNewSetLabel
preventStealing: true
onClicked: showList()
} }
}
} QGCFlickable {
id: addNewSetFlickable
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
anchors.rightMargin: anchors.leftMargin
anchors.topMargin: ScreenTools.defaultFontPixelWidth / 3
anchors.bottomMargin: anchors.topMargin
anchors.top: addNewSetLabel.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
clip: true
contentHeight: addNewSetColumn.height
Column { Column {
anchors.verticalCenter: parent.verticalCenter id: addNewSetColumn
spacing: ScreenTools.defaultFontPixelHeight * 0.5 anchors.left: parent.left
Row { anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelHeight / (ScreenTools.isTinyScreen ? 4 : 2)
QGCLabel {
text: qsTr("Name:") Column {
width: _newSetMiddleLabel anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right
horizontalAlignment: Text.AlignRight
} QGCLabel { text: qsTr("Name:") }
QGCTextField { QGCTextField {
id: setName id: setName
width: _newSetMiddleField anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Description:")
width: _newSetMiddleLabel
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignRight
}
QGCTextField {
id: setDescription
text: qsTr("Description")
width: _newSetMiddleField
anchors.verticalCenter: parent.verticalCenter
} }
} }
Row {
spacing: ScreenTools.defaultFontPixelWidth Column {
anchors.left: parent.left
anchors.right: parent.right
QGCLabel { QGCLabel {
text: qsTr("Map Type:") text: qsTr("Map type:")
width: _newSetMiddleLabel visible: !_saveRealEstate
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignRight
} }
QGCComboBox { QGCComboBox {
id: mapCombo id: mapCombo
width: _newSetMiddleField anchors.left: parent.left
anchors.right: parent.right
model: QGroundControl.mapEngineManager.mapList model: QGroundControl.mapEngineManager.mapList
onActivated: { onActivated: {
mapType = textAt(index) mapType = textAt(index)
...@@ -658,6 +708,7 @@ Rectangle { ...@@ -658,6 +708,7 @@ Rectangle {
_dropButtonsExclusiveGroup.current.checked = false _dropButtonsExclusiveGroup.current.checked = false
_dropButtonsExclusiveGroup.current = null _dropButtonsExclusiveGroup.current = null
} }
Component.onCompleted: { Component.onCompleted: {
var index = mapCombo.find(mapType) var index = mapCombo.find(mapType)
if (index === -1) { if (index === -1) {
...@@ -668,468 +719,202 @@ Rectangle { ...@@ -668,468 +719,202 @@ Rectangle {
} }
} }
} }
}
Item {
height: 1
width: ScreenTools.defaultFontPixelWidth
}
Column {
anchors.verticalCenter: parent.verticalCenter
spacing: ScreenTools.defaultFontPixelHeight * 0.5
QGCButton {
text: qsTr("Download")
enabled: setName.text.length > 0
width: ScreenTools.defaultFontPixelWidth * 10
onClicked: {
if(QGroundControl.mapEngineManager.findName(setName.text)) {
duplicateName.visible = true
} else {
/* This does not work if hosted by QQuickWidget. Waiting until we're 100% QtQuick
var mapImage
_map.grabToImage(function(result) { mapImage = result; })
QGroundControl.mapEngineManager.startDownload(setName.text, setDescription.text, mapType, mapImage);
*/
QGroundControl.mapEngineManager.startDownload(setName.text, setDescription.text, mapType);
showList()
}
}
}
QGCButton {
text: qsTr("Cancel")
width: ScreenTools.defaultFontPixelWidth * 10
onClicked: {
showList()
}
}
MessageDialog {
id: duplicateName
visible: false
icon: StandardIcon.Warning
standardButtons: StandardButton.Ok
title: qsTr("Tile Set Already Exists")
text: qsTr("Tile Set \"%1\" already exists.\nPlease select a different name.").arg(setName.text)
onYes: {
duplicateName.visible = false
}
}
}
}
}
}
//-- Show Set Info
Item {
id: _infoView
width: parent.width
anchors.bottom: parent.bottom
anchors.margins: ScreenTools.defaultFontPixelWidth
visible: false
//-- Tile set settings
Rectangle { Rectangle {
id: bottomInfoRect anchors.left: parent.left
width: _controlInfoRow.width + (ScreenTools.defaultFontPixelWidth * 2) anchors.right: parent.right
height: _controlInfoRow.height + (ScreenTools.defaultFontPixelHeight * 2) height: zoomColumn.height + ScreenTools.defaultFontPixelHeight / 2
color: qgcPal.window color: qgcPal.window
border.color: qgcPal.text
radius: ScreenTools.defaultFontPixelWidth * 0.5 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 { Column {
anchors.rightMargin: ScreenTools.defaultFontPixelWidth id: zoomColumn
anchors.leftMargin: ScreenTools.defaultFontPixelWidth anchors.margins: ScreenTools.defaultFontPixelHeight / 4
anchors.verticalCenter: parent.verticalCenter anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelHeight * 0.5 anchors.left: parent.left
QGCLabel { anchors.right: parent.right
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.name : ""
font.pointSize: ScreenTools.isAndroid ? ScreenTools.mediumFontPointSize : ScreenTools.largeFontPointSize
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 { QGCLabel {
text: qsTr("Min Zoom:") text: qsTr("Min Zoom:")
font.pointSize: _adjustableFontPointSize
} }
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.minZoom : "" Slider {
} id: sliderMinZoom
QGCLabel { anchors.left: parent.left
text: qsTr("Max Zoom:") anchors.right: parent.right
} height: setName.height
QGCLabel { minimumValue: minZoomLevel
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.maxZoom : "" maximumValue: maxZoomLevel
} stepSize: 1
QGCLabel { updateValueWhileDragging: true
text: qsTr("Total:")
} property real _savedZoom
QGCLabel {
text: (_offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.numTilesStr : "") + " (" + (_offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.tilesSizeStr : "") + ")" Component.onCompleted: sliderMinZoom.value = _map.zoomLevel - 2
onValueChanged: {
if(sliderMinZoom.value > sliderMaxZoom.value) {
sliderMaxZoom.value = sliderMinZoom.value
} }
QGCLabel { handleChanges()
text: qsTr("Downloaded:") checkSanity()
visible: _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete _map.zoomLevel = sliderMinZoom.value
} }
QGCLabel {
text: (_offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedTilesStr : "") + " (" + (_offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedSizeStr : "") + ")" onPressedChanged: {
visible: _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete if (pressed) {
_savedZoom = _map.zoomLevel
_map.zoomLevel = sliderMinZoom.value
} else {
_map.zoomLevel = _savedZoom
} }
QGCLabel {
text: qsTr("Error Count:")
visible: _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete
} }
} // Slider - min zoom
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.errorCountStr : "" text: qsTr("Max Zoom:")
visible: _offlineMapRoot._currentSelection && !_offlineMapRoot._currentSelection.complete font.pointSize: _adjustableFontPointSize
}
}
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()
}
}
}
}
} }
Slider {
id: sliderMaxZoom
anchors.left: parent.left
anchors.right: parent.right
height: setName.height
minimumValue: minZoomLevel
maximumValue: maxZoomLevel
stepSize: 1
updateValueWhileDragging: true
property real _savedZoom
Component.onCompleted: {
sliderMaxZoom.value = _map.zoomLevel + 2
} }
//-- Show info on default tile set onValueChanged: {
Rectangle { if(sliderMaxZoom.value < sliderMinZoom.value) {
id: _defaultInfoView sliderMinZoom.value = sliderMaxZoom.value
color: qgcPal.windowShade
width: parent.width
anchors.top: _offlineMapTopRect.bottom
anchors.bottom: parent.bottom
anchors.margins: ScreenTools.defaultFontPixelWidth
visible: false
QGCFlickable {
id: infoScroll
anchors.fill: parent
contentHeight: infoColumn.height
flickableDirection: Flickable.VerticalFlick
clip: true
Column {
id: infoColumn
width: parent.width
spacing: ScreenTools.defaultFontPixelHeight
Item {
height: ScreenTools.defaultFontPixelHeight * 0.5
width: 1
} }
Rectangle { handleChanges()
id: _infoNameRect checkSanity()
width: infoWidth if (pressed) {
height: infoCol.height + (ScreenTools.defaultFontPixelHeight * 2) _map.zoomLevel = sliderMaxZoom.value
color: qgcPal.window
radius: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
Column {
id: infoCol
spacing: ScreenTools.defaultFontPixelHeight
anchors.centerIn: parent
QGCLabel {
id: nameLabel
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.name : ""
font.pointSize: ScreenTools.isAndroid ? ScreenTools.mediumFontPointSize : ScreenTools.largeFontPointSize
anchors.horizontalCenter: parent.horizontalCenter
} }
QGCLabel {
id: descLabel
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.description : ""
anchors.horizontalCenter: parent.horizontalCenter
} }
onPressedChanged: {
if (pressed) {
_savedZoom = _map.zoomLevel
_map.zoomLevel = sliderMaxZoom.value
} else {
_map.zoomLevel = _savedZoom
} }
} }
Rectangle { } // Slider - max zoom
id: _infoRect
width: infoWidth
height: infoGrid.height + (ScreenTools.defaultFontPixelHeight * 4)
color: qgcPal.window
radius: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
GridLayout { GridLayout {
id: infoGrid
columns: 2 columns: 2
anchors.centerIn: parent rowSpacing: 0
anchors.margins: ScreenTools.defaultFontPixelWidth * 2
rowSpacing: ScreenTools.defaultFontPixelWidth
columnSpacing: ScreenTools.defaultFontPixelHeight * 2
QGCLabel {
text: qsTr("Default Set Size:")
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.tilesSizeStr : ""
}
QGCLabel {
text: qsTr("Default Set Tile Count:")
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.numTilesStr : ""
}
QGCLabel { QGCLabel {
text: qsTr("Total Size (All Sets):") text: qsTr("Tile Count")
font.pointSize: _adjustableFontPointSize
} }
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedSizeStr : "" text: QGroundControl.mapEngineManager.tileCountStr
font.pointSize: _adjustableFontPointSize
} }
QGCLabel { QGCLabel {
text: qsTr("Total Count (All Sets):") text: qsTr("Set Size (Est)")
font.pointSize: _adjustableFontPointSize
} }
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedTilesStr : "" text: QGroundControl.mapEngineManager.tileSizeStr
} font.pointSize: _adjustableFontPointSize
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: ScreenTools.defaultFontPixelWidth
QGCButton {
width: ScreenTools.defaultFontPixelWidth * 18
text: qsTr("Delete")
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting)
onClicked: {
if(_offlineMapRoot._currentSelection)
deleteDefaultDialog.visible = true
}
MessageDialog {
id: deleteDefaultDialog
visible: false
icon: StandardIcon.Warning
standardButtons: StandardButton.Yes | StandardButton.No
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)
deleteDefaultDialog.visible = false
showList()
}
onNo: {
deleteDefaultDialog.visible = false
}
} }
} }
} // Column - Zoom info
} // Rectangle - Zoom info
QGCButton { QGCButton {
text: qsTr("Back") text: qsTr("Download")
width: ScreenTools.defaultFontPixelWidth * 18 enabled: setName.text.length > 0
anchors.horizontalCenter: parent.horizontalCenter
onClicked: { onClicked: {
if(QGroundControl.mapEngineManager.findName(setName.text)) {
duplicateName.visible = true
} else {
/* This does not work if hosted by QQuickWidget. Waiting until we're 100% QtQuick
var mapImage
_map.grabToImage(function(result) { mapImage = result; })
QGroundControl.mapEngineManager.startDownload(setName.text, "Description", mapType, mapImage);
*/
QGroundControl.mapEngineManager.startDownload(setName.text, "Description" /* Description */, mapType);
showList() showList()
} }
} }
} }
} } // Column
} } // QGCFlickable
} } // Rectangle - addNewSetView
} // Map
Rectangle {
id: _optionsView
color: qgcPal.windowShade
width: parent.width
anchors.top: _offlineMapTopRect.bottom
anchors.bottom: parent.bottom
anchors.margins: ScreenTools.defaultFontPixelWidth
visible: false
onVisibleChanged: {
if(_optionsView.visible) {
mapBoxToken.text = QGroundControl.mapEngineManager.mapboxToken
maxCacheSize.text = QGroundControl.mapEngineManager.maxDiskCache
maxCacheMemSize.text = QGroundControl.mapEngineManager.maxMemCache
}
}
QGCFlickable { QGCFlickable {
id: optionsScroll id: _tileSetList
anchors.fill: parent
contentHeight: optionsColumn.height
flickableDirection: Flickable.VerticalFlick
clip: true clip: true
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.top: parent.top
anchors.bottom: _optionsButton.top
anchors.left: parent.left
anchors.right: parent.right
contentHeight: _cacheList.height
Column { Column {
id: optionsColumn id: _cacheList
width: parent.width width: Math.min(_tileSetList.width, (ScreenTools.defaultFontPixelWidth * 50).toFixed(0))
spacing: ScreenTools.defaultFontPixelHeight spacing: ScreenTools.defaultFontPixelHeight * 0.5
Item {
height: ScreenTools.defaultFontPixelHeight
width: 1
}
Rectangle {
width: infoWidth
height: optionsLabel.height + (ScreenTools.defaultFontPixelHeight * 2)
color: qgcPal.window
radius: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
id: optionsLabel
text: qsTr("Offline Map Options")
font.pointSize: ScreenTools.largeFontPointSize
anchors.centerIn: parent
}
}
Rectangle {
id: optionsRect
width: optionsGrid.width + (ScreenTools.defaultFontPixelWidth * 4)
height: optionsGrid.height + (ScreenTools.defaultFontPixelHeight * 4)
color: qgcPal.window
radius: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
GridLayout {
id: optionsGrid
columns: 2
anchors.centerIn: parent
anchors.margins: ScreenTools.defaultFontPixelWidth * 2
rowSpacing: ScreenTools.defaultFontPixelWidth * 1.5
columnSpacing: ScreenTools.defaultFontPixelHeight * 2
QGCLabel {
text: qsTr("Max Cache Disk Size (MB):")
}
QGCTextField {
id: maxCacheSize
maximumLength: 6
inputMethodHints: Qt.ImhDigitsOnly
validator: IntValidator {bottom: 1; top: 262144;}
}
QGCLabel {
text: qsTr("Max Cache Memory Size (MB):")
}
QGCTextField {
id: maxCacheMemSize
maximumLength: 4
inputMethodHints: Qt.ImhDigitsOnly
validator: IntValidator {bottom: 1; top: 4096;}
}
Item {
Layout.columnSpan: 2
Layout.fillWidth: true
height: ScreenTools.defaultFontPixelHeight * 1.5
QGCLabel {
anchors.centerIn: parent
text: qsTr("Memory cache changes require a restart to take effect.")
font.pointSize: ScreenTools.smallFontPointSize
}
}
Rectangle {
Layout.columnSpan: 2
Layout.fillWidth: true
height: 1
color: qgcPal.text
}
QGCLabel {
text: qsTr("MapBox Access Token")
}
QGCTextField {
id: mapBoxToken
maximumLength: 256
width: ScreenTools.defaultFontPixelWidth * 30
}
Item {
Layout.columnSpan: 2
Layout.fillWidth: true
height: ScreenTools.defaultFontPixelHeight * 1.5
QGCLabel {
anchors.centerIn: parent
text: qsTr("With an access token, you can use MapBox Maps.")
font.pointSize: ScreenTools.smallFontPointSize
}
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
spacing: ScreenTools.defaultFontPixelWidth
QGCButton { OfflineMapButton {
text: qsTr("Save") id: firstButton
width: ScreenTools.defaultFontPixelWidth * 18 text: qsTr("Add new set")
width: _cacheList.width
height: ScreenTools.defaultFontPixelHeight * 2
onClicked: { onClicked: {
QGroundControl.mapEngineManager.mapboxToken = mapBoxToken.text offlineMapView._currentSelection = null
QGroundControl.mapEngineManager.maxDiskCache = parseInt(maxCacheSize.text) addNewSet()
QGroundControl.mapEngineManager.maxMemCache = parseInt(maxCacheMemSize.text)
showList()
} }
} }
QGCButton { Repeater {
text: qsTr("Cancel") model: QGroundControl.mapEngineManager.tileSets
width: ScreenTools.defaultFontPixelWidth * 18 delegate: OfflineMapButton {
text: object.name
size: object.downloadStatus
complete: object.complete
width: firstButton.width
height: ScreenTools.defaultFontPixelHeight * 2
onClicked: { onClicked: {
showList() offlineMapView._currentSelection = object
showInfo()
} }
} }
} }
} }
} }
QGCButton {
id: _optionsButton
text: qsTr("Options")
visible: _tileSetList.visible
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelWidth
onClicked: showDialog(optionsDialogComponent, qsTr("Offline Maps Options"), qgcView.showDialogDefaultWidth, StandardButton.Save | StandardButton.Cancel)
} }
} } // QGCViewPanel
} // QGCView
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment