summaryrefslogtreecommitdiff
path: root/examples/location
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-03-10 15:59:52 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-03-13 10:31:23 +0000
commitb0480d83282d76c6740ed71323155adbf97de9fa (patch)
tree69a4d6e257b0029431e8806d5f41a6c1aca0fa54 /examples/location
parentdca175454aefdd019952d941c6369c314e8c3b11 (diff)
downloadqtlocation-b0480d83282d76c6740ed71323155adbf97de9fa.tar.gz
Polish MapViewer example
This patch does some improvements to the MapViewer example. Namely: - sliders, which have been problematic in many ways, are now from QtQuickControls 2, and this solves a couple of glitches. - changing map provider now retains tilt, bearing and field of view, if possible. - High DPI scaling is enabled by default in main() - the slider panel is open at start Change-Id: I1cc380e3d05b89aa547139d912c142e4f0d266c9 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/location')
-rw-r--r--examples/location/mapviewer/main.cpp1
-rw-r--r--examples/location/mapviewer/map/MapComponent.qml1
-rw-r--r--examples/location/mapviewer/map/MapSliders.qml42
-rw-r--r--examples/location/mapviewer/mapviewer.qml12
4 files changed, 33 insertions, 23 deletions
diff --git a/examples/location/mapviewer/main.cpp b/examples/location/mapviewer/main.cpp
index 3eedd8dd..c44e3d9e 100644
--- a/examples/location/mapviewer/main.cpp
+++ b/examples/location/mapviewer/main.cpp
@@ -88,6 +88,7 @@ int main(int argc, char *argv[])
for (const QByteArray &p : additionalLibraryPaths.split(':'))
QCoreApplication::addLibraryPath(QString(p));
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication application(argc, argv);
QVariantMap parameters;
diff --git a/examples/location/mapviewer/map/MapComponent.qml b/examples/location/mapviewer/map/MapComponent.qml
index c3d5dfd2..c450a150 100644
--- a/examples/location/mapviewer/map/MapComponent.qml
+++ b/examples/location/mapviewer/map/MapComponent.qml
@@ -61,6 +61,7 @@ Map {
property alias routeQuery: routeQuery
property alias routeModel: routeModel
property alias geocodeModel: geocodeModel
+ property alias slidersExpanded: sliders.expanded
signal showGeocodeInfo()
signal geocodeFinished()
diff --git a/examples/location/mapviewer/map/MapSliders.qml b/examples/location/mapviewer/map/MapSliders.qml
index 75e4f474..8e24481f 100644
--- a/examples/location/mapviewer/map/MapSliders.qml
+++ b/examples/location/mapviewer/map/MapSliders.qml
@@ -41,6 +41,7 @@
import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
+import QtQuick.Controls 2.0 as C2
Row {
id: containerRow
@@ -49,6 +50,7 @@ Row {
property real fontSize : 14
property color labelBackground : "transparent"
property int edge: Qt.RightEdge
+ property alias expanded: sliderToggler.checked
function rightEdge() {
return (containerRow.edge === Qt.RightEdge);
@@ -65,7 +67,7 @@ Row {
width: 32
height: 96
checkable: true
- checked: false
+ checked: true
anchors.verticalCenter: parent.verticalCenter
transform: Scale {
@@ -204,59 +206,53 @@ Row {
// The sliders row
Row {
- spacing: 10
+ spacing: -10
id: sliderRow
height: sliderContainer.slidersHeight
- Slider {
+ C2.Slider {
id: zoomSlider
height: parent.height
orientation : Qt.Vertical
+ from : containerRow.mapSource.minimumZoomLevel
+ to : containerRow.mapSource.maximumZoomLevel
+ value : containerRow.mapSource.zoomLevel
onValueChanged: {
containerRow.mapSource.zoomLevel = value
}
- Component.onCompleted: {
- minimumValue = Qt.binding(function() { return containerRow.mapSource.minimumZoomLevel; })
- maximumValue = Qt.binding(function() { return containerRow.mapSource.maximumZoomLevel; })
- value = Qt.binding(function() { return containerRow.mapSource.zoomLevel; })
- }
}
- Slider {
+ C2.Slider {
id: bearingSlider
height: parent.height
- minimumValue: 0
- maximumValue: 360
+ from: 0
+ to: 360
orientation : Qt.Vertical
value: containerRow.mapSource.bearing
onValueChanged: {
containerRow.mapSource.bearing = value;
}
}
- Slider {
+ C2.Slider {
id: tiltSlider
height: parent.height
orientation : Qt.Vertical
+ from: containerRow.mapSource.minimumTilt;
+ to: containerRow.mapSource.maximumTilt
+ value: containerRow.mapSource.tilt
onValueChanged: {
containerRow.mapSource.tilt = value;
}
- Component.onCompleted: {
- minimumValue = Qt.binding(function() { return containerRow.mapSource.minimumTilt; })
- maximumValue = Qt.binding(function() { return containerRow.mapSource.maximumTilt; })
- value = Qt.binding(function() { return containerRow.mapSource.tilt; })
- }
}
- Slider {
+ C2.Slider {
id: fovSlider
height: parent.height
orientation : Qt.Vertical
+ from: containerRow.mapSource.minimumFieldOfView
+ to: containerRow.mapSource.maximumFieldOfView
+ value: containerRow.mapSource.fieldOfView
onValueChanged: {
containerRow.mapSource.fieldOfView = value;
}
- Component.onCompleted: {
- minimumValue = Qt.binding(function() { return containerRow.mapSource.minimumFieldOfView; })
- maximumValue = Qt.binding(function() { return containerRow.mapSource.maximumFieldOfView; })
- value = Qt.binding(function() { return containerRow.mapSource.fieldOfView; })
- }
}
} // Row sliders
diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml
index 21348919..debc329f 100644
--- a/examples/location/mapviewer/mapviewer.qml
+++ b/examples/location/mapviewer/mapviewer.qml
@@ -73,10 +73,18 @@ ApplicationWindow {
}
var zoomLevel = null
+ var tilt = null
+ var bearing = null
+ var fov = null
var center = null
+ var panelExpanded = null
if (map) {
zoomLevel = map.zoomLevel
+ tilt = map.tilt
+ bearing = map.bearing
+ fov = map.fieldOfView
center = map.center
+ panelExpanded = map.slidersExpanded
map.destroy()
}
@@ -84,8 +92,12 @@ ApplicationWindow {
map.plugin = plugin;
if (zoomLevel != null) {
+ map.tilt = tilt
+ map.bearing = bearing
+ map.fieldOfView = fov
map.zoomLevel = zoomLevel
map.center = center
+ map.slidersExpanded = panelExpanded
} else {
// Use an integer ZL to enable nearest interpolation, if possible.
map.zoomLevel = Math.floor((map.maximumZoomLevel - map.minimumZoomLevel)/2)