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

Small screen re-work

parent eeed8ab7
...@@ -16,25 +16,22 @@ import QtQuick.Layouts 1.2 ...@@ -16,25 +16,22 @@ import QtQuick.Layouts 1.2
import QtLocation 5.5 import QtLocation 5.5
import QtPositioning 5.5 import QtPositioning 5.5
import QGroundControl 1.0 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() {
var isDefaultSet = offlineMapView._currentSelection.defaultSet
_map.visible = true
isMapInteractive = false
savedCenter = _map.toCoordinate(Qt.point(_map.width / 2, _map.height / 2))
savedZoom = _map.zoomLevel
savedMapType = mapType
if(!isDefaultSet) { if(!isDefaultSet) {
isMapInteractive = false mapType = offlineMapView._currentSelection.mapTypeStr
savedCenter = _map.toCoordinate(Qt.point(_map.width / 2, _map.height / 2)) _map.center = midPoint(offlineMapView._currentSelection.topleftLat, offlineMapView._currentSelection.bottomRightLat, offlineMapView._currentSelection.topleftLon, offlineMapView._currentSelection.bottomRightLon)
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 //-- 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,923 +202,719 @@ Rectangle { ...@@ -213,923 +202,719 @@ 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
anchors.top: parent.top
Row { function accept() {
spacing: ScreenTools.defaultFontPixelHeight * 2 QGroundControl.mapEngineManager.mapboxToken = mapBoxToken.text
anchors.verticalCenter: parent.verticalCenter QGroundControl.mapEngineManager.maxDiskCache = parseInt(maxCacheSize.text)
QGCLabel { QGroundControl.mapEngineManager.maxMemCache = parseInt(maxCacheMemSize.text)
id: labelTitle optionDialog.hideDialog()
text: qsTr("Offline Maps")
font.pointSize: ScreenTools.mediumFontPointSize
anchors.verticalCenter: parent.verticalCenter
}
QGCCheckBox {
id: showTilePreview
text: qsTr("Show tile min/max zoom level preview")
checked: false
visible: _mapView.visible && !ScreenTools.isTinyScreen
anchors.verticalCenter: parent.verticalCenter
} }
}
}
Map { QGCFlickable {
id: _map anchors.fill: parent
anchors.top: _offlineMapTopRect.bottom contentHeight: optionsColumn.height
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: mapMargin
width: parent.width - ScreenTools.defaultFontPixelWidth
center: QGroundControl.defaultMapPosition
visible: false
gesture.flickDeceleration: 3000
plugin: Plugin { name: "QGroundControl" }
Rectangle {
color: Qt.rgba(0,0,0,0)
border.color: "black"
border.width: 1
anchors.fill: parent
}
MapRectangle { Column {
id: mapBoundary id: optionsColumn
border.width: 2 anchors.margins: ScreenTools.defaultFontPixelWidth
border.color: "red" anchors.left: parent.left
color: Qt.rgba(1,0,0,0.05) anchors.right: parent.right
smooth: true anchors.top: parent.top
antialiasing: true spacing: ScreenTools.defaultFontPixelHeight / 2
}
Component.onCompleted: { QGCLabel { text: qsTr("Max Cache Disk Size (MB):") }
center = QGroundControl.flightMapPosition
zoomLevel = QGroundControl.flightMapZoom
}
onCenterChanged: { QGCTextField {
handleChanges() id: maxCacheSize
checkSanity() maximumLength: 6
} inputMethodHints: Qt.ImhDigitsOnly
onZoomLevelChanged: { validator: IntValidator {bottom: 1; top: 262144;}
handleChanges() text: QGroundControl.mapEngineManager.maxDiskCache
checkSanity() }
}
onWidthChanged: {
handleChanges()
checkSanity()
}
onHeightChanged: {
handleChanges()
checkSanity()
}
// Used to make pinch zoom work
MouseArea {
anchors.fill: parent
}
}
QGCFlickable { Item { width: 1; height: 1 }
id: _tileSetList
clip: true QGCLabel { text: qsTr("Max Cache Memory Size (MB):") }
anchors.top: _offlineMapTopRect.bottom
anchors.left: parent.left QGCTextField {
anchors.right: parent.right id: maxCacheMemSize
anchors.bottom: _optionsButton.top maximumLength: 4
contentHeight: _cacheList.height inputMethodHints: Qt.ImhDigitsOnly
flickableDirection: Flickable.VerticalFlick validator: IntValidator {bottom: 1; top: 4096;}
text: QGroundControl.mapEngineManager.maxMemCache
Column {
id: _cacheList
width: Math.min(parent.width, (ScreenTools.defaultFontPixelWidth * 50).toFixed(0))
anchors.margins: ScreenTools.defaultFontPixelWidth
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
OfflineMapButton {
text: qsTr("Add new set")
anchors.left: parent.left
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight * 2
onClicked: {
_offlineMapRoot._currentSelection = null
showMap()
}
}
Repeater {
model: QGroundControl.mapEngineManager.tileSets
delegate: OfflineMapButton {
text: object.name
size: object.downloadStatus
complete: object.complete
anchors.left: parent.left
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight * 2
onClicked: {
_offlineMapRoot._currentSelection = object
showInfo()
} }
}
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 {
text: qsTr("With an access token, you can use MapBox Maps.")
font.pointSize: _adjustableFontPointSize
}
} // 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()
} }
} }
} }
QGCButton { Component {
id: _optionsButton id: deleteSystemSetConfirmationDialogComponent
text: qsTr("Options")
visible: _tileSetList.visible
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelWidth
onClicked: showOptions()
}
//-- Offline Map Definition QGCViewMessage {
Item { id: deleteSystemSetConfirmationDialog
id: _mapView message: qsTr("This will delete all tiles INCLUDING the tile sets you have created yourself.\n\nIs this really what you want?")
width: parent.width
anchors.top: _offlineMapTopRect.bottom function accept() {
anchors.bottom: parent.bottom QGroundControl.mapEngineManager.deleteTileSet(offlineMapView._currentSelection)
anchors.margins: ScreenTools.defaultFontPixelWidth deleteSystemSetConfirmationDialog.hideDialog()
visible: false leaveInfoView()
showList()
//-- 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.margins: ScreenTools.defaultFontPixelHeight
color: "black"
Map {
id: _mapMin
anchors.fill: parent
anchors.margins: 2
zoomLevel: _slider0.value
center: _map.center
gesture.enabled: false
activeMapType: _map.activeMapType
plugin: Plugin { name: "QGroundControl" }
}
}
Rectangle {
width: ScreenTools.defaultFontPixelHeight * 16
height: ScreenTools.defaultFontPixelHeight * 9
anchors.top: parent.top
anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelHeight
color: "black"
Map {
id: _mapMax
anchors.fill: parent
anchors.margins: 2
zoomLevel: _slider1.value
center: _map.center
gesture.enabled: false
activeMapType: _map.activeMapType
plugin: Plugin { name: "QGroundControl" }
}
} }
} }
//-- Tile set settings }
Rectangle {
id: bottomRect QGCViewPanel {
width: _controlRow.width + (ScreenTools.defaultFontPixelWidth * 2) id: panel
height: _controlRow.height + (ScreenTools.defaultFontPixelHeight * 2) anchors.fill: parent
color: qgcPal.window
radius: ScreenTools.defaultFontPixelWidth * 0.5 Map {
anchors.horizontalCenter: parent.horizontalCenter id: _map
anchors.fill: parent
center: QGroundControl.defaultMapPosition
visible: false
gesture.flickDeceleration: 3000
plugin: Plugin { name: "QGroundControl" }
MapRectangle {
id: mapBoundary
border.width: 2
border.color: "red"
color: Qt.rgba(1,0,0,0.05)
smooth: true
antialiasing: true
}
Component.onCompleted: { Component.onCompleted: {
color = Qt.rgba(color.r, color.g, color.b, 0.85) center = QGroundControl.flightMapPosition
zoomLevel = QGroundControl.flightMapZoom
} }
anchors.bottom: parent.bottom
Row { onCenterChanged: {
id: _controlRow handleChanges()
anchors.centerIn: parent checkSanity()
spacing: ScreenTools.defaultFontPixelWidth * 0.5 }
Rectangle { onZoomLevelChanged: {
height: _zoomRow.height + ScreenTools.defaultFontPixelHeight * 1.5 handleChanges()
width: _zoomRow.width + ScreenTools.defaultFontPixelWidth checkSanity()
color: "#98aca4" }
border.color: "black" onWidthChanged: {
border.width: 2 handleChanges()
radius: ScreenTools.defaultFontPixelWidth * 0.5 checkSanity()
anchors.verticalCenter: parent.verticalCenter }
Row { onHeightChanged: {
id: _zoomRow handleChanges()
anchors.centerIn: parent checkSanity()
Column {
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.verticalCenter: parent.verticalCenter
Row {
spacing: ScreenTools.defaultFontPixelWidth * 0.5
Column {
anchors.verticalCenter: parent.verticalCenter
Label {
text: qsTr("Min")
color: "black"
width: ScreenTools.defaultFontPixelWidth * 4
font.pointSize: ScreenTools.smallFontPointSize
horizontalAlignment: Text.AlignHCenter
font.family: ScreenTools.normalFontFamily
}
Label {
text: qsTr("Zoom")
color: "black"
width: ScreenTools.defaultFontPixelWidth * 4
font.family: ScreenTools.normalFontFamily
font.pointSize: ScreenTools.smallFontPointSize
horizontalAlignment: Text.AlignHCenter
}
}
Slider {
id: _slider0
minimumValue: minZoomLevel
maximumValue: maxZoomLevel
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
}
}
}
Component.onCompleted: {
_slider0.value = _map.zoomLevel - 2
}
onValueChanged: {
if(_slider1) {
if(_slider0.value > _slider1.value)
_slider1.value = _slider0.value
else {
handleChanges()
checkSanity()
}
}
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth * 0.5
Column {
anchors.verticalCenter: parent.verticalCenter
Label {
text: qsTr("Max")
color: "black"
width: ScreenTools.defaultFontPixelWidth * 4
font.pointSize: ScreenTools.smallFontPointSize
font.family: ScreenTools.normalFontFamily
horizontalAlignment: Text.AlignHCenter
}
Label {
text: qsTr("Zoom")
color: "black"
width: ScreenTools.defaultFontPixelWidth * 4
font.pointSize: ScreenTools.smallFontPointSize
font.family: ScreenTools.normalFontFamily
horizontalAlignment: Text.AlignHCenter
}
}
Slider {
id: _slider1
minimumValue: minZoomLevel
maximumValue: maxZoomLevel
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: _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()
}
}
}
}
}
Column {
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.verticalCenter: parent.verticalCenter
Label {
text: qsTr("Tile Count")
color: "black"
width: ScreenTools.defaultFontPixelWidth * 12
font.pointSize: ScreenTools.smallFontPointSize
font.family: ScreenTools.normalFontFamily
horizontalAlignment: Text.AlignHCenter
}
Label {
text: QGroundControl.mapEngineManager.tileCountStr
color: "black"
width: ScreenTools.defaultFontPixelWidth * 12
font.family: ScreenTools.normalFontFamily
font.pointSize: ScreenTools.defaultFontPointSize
horizontalAlignment: Text.AlignHCenter
}
Label {
text: qsTr("Set Size (Est)")
color: "black"
width: ScreenTools.defaultFontPixelWidth * 12
font.pointSize: ScreenTools.smallFontPointSize
font.family: ScreenTools.normalFontFamily
horizontalAlignment: Text.AlignHCenter
}
Label {
text: QGroundControl.mapEngineManager.tileSizeStr
color: "black"
width: ScreenTools.defaultFontPixelWidth * 12
font.family: ScreenTools.normalFontFamily
font.pointSize: ScreenTools.defaultFontPointSize
horizontalAlignment: Text.AlignHCenter
}
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
spacing: ScreenTools.defaultFontPixelHeight * 0.5
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Name:")
width: _newSetMiddleLabel
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignRight
}
QGCTextField {
id: setName
width: _newSetMiddleField
anchors.verticalCenter: parent.verticalCenter
}
}
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
QGCLabel {
text: qsTr("Map Type:")
width: _newSetMiddleLabel
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignRight
}
QGCComboBox {
id: mapCombo
width: _newSetMiddleField
model: QGroundControl.mapEngineManager.mapList
onActivated: {
mapType = textAt(index)
if(_dropButtonsExclusiveGroup.current)
_dropButtonsExclusiveGroup.current.checked = false
_dropButtonsExclusiveGroup.current = null
}
Component.onCompleted: {
var index = mapCombo.find(mapType)
if (index === -1) {
console.warn(qsTr("Active map name not in combo"), mapType)
} else {
mapCombo.currentIndex = index
}
}
}
}
}
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 MapScale {
Item { anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
id: _infoView anchors.bottomMargin: anchors.leftMargin
width: parent.width anchors.left: parent.left
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.margins: ScreenTools.defaultFontPixelWidth mapControl: _map
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 { //-- Show Set Info
id: _controlInfoRow Rectangle {
anchors.centerIn: parent id: infoView
spacing: ScreenTools.defaultFontPixelWidth * 4 anchors.margins: ScreenTools.defaultFontPixelWidth
y: Math.max(anchors.margins, (parent.height - (anchors.margins * 2) - height) / 2)
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
readonly property real _margins: ScreenTools.defaultFontPixelHeight / 2
QGCLabel {
anchors.margins: ScreenTools.defaultFontPixelHeight / 4
anchors.top: parent.top
anchors.right: parent.right
text: "X"
}
Column { Column {
anchors.rightMargin: ScreenTools.defaultFontPixelWidth id: titleColumn
anchors.leftMargin: ScreenTools.defaultFontPixelWidth anchors.margins: infoView._margins
anchors.verticalCenter: parent.verticalCenter anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelHeight * 0.5 anchors.left: parent.left
anchors.right: parent.right
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.name : "" anchors.left: parent.left
font.pointSize: ScreenTools.isAndroid ? ScreenTools.mediumFontPointSize : ScreenTools.largeFontPointSize anchors.right: parent.right
anchors.horizontalCenter: parent.horizontalCenter wrapMode: Text.WordWrap
text: offlineMapView._currentSelection ? offlineMapView._currentSelection.name : ""
font.pointSize: _saveRealEstate ? ScreenTools.defaultFontPointSize : ScreenTools.mediumFontPointSize
horizontalAlignment: Text.AlignHCenter
} }
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.description : "" anchors.left: parent.left
visible: text !== qsTr("Description") anchors.right: parent.right
anchors.horizontalCenter: parent.horizontalCenter wrapMode: Text.WordWrap
text: offlineMapView._currentSelection ? offlineMapView._currentSelection.description : ""
visible: text !== qsTr("Description")
horizontalAlignment: Text.AlignHCenter
} }
QGCLabel { QGCLabel {
text: _offlineMapRoot._currentSelection ? "(" + _offlineMapRoot._currentSelection.mapTypeStr + ")" : "" anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: offlineMapView._currentSelection ? "(" + offlineMapView._currentSelection.mapTypeStr + ")" : ""
horizontalAlignment: Text.AlignHCenter
} }
} }
GridLayout {
columns: 2 MouseArea {
anchors.margins: ScreenTools.defaultFontPixelWidth anchors.fill: titleColumn
rowSpacing: ScreenTools.defaultFontPixelWidth preventStealing: true
columnSpacing: ScreenTools.defaultFontPixelHeight
QGCLabel { onClicked: {
text: qsTr("Min Zoom:") leaveInfoView()
} showList()
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 QGCFlickable {
spacing: ScreenTools.defaultFontPixelHeight * 0.5 id: controlInfoFlickable
QGCButton { anchors.margins: infoView._margins
width: ScreenTools.defaultFontPixelWidth * 18 anchors.top: titleColumn.bottom
text: qsTr("Delete") anchors.bottom: parent.bottom
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting) anchors.left: parent.left
onClicked: { width: controlInfoColumn.width
if(_offlineMapRoot._currentSelection) clip: true
deleteDialog.visible = true contentHeight: controlInfoColumn.height
}
MessageDialog { Column {
id: deleteDialog id: controlInfoColumn
visible: false spacing: ScreenTools.defaultFontPixelHeight
icon: StandardIcon.Warning
standardButtons: StandardButton.Yes | StandardButton.No GridLayout {
title: qsTr("Delete Tile Set") columns: 2
text: { rowSpacing: 0
if(_offlineMapRoot._currentSelection) {
var blurb = qsTr("Delete %1 and all its tiles.\nIs this really what you want?").arg(_offlineMapRoot._currentSelection.name) QGCLabel { text: qsTr("Min Zoom:") }
return blurb QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.minZoom : "" }
}
return "" QGCLabel { text: qsTr("Max Zoom:") }
QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.maxZoom : "" }
QGCLabel { text: qsTr("Total:") }
QGCLabel { text: (offlineMapView._currentSelection ? offlineMapView._currentSelection.numTilesStr : "") + " (" + (offlineMapView._currentSelection ? offlineMapView._currentSelection.tilesSizeStr : "") + ")" }
QGCLabel {
text: qsTr("Downloaded:")
visible: offlineMapView._currentSelection && !offlineMapView._currentSelection.complete
} }
onYes: { QGCLabel {
leaveInfoView() text: (offlineMapView._currentSelection ? offlineMapView._currentSelection.savedTilesStr : "") + " (" + (offlineMapView._currentSelection ? offlineMapView._currentSelection.savedSizeStr : "") + ")"
if(_offlineMapRoot._currentSelection) visible: offlineMapView._currentSelection && !offlineMapView._currentSelection.complete
QGroundControl.mapEngineManager.deleteTileSet(_offlineMapRoot._currentSelection)
deleteDialog.visible = false
showList()
} }
onNo: {
deleteDialog.visible = false QGCLabel {
text: qsTr("Error Count:")
visible: offlineMapView._currentSelection && !offlineMapView._currentSelection.complete
}
QGCLabel {
text: offlineMapView._currentSelection ? offlineMapView._currentSelection.errorCountStr : ""
visible: offlineMapView._currentSelection && !offlineMapView._currentSelection.complete
} }
} }
}
QGCButton { QGCButton {
text: qsTr("Resume Download") text: qsTr("Resume Download")
width: ScreenTools.defaultFontPixelWidth * 18 visible: offlineMapView._currentSelection && (!offlineMapView._currentSelection.complete && !offlineMapView._currentSelection.downloading)
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting && !_offlineMapRoot._currentSelection.downloading)
visible: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.complete && !_offlineMapRoot._currentSelection.downloading) onClicked: {
onClicked: { if(offlineMapView._currentSelection)
if(_offlineMapRoot._currentSelection) offlineMapView._currentSelection.resumeDownloadTask()
_offlineMapRoot._currentSelection.resumeDownloadTask() }
} }
}
QGCButton { QGCButton {
text: qsTr("Cancel Download") text: qsTr("Cancel Download")
width: ScreenTools.defaultFontPixelWidth * 18 visible: offlineMapView._currentSelection && (!offlineMapView._currentSelection.complete && offlineMapView._currentSelection.downloading)
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting && _offlineMapRoot._currentSelection.downloading)
visible: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.complete && _offlineMapRoot._currentSelection.downloading) onClicked: {
onClicked: { if(offlineMapView._currentSelection)
if(_offlineMapRoot._currentSelection) offlineMapView._currentSelection.cancelDownloadTask()
_offlineMapRoot._currentSelection.cancelDownloadTask() }
} }
}
QGCButton { QGCButton {
text: qsTr("Back") text: qsTr("Delete")
width: ScreenTools.defaultFontPixelWidth * 18 onClicked: showDialog(deleteConfirmationDialogComponent, qsTr("Confirm Delete"), qgcView.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
onClicked: {
leaveInfoView()
showList()
} }
} } // Column
} } // QGCFlickable
} } // Rectangle - infoView
}
}
//-- Show info on default tile set //-- Show Default Set Info
Rectangle { Rectangle {
id: _defaultInfoView id: defaultInfoView
color: qgcPal.windowShade anchors.margins: ScreenTools.defaultFontPixelWidth
width: parent.width y: Math.max(anchors.margins, (parent.height - (anchors.margins * 2) - height) / 2)
anchors.top: _offlineMapTopRect.bottom anchors.right: parent.right
anchors.bottom: parent.bottom width: ScreenTools.defaultFontPixelWidth * 20
anchors.margins: ScreenTools.defaultFontPixelWidth height: Math.min(parent.height - (anchors.margins * 2), defaultControlInfoFlickable.y + defaultControlInfoColumn.height + ScreenTools.defaultFontPixelHeight)
visible: false color: qgcPal.window
QGCFlickable { opacity: 0.85
id: infoScroll radius: ScreenTools.defaultFontPixelWidth * 0.5
anchors.fill: parent visible: false
contentHeight: infoColumn.height
flickableDirection: Flickable.VerticalFlick QGCLabel {
clip: true anchors.margins: ScreenTools.defaultFontPixelHeight / 4
Column { anchors.top: parent.top
id: infoColumn anchors.right: parent.right
width: parent.width text: "X"
spacing: ScreenTools.defaultFontPixelHeight
Item {
height: ScreenTools.defaultFontPixelHeight * 0.5
width: 1
} }
Rectangle {
id: _infoNameRect Column {
width: infoWidth id: defaultTitleColumn
height: infoCol.height + (ScreenTools.defaultFontPixelHeight * 2) anchors.margins: ScreenTools.defaultFontPixelHeight / 2
color: qgcPal.window anchors.top: parent.top
radius: ScreenTools.defaultFontPixelHeight * 0.5 anchors.left: parent.left
anchors.horizontalCenter: parent.horizontalCenter anchors.right: parent.right
Column {
id: infoCol QGCLabel {
spacing: ScreenTools.defaultFontPixelHeight anchors.left: parent.left
anchors.centerIn: parent anchors.right: parent.right
QGCLabel { wrapMode: Text.WordWrap
id: nameLabel text: offlineMapView._currentSelection ? offlineMapView._currentSelection.name : ""
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.name : "" font.pointSize: _saveRealEstate ? ScreenTools.defaultFontPointSize : ScreenTools.mediumFontPointSize
font.pointSize: ScreenTools.isAndroid ? ScreenTools.mediumFontPointSize : ScreenTools.largeFontPointSize horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter }
}
QGCLabel { QGCLabel {
id: descLabel anchors.left: parent.left
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.description : "" anchors.right: parent.right
anchors.horizontalCenter: parent.horizontalCenter wrapMode: Text.WordWrap
} text: qsTr("System Wide Tile Cache")
horizontalAlignment: Text.AlignHCenter
} }
} }
Rectangle {
id: _infoRect MouseArea {
width: infoWidth anchors.fill: defaultTitleColumn
height: infoGrid.height + (ScreenTools.defaultFontPixelHeight * 4) preventStealing: true
color: qgcPal.window
radius: ScreenTools.defaultFontPixelHeight * 0.5 onClicked: {
anchors.horizontalCenter: parent.horizontalCenter leaveInfoView()
GridLayout { showList()
id: infoGrid
columns: 2
anchors.centerIn: parent
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 {
text: qsTr("Total Size (All Sets):")
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedSizeStr : ""
}
QGCLabel {
text: qsTr("Total Count (All Sets):")
}
QGCLabel {
text: _offlineMapRoot._currentSelection ? _offlineMapRoot._currentSelection.savedTilesStr : ""
}
} }
} }
Row {
anchors.horizontalCenter: parent.horizontalCenter QGCFlickable {
spacing: ScreenTools.defaultFontPixelWidth id: defaultControlInfoFlickable
QGCButton { anchors.margins: ScreenTools.defaultFontPixelHeight
width: ScreenTools.defaultFontPixelWidth * 18 anchors.top: defaultTitleColumn.bottom
text: qsTr("Delete") anchors.left: parent.left
enabled: _offlineMapRoot._currentSelection && (!_offlineMapRoot._currentSelection.deleting) anchors.right: parent.right
onClicked: { anchors.bottom: parent.bottom
if(_offlineMapRoot._currentSelection) clip: true
deleteDefaultDialog.visible = true contentHeight: defaultControlInfoColumn.height
}
MessageDialog { Column {
id: deleteDefaultDialog id: defaultControlInfoColumn
visible: false anchors.left: parent.left
icon: StandardIcon.Warning anchors.right: parent.right
standardButtons: StandardButton.Yes | StandardButton.No spacing: ScreenTools.defaultFontPixelHeight
title: qsTr("Delete All Tiles")
text: qsTr("Delete all cached tiles.\nIs this really what you want?") GridLayout {
onYes: { columns: 2
if(_offlineMapRoot._currentSelection) rowSpacing: 0
QGroundControl.mapEngineManager.deleteTileSet(_offlineMapRoot._currentSelection)
deleteDefaultDialog.visible = false QGCLabel {
showList() Layout.columnSpan: 2
text: qsTr("System Cache")
} }
onNo: {
deleteDefaultDialog.visible = false 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")
}
QGCLabel { text: qsTr("Size:") }
QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.savedSizeStr : "" }
QGCLabel { text: qsTr("Tile Count:") }
QGCLabel { text: offlineMapView._currentSelection ? offlineMapView._currentSelection.savedTilesStr : ""}
} }
}
QGCButton { QGCButton {
text: qsTr("Back") text: qsTr("Delete All")
width: ScreenTools.defaultFontPixelWidth * 18 onClicked: showDialog(deleteSystemSetConfirmationDialogComponent, qsTr("Confirm Delete All"), qgcView.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
onClicked: {
showList()
} }
} } // Column
} // QGCFlickable
} // Rectangle - defaultInfoView
//-- Add New Set View
Rectangle {
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"
} }
}
}
}
Rectangle { QGCLabel {
id: _optionsView id: addNewSetLabel
color: qgcPal.windowShade anchors.margins: ScreenTools.defaultFontPixelHeight / 2
width: parent.width anchors.top: parent.top
anchors.top: _offlineMapTopRect.bottom anchors.left: parent.left
anchors.bottom: parent.bottom anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelWidth wrapMode: Text.WordWrap
visible: false text: qsTr("Add New Set")
onVisibleChanged: { font.pointSize: _saveRealEstate ? ScreenTools.defaultFontPointSize : ScreenTools.mediumFontPointSize
if(_optionsView.visible) { horizontalAlignment: Text.AlignHCenter
mapBoxToken.text = QGroundControl.mapEngineManager.mapboxToken
maxCacheSize.text = QGroundControl.mapEngineManager.maxDiskCache
maxCacheMemSize.text = QGroundControl.mapEngineManager.maxMemCache
}
}
QGCFlickable {
id: optionsScroll
anchors.fill: parent
contentHeight: optionsColumn.height
flickableDirection: Flickable.VerticalFlick
clip: true
Column {
id: optionsColumn
width: parent.width
spacing: ScreenTools.defaultFontPixelHeight
Item {
height: ScreenTools.defaultFontPixelHeight
width: 1
} }
Rectangle {
width: infoWidth MouseArea {
height: optionsLabel.height + (ScreenTools.defaultFontPixelHeight * 2) anchors.fill: addNewSetLabel
color: qgcPal.window preventStealing: true
radius: ScreenTools.defaultFontPixelHeight * 0.5 onClicked: showList()
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
id: optionsLabel
text: qsTr("Offline Map Options")
font.pointSize: ScreenTools.largeFontPointSize
anchors.centerIn: parent
}
} }
Rectangle {
id: optionsRect QGCFlickable {
width: optionsGrid.width + (ScreenTools.defaultFontPixelWidth * 4) id: addNewSetFlickable
height: optionsGrid.height + (ScreenTools.defaultFontPixelHeight * 4) anchors.leftMargin: ScreenTools.defaultFontPixelWidth
color: qgcPal.window anchors.rightMargin: anchors.leftMargin
radius: ScreenTools.defaultFontPixelHeight * 0.5 anchors.topMargin: ScreenTools.defaultFontPixelWidth / 3
anchors.horizontalCenter: parent.horizontalCenter anchors.bottomMargin: anchors.topMargin
GridLayout { anchors.top: addNewSetLabel.bottom
id: optionsGrid anchors.left: parent.left
columns: 2 anchors.right: parent.right
anchors.centerIn: parent anchors.bottom: parent.bottom
anchors.margins: ScreenTools.defaultFontPixelWidth * 2 clip: true
rowSpacing: ScreenTools.defaultFontPixelWidth * 1.5 contentHeight: addNewSetColumn.height
columnSpacing: ScreenTools.defaultFontPixelHeight * 2
QGCLabel { Column {
text: qsTr("Max Cache Disk Size (MB):") id: addNewSetColumn
} anchors.left: parent.left
QGCTextField { anchors.right: parent.right
id: maxCacheSize spacing: ScreenTools.defaultFontPixelHeight / (ScreenTools.isTinyScreen ? 4 : 2)
maximumLength: 6
inputMethodHints: Qt.ImhDigitsOnly Column {
validator: IntValidator {bottom: 1; top: 262144;} anchors.left: parent.left
} anchors.right: parent.right
QGCLabel {
text: qsTr("Max Cache Memory Size (MB):") QGCLabel { text: qsTr("Name:") }
}
QGCTextField { QGCTextField {
id: maxCacheMemSize id: setName
maximumLength: 4 anchors.left: parent.left
inputMethodHints: Qt.ImhDigitsOnly anchors.right: parent.right
validator: IntValidator {bottom: 1; top: 4096;} }
} }
Item {
Layout.columnSpan: 2 Column {
Layout.fillWidth: true anchors.left: parent.left
height: ScreenTools.defaultFontPixelHeight * 1.5 anchors.right: parent.right
QGCLabel { QGCLabel {
anchors.centerIn: parent text: qsTr("Map type:")
text: qsTr("Memory cache changes require a restart to take effect.") visible: !_saveRealEstate
font.pointSize: ScreenTools.smallFontPointSize }
QGCComboBox {
id: mapCombo
anchors.left: parent.left
anchors.right: parent.right
model: QGroundControl.mapEngineManager.mapList
onActivated: {
mapType = textAt(index)
if(_dropButtonsExclusiveGroup.current)
_dropButtonsExclusiveGroup.current.checked = false
_dropButtonsExclusiveGroup.current = null
}
Component.onCompleted: {
var index = mapCombo.find(mapType)
if (index === -1) {
console.warn(qsTr("Active map name not in combo"), mapType)
} else {
mapCombo.currentIndex = index
}
}
} }
} }
Rectangle { Rectangle {
Layout.columnSpan: 2 anchors.left: parent.left
Layout.fillWidth: true anchors.right: parent.right
height: 1 height: zoomColumn.height + ScreenTools.defaultFontPixelHeight / 2
color: qgcPal.text color: qgcPal.window
} border.color: qgcPal.text
QGCLabel { radius: ScreenTools.defaultFontPixelWidth * 0.5
text: qsTr("MapBox Access Token")
} Column {
QGCTextField { id: zoomColumn
id: mapBoxToken anchors.margins: ScreenTools.defaultFontPixelHeight / 4
maximumLength: 256 anchors.top: parent.top
width: ScreenTools.defaultFontPixelWidth * 30 anchors.left: parent.left
} anchors.right: parent.right
Item {
Layout.columnSpan: 2 QGCLabel {
Layout.fillWidth: true text: qsTr("Min Zoom:")
height: ScreenTools.defaultFontPixelHeight * 1.5 font.pointSize: _adjustableFontPointSize
QGCLabel { }
anchors.centerIn: parent
text: qsTr("With an access token, you can use MapBox Maps.") Slider {
font.pointSize: ScreenTools.smallFontPointSize id: sliderMinZoom
anchors.left: parent.left
anchors.right: parent.right
height: setName.height
minimumValue: minZoomLevel
maximumValue: maxZoomLevel
stepSize: 1
updateValueWhileDragging: true
property real _savedZoom
Component.onCompleted: sliderMinZoom.value = _map.zoomLevel - 2
onValueChanged: {
if(sliderMinZoom.value > sliderMaxZoom.value) {
sliderMaxZoom.value = sliderMinZoom.value
}
handleChanges()
checkSanity()
_map.zoomLevel = sliderMinZoom.value
}
onPressedChanged: {
if (pressed) {
_savedZoom = _map.zoomLevel
_map.zoomLevel = sliderMinZoom.value
} else {
_map.zoomLevel = _savedZoom
}
}
} // Slider - min zoom
QGCLabel {
text: qsTr("Max Zoom:")
font.pointSize: _adjustableFontPointSize
}
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
}
onValueChanged: {
if(sliderMaxZoom.value < sliderMinZoom.value) {
sliderMinZoom.value = sliderMaxZoom.value
}
handleChanges()
checkSanity()
if (pressed) {
_map.zoomLevel = sliderMaxZoom.value
}
}
onPressedChanged: {
if (pressed) {
_savedZoom = _map.zoomLevel
_map.zoomLevel = sliderMaxZoom.value
} else {
_map.zoomLevel = _savedZoom
}
}
} // Slider - max zoom
GridLayout {
columns: 2
rowSpacing: 0
QGCLabel {
text: qsTr("Tile Count")
font.pointSize: _adjustableFontPointSize
}
QGCLabel {
text: QGroundControl.mapEngineManager.tileCountStr
font.pointSize: _adjustableFontPointSize
}
QGCLabel {
text: qsTr("Set Size (Est)")
font.pointSize: _adjustableFontPointSize
}
QGCLabel {
text: QGroundControl.mapEngineManager.tileSizeStr
font.pointSize: _adjustableFontPointSize
}
}
} // Column - Zoom info
} // Rectangle - Zoom info
QGCButton {
text: qsTr("Download")
enabled: setName.text.length > 0
anchors.horizontalCenter: parent.horizontalCenter
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()
}
} }
} }
} // Column
} // QGCFlickable
} // Rectangle - addNewSetView
} // Map
QGCFlickable {
id: _tileSetList
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 {
id: _cacheList
width: Math.min(_tileSetList.width, (ScreenTools.defaultFontPixelWidth * 50).toFixed(0))
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
OfflineMapButton {
id: firstButton
text: qsTr("Add new set")
width: _cacheList.width
height: ScreenTools.defaultFontPixelHeight * 2
onClicked: {
offlineMapView._currentSelection = null
addNewSet()
} }
} }
Row { Repeater {
anchors.horizontalCenter: parent.horizontalCenter model: QGroundControl.mapEngineManager.tileSets
spacing: ScreenTools.defaultFontPixelWidth delegate: OfflineMapButton {
QGCButton { text: object.name
text: qsTr("Save") size: object.downloadStatus
width: ScreenTools.defaultFontPixelWidth * 18 complete: object.complete
onClicked: { width: firstButton.width
QGroundControl.mapEngineManager.mapboxToken = mapBoxToken.text height: ScreenTools.defaultFontPixelHeight * 2
QGroundControl.mapEngineManager.maxDiskCache = parseInt(maxCacheSize.text) onClicked: {
QGroundControl.mapEngineManager.maxMemCache = parseInt(maxCacheMemSize.text) offlineMapView._currentSelection = object
showList() showInfo()
}
}
QGCButton {
text: qsTr("Cancel")
width: ScreenTools.defaultFontPixelWidth * 18
onClicked: {
showList()
} }
} }
} }
} }
} }
}
} 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