Skip to content

Commit

Permalink
Fix problem with map rotation on Android devices
Browse files Browse the repository at this point in the history
  • Loading branch information
kebekus committed Jan 19, 2024
1 parent 03348dd commit 8389d8c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ option(BUILD_DOC "Build developer documentation" OFF)
# Project data
#

project(enroute VERSION 2.30.00)
project(enroute VERSION 2.30.01)
set(APP_ID de.akaflieg_freiburg.enroute)
set(DISPLAY_NAME "Enroute")
math(EXPR PROJECT_VERSION_CODE 10000*${PROJECT_VERSION_MAJOR}+100*${PROJECT_VERSION_MINOR}+${PROJECT_VERSION_PATCH})
Expand Down
60 changes: 40 additions & 20 deletions src/qml/items/MFM.qml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,25 @@ Item {

property geoCoordinate startCentroid
property real rawBearing: 0
property real startBearing: 0
property bool aboveRotationThreshold: false
property real startZoomLevel

onActiveChanged: if (active) {
flightMap.followGPS = false
startCentroid = flightMap.toCoordinate(pinch.centroid.position, false)
startZoomLevel = flightMap.zoomLevel
}
onActiveChanged: {
if (active) {
flightMap.followGPS = false
startCentroid = flightMap.toCoordinate(pinch.centroid.position, false)
startZoomLevel = flightMap.zoomLevel
rawBearing = flightMap.bearing
startBearing = flightMap.bearing
return
}

if (flightMap.bearing === 0.0)
{
GlobalSettings.mapBearingPolicy = GlobalSettings.NUp
}
}

onScaleChanged: (delta) => {
var newZoom = startZoomLevel+Math.log2(activeScale)
Expand All @@ -88,18 +100,27 @@ Item {
}
zoomLevelBehavior.enabled = false
flightMap.zoomLevel = newZoom
flightMap.alignCoordinateToPoint(startCentroid, pinch.centroid.position)
flightMap.alignCoordinateToPoint(pinch.startCentroid, pinch.centroid.position)
zoomLevelBehavior.enabled = true
}

onRotationChanged: (delta) => {
pinch.rawBearing -= delta
// snap to 0° if we're close enough

bearingBehavior.enabled = false
flightMap.bearing = (Math.abs(pinch.rawBearing) < 5) ? 0 : pinch.rawBearing
flightMap.alignCoordinateToPoint(pinch.startCentroid, pinch.centroid.position)
bearingBehavior.enabled = true
if (GlobalSettings.mapBearingPolicy === GlobalSettings.UserDefinedBearingUp)
{
// snap to 0° if we're close enough
bearingBehavior.enabled = false
flightMap.bearing = (Math.abs(pinch.rawBearing) < 5) ? 0 : pinch.rawBearing
flightMap.alignCoordinateToPoint(pinch.startCentroid, pinch.centroid.position)
bearingBehavior.enabled = true
return
}

if (Math.abs(pinch.rawBearing-pinch.startBearing) > 5)
{
GlobalSettings.mapBearingPolicy = GlobalSettings.UserDefinedBearingUp
}
}
}

Expand Down Expand Up @@ -166,7 +187,6 @@ Item {

// If "followGPS" is true, then update the map bearing whenever a new GPS position comes in
Binding on bearing {
restoreMode: Binding.RestoreBinding
when: GlobalSettings.mapBearingPolicy !== GlobalSettings.UserDefinedBearingUp
value: GlobalSettings.mapBearingPolicy === GlobalSettings.TTUp ? PositionProvider.lastValidTT.toDEG() : 0
}
Expand Down Expand Up @@ -492,13 +512,13 @@ Item {
}

sourceItem: Image {
id: image
id: image

source: "/icons/waypoints/ic_warning.svg"
opacity: 0.75
sourceSize.width: 20
sourceSize.height: 20
}
source: "/icons/waypoints/ic_warning.svg"
opacity: 0.75
sourceSize.width: 20
sourceSize.height: 20
}
}

}
Expand Down Expand Up @@ -790,8 +810,8 @@ Item {
onLinkActivated: {
Global.dialogLoader.active = false
Global.dialogLoader.setSource("../dialogs/LongTextDialog.qml", {title: qsTr("Map Data Copyright Information"),
text: GeoMapProvider.copyrightNotice,
standardButtons: Dialog.Ok})
text: GeoMapProvider.copyrightNotice,
standardButtons: Dialog.Ok})
Global.dialogLoader.active = true
}
}
Expand Down

0 comments on commit 8389d8c

Please sign in to comment.