Skip to content

Commit

Permalink
Default snappingTolerance on Normal.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenD98 committed Jan 31, 2025
1 parent aa21c33 commit f434250
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
46 changes: 23 additions & 23 deletions src/qml/CoordinateLocator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Item {
property bool snapToCommonAngles: false
property bool snappingIsRelative: false
property real snappingAngleDegrees: 45.0
property real snappingTolerance: 0
property real snappingTolerance: 1

/**
* Overrides any possibility for the user to modify the coordinate.
Expand Down Expand Up @@ -393,6 +393,28 @@ Item {
flashAnimation.start();
}

/** Function to get the multiplier based on the selected tolerance
*
* - Narrow tolerance (index 0) divides by 2.
* - Normal tolerance (index 1) keeps unchanged.
* - Large tolerance (index 2) multiplies by 4.
*/
function getToleranceMultiplier() {
switch (snappingTolerance) {
case 0 // Narrow
:
return 0.5;
case 1 // Normal
:
return 1;
case 2 // Large
:
return 4;
default:
return 1;
}
}

/**
* Computes the possible common angle
*
Expand Down Expand Up @@ -446,28 +468,6 @@ Item {
}
}

/** Function to get the multiplier based on the selected tolerance
*
* - Narrow tolerance (index 0) divides by 2.
* - Normal tolerance (index 1) keeps unchanged.
* - Large tolerance (index 2) multiplies by 4.
*/
function getToleranceMultiplier() {
switch (snappingTolerance) {
case 0 // Narrow
:
return 0.5;
case 1 // Normal
:
return 1;
case 2 // Large
:
return 4;
default:
return 1;
}
}

/**
* Computes a new point that forms a common angle
*
Expand Down
6 changes: 4 additions & 2 deletions src/qml/qgismobileapp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ ApplicationWindow {
coordinateLocator.snapToCommonAngles = settings.valueBool("/QField/Digitizing/SnapToCommonAngleIsEnabled", false);
coordinateLocator.snappingIsRelative = settings.valueBool("/QField/Digitizing/SnapToCommonAngleIsRelative", true);
coordinateLocator.snappingAngleDegrees = settings.valueInt("/QField/Digitizing/SnapToCommonAngleDegrees", 45);
coordinateLocator.snappingTolerance = settings.valueInt("/QField/Digitizing/SnappingTolerance", 0);
coordinateLocator.snappingTolerance = settings.valueInt("/QField/Digitizing/SnappingTolerance", 1);
}

Menu {
Expand Down Expand Up @@ -1750,7 +1750,6 @@ ApplicationWindow {
color: selected ? Theme.mainColor : "transparent" // Theme.darkTheme ? Theme.gray : Theme.lightGray
enabled: !selected

// border.color: Theme.darkTheme ? Theme.gray : Theme.lightGray
property bool selected: modelData === coordinateLocator.snappingAngleDegrees

Text {
Expand Down Expand Up @@ -1828,6 +1827,9 @@ ApplicationWindow {
font: parent.selected ? Theme.strongTipFont : Theme.tipFont
anchors.centerIn: parent
color: Theme.mainTextColor
elide: Text.ElideRight
width: parent.width
horizontalAlignment: Text.AlignHCenter
}

Ripple {
Expand Down

0 comments on commit f434250

Please sign in to comment.