summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Rahn <rahn@kde.org>2016-11-13 21:13:47 (GMT)
committerTorsten Rahn <trahn@testo.de>2016-11-13 21:15:00 (GMT)
commit859d12735508336f47e277a26f308ac7e92cec4c (patch)
tree2cf3cd891541685bcbcd5cf6c34cedd756077e52
parent53ee4580a24229d5e4f3728804338304fe946615 (diff)
- Clean up position marker code
- Animate position marker rotation, position and accuracy
-rw-r--r--src/apps/marble-maps/MainScreen.qml26
-rw-r--r--src/apps/marble-maps/PositionMarker.qml49
2 files changed, 52 insertions, 23 deletions
diff --git a/src/apps/marble-maps/MainScreen.qml b/src/apps/marble-maps/MainScreen.qml
index acba10c..aa8d560 100644
--- a/src/apps/marble-maps/MainScreen.qml
+++ b/src/apps/marble-maps/MainScreen.qml
@@ -100,12 +100,17 @@ ApplicationWindow {
updateIndicator();
}
onVisibleLatLonAltBoxChanged: {
+ !panningDetectionTimer.restart();
updateIndicator();
}
onCurrentPositionChanged: {
updateIndicator();
}
+ onZoomChanged: {
+ zoomDetectionTimer.restart()
+ }
+
Component.onCompleted: {
setPluginSetting("coordinate-grid", "gridColor", "#999999");
setPluginSetting("coordinate-grid", "tropicsColor", "#888888");
@@ -130,14 +135,27 @@ ApplicationWindow {
// visible: hasRoute // TODO: make this work
}
+ Timer {
+ id: zoomDetectionTimer
+ interval: 1000
+ }
+ Timer {
+ id: panningDetectionTimer
+ interval: 1000
+ }
+
PositionMarker {
id: positionMarker
- posX: navigationManager.snappedPositionMarkerScreenPosition.x
- posY: navigationManager.snappedPositionMarkerScreenPosition.y
+ x: navigationManager.snappedPositionMarkerScreenPosition.x
+ y: navigationManager.snappedPositionMarkerScreenPosition.y
angle: marbleMaps.angle
- visible: marbleMaps.positionAvailable && marbleMaps.positionVisible
- radius: navigationManager.screenAccuracy
+ visible: marbleMaps.positionAvailable
+ && x + radius > 0 && x - radius < marbleMaps.width
+ && y + radius > 0 && y - radius < marbleMaps.height
+ radius: navigationManager.screenAccuracy / 2
showAccuracy: navigationManager.deviated
+ allowRadiusAnimation: !zoomDetectionTimer.running
+ allowPositionAnimation: !panningDetectionTimer.running
}
MouseArea {
diff --git a/src/apps/marble-maps/PositionMarker.qml b/src/apps/marble-maps/PositionMarker.qml
index bb4196d..896ca7d 100644
--- a/src/apps/marble-maps/PositionMarker.qml
+++ b/src/apps/marble-maps/PositionMarker.qml
@@ -15,24 +15,41 @@ import QtQuick.Window 2.2
Item {
id: root
- property alias angle: rotation.angle
- property int posX: 0
- property int posY: 0
+ property real angle: 0
property bool showAccuracy: true
property real radius: 100
+ property bool allowRadiusAnimation: true
+ property bool allowPositionAnimation: true
- x: posX - width * 0.5
- y: posY - height * 0.5
+ Behavior on radius {
+ enabled: allowRadiusAnimation
+ NumberAnimation { duration: 200 }
+ }
- width: radius
- height: radius
+ Behavior on angle {
+ RotationAnimation {
+ duration: 200
+ direction: RotationAnimation.Shortest
+ }
+ }
+ Behavior on x {
+ enabled: allowPositionAnimation
+ SmoothedAnimation { duration: 200 }
+ }
+ Behavior on y {
+ enabled: allowPositionAnimation
+ SmoothedAnimation { duration: 200 }
+ }
Rectangle {
- anchors.fill: parent
- color: "#40ff0000"
- border.color: "#ff0000"
- border.width: 2
- radius: root.radius
+ width: 2 * root.radius
+ height: 2 * root.radius
+ anchors.centerIn: parent
+ visible: root.showAccuracy
+ color: "#40ff0000"
+ border.color: "#ff0000"
+ border.width: 2
+ radius: root.radius
}
Image {
@@ -44,12 +61,6 @@ Item {
height: width
anchors.centerIn: parent
smooth: true
- transform: Rotation {
- id: rotation
- origin {
- x: image.width * 0.5
- y: image.height * 0.5
- }
- }
+ rotation: root.angle
}
}