Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock map rotation #5266

Merged
merged 8 commits into from
May 24, 2024
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
Copy link
Member

Choose a reason for hiding this comment

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

The screenshot shows an alignment issue between icons and the checkbox. This should do it:

Suggested change
checked: qfieldSettings.enableMapRotation
checked: qfieldSettings.enableMapRotation
indicator.height: 20
indicator.width: 20
indicator.implicitHeight: 24
indicator.implicitWidth: 24

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok thank you..

result:

image

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
Loading