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

Add a value map button interface threshold layer setting #83

Merged
merged 1 commit into from
May 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion libqfieldsync/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def __init__(
# compatibility with QFieldSync <4.3 and QField <2.7
self._photo_naming = {}
self._relationship_maximum_visible = {}
self._value_map_button_interface_threshold = 0
self._is_geometry_locked = None
self._is_geometry_locked_expression_active = False
self._geometry_locked_expression = ""
Expand Down Expand Up @@ -168,6 +169,9 @@ def read_layer(self):
self._relationship_maximum_visible = json.loads(
self.layer.customProperty("QFieldSync/relationship_maximum_visible") or "{}"
)
self._value_map_button_interface_threshold = self.layer.customProperty(
"QFieldSync/value_map_button_interface_threshold", 0
)
self._is_geometry_locked = self.layer.customProperty(
"QFieldSync/is_geometry_locked", False
)
Expand Down Expand Up @@ -233,6 +237,10 @@ def apply(self):
self.layer.customProperty("QFieldSync/relationship_maximum_visible")
!= relationship_maximum_visible_json
)
has_changed |= (
self.layer.customProperty("QFieldSync/value_map_button_interface_threshold")
!= self.value_map_button_interface_threshold
)
has_changed |= (
bool(self.layer.customProperty("QFieldSync/is_geometry_locked"))
!= self.is_geometry_locked
Expand Down Expand Up @@ -323,7 +331,10 @@ def apply(self):
self.layer.setCustomProperty(
"QFieldSync/relationship_maximum_visible", relationship_maximum_visible_json
)

self.layer.setCustomProperty(
"QFieldSync/value_map_button_interface_threshold",
self.value_map_button_interface_threshold,
)
# custom properties does not store the data type, so it is safer to remove boolean custom properties, rather than setting them to the string 'false' (which is boolean `True`)
if self.is_geometry_locked:
self.layer.setCustomProperty("QFieldSync/is_geometry_locked", True)
Expand Down Expand Up @@ -684,6 +695,18 @@ def is_supported(self):
def can_lock_geometry(self):
return self.layer.type() == QgsMapLayer.VectorLayer

@property
def value_map_button_interface_threshold(self):
return self._value_map_button_interface_threshold

@value_map_button_interface_threshold.setter
def value_map_button_interface_threshold(
self, value_map_button_interface_threshold
):
self._value_map_button_interface_threshold = (
value_map_button_interface_threshold
)

@property
def is_geometry_locked(self):
return bool(self._is_geometry_locked)
Expand Down
Loading