Skip to content

Commit

Permalink
Merge pull request #5266 from opengisch/lock-map-rotation
Browse files Browse the repository at this point in the history
Lock map rotation
  • Loading branch information
nirvn committed May 24, 2024
2 parents a6816a6 + 11163de commit 100983f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
5 changes: 3 additions & 2 deletions src/qml/MapCanvas.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Item {
property bool hovered: false
property bool pinched: pinchHandler.active
property bool freehandDigitizing: false
property bool isMapRotationEnabled: false

// for signals, type can be "stylus" for any device click or "touch"

Expand Down Expand Up @@ -346,7 +347,7 @@ Item {

DragHandler {
target: null
enabled: interactive
enabled: interactive && isMapRotationEnabled
acceptedDevices: PointerDevice.Stylus | PointerDevice.Mouse
acceptedModifiers: Qt.ShiftModifier
grabPermissions: PointerHandler.TakeOverForbidden
Expand Down Expand Up @@ -421,7 +422,7 @@ Item {
}

onRotationChanged: {
if ( active )
if ( active && isMapRotationEnabled )
{
if (rotationTresholdReached)
{
Expand Down
8 changes: 8 additions & 0 deletions src/qml/QFieldSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Page {
property alias fingerTapDigitizing: registry.fingerTapDigitizing
property alias mouseAsTouchScreen: registry.mouseAsTouchScreen
property alias enableInfoCollection: registry.enableInfoCollection
property alias enableMapRotation: registry.enableMapRotation
property alias quality: registry.quality

Component.onCompleted: {
Expand All @@ -45,6 +46,7 @@ Page {
property bool fingerTapDigitizing: false
property bool mouseAsTouchScreen: false
property bool enableInfoCollection: true
property bool enableMapRotation: true
property double quality: 1.0

onEnableInfoCollectionChanged: {
Expand Down Expand Up @@ -78,6 +80,12 @@ Page {
settingAlias: "showBookmarks"
isVisible: true
}
ListElement {
title: qsTr( "Enable map rotation" )
description: qsTr( "When switched on, the map can be rotated by the user." )
settingAlias: "enableMapRotation"
isVisible: true
}
}

ListModel {
Expand Down
6 changes: 3 additions & 3 deletions src/qml/imports/Theme/Theme.qml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ QtObject {

readonly property int popupScreenEdgeMargin: 40

readonly property int menuItemIconlessLeftPadding: 54
readonly property int menuItemLeftPadding: 14
readonly property int menuItemCheckLeftPadding: 20
readonly property int menuItemIconlessLeftPadding: 52
readonly property int menuItemLeftPadding: 12
readonly property int menuItemCheckLeftPadding: 16

function getThemeIcon(name) {
var ppiName
Expand Down
49 changes: 26 additions & 23 deletions src/qml/qgismobileapp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ ApplicationWindow {
!sketcher.visible &&
!overlayFeatureFormDrawer.visible
interactive: isEnabled && !screenLocker.enabled
isMapRotationEnabled: qfieldSettings.enableMapRotation
incrementalRendering: true
quality: qfieldSettings.quality
forceDeferredLayersRepaint: trackings.count > 0
Expand Down Expand Up @@ -2636,12 +2637,14 @@ ApplicationWindow {
var xValue = Number( displayPoint.x ).toLocaleString( Qt.locale(), 'f', isGeographic ? 7 : 3 )
var yLabel = isGeographic ? qsTr( 'Lat' ) : 'Y'
var yValue = Number( displayPoint.y ).toLocaleString( Qt.locale(), 'f', isGeographic ? 7 : 3 )
xItem.text = isXY
const xItemText = isXY
? xLabel + ': ' + xValue
: yLabel + ': ' + yValue
yItem.text = isXY
const yItemText = isXY
? yLabel + ': ' + yValue
: xLabel + ': ' + xValue

cordinateItem.text = xItemText + " " + yItemText
}

topMargin: sceneTopMargin
Expand Down Expand Up @@ -2675,19 +2678,18 @@ ApplicationWindow {
MenuSeparator { width: parent.width; height: canvasMenuActionsToolbar.children.length > 0 ? undefined : 0 }

MenuItem {
id: xItem
text: ""
height: 48
font: Theme.defaultFont
enabled:false
}
id: cordinateItem
text: ""
height: 48
leftPadding: Theme.menuItemLeftPadding
font: Theme.defaultFont
icon.source: Theme.getThemeVectorIcon( "ic_copy_black_24dp" )

MenuItem {
id: yItem
text: ""
height: 48
font: Theme.defaultFont
enabled:false
onTriggered: {
const displayPoint = GeometryUtils.reprojectPoint(canvasMenu.point, mapCanvas.mapSettings.destinationCrs, projectInfo.coordinateDisplayCrs)
platformUtilities.copyTextToClipboard(StringUtils.pointInformation(displayPoint, projectInfo.coordinateDisplayCrs))
displayToast(qsTr('Coordinates copied to clipboard'));
}
}

MenuSeparator { width: parent.width }
Expand Down Expand Up @@ -2727,18 +2729,19 @@ ApplicationWindow {
}

MenuItem {
id: copyCoordinatesItem
text: qsTr( "Copy Coordinates" )
id: lockMapRotation
text: "Enable Map Rotation"
height: 48
leftPadding: Theme.menuItemLeftPadding
leftPadding: Theme.menuItemCheckLeftPadding
font: Theme.defaultFont
icon.source: Theme.getThemeVectorIcon( "ic_copy_black_24dp" )
checkable: true
checked: qfieldSettings.enableMapRotation
indicator.height: 20
indicator.width: 20
indicator.implicitHeight: 24
indicator.implicitWidth: 24

onTriggered: {
var displayPoint = GeometryUtils.reprojectPoint(canvasMenu.point, mapCanvas.mapSettings.destinationCrs, projectInfo.coordinateDisplayCrs)
platformUtilities.copyTextToClipboard(StringUtils.pointInformation(displayPoint, projectInfo.coordinateDisplayCrs))
displayToast(qsTr('Coordinates copied to clipboard'));
}
onTriggered: qfieldSettings.enableMapRotation = checked
}

MenuSeparator { width: parent.width }
Expand Down

1 comment on commit 100983f

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.