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 project settting to keep track of map themes' default active layer #91

Merged
merged 2 commits into from
Jul 23, 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: 25 additions & 0 deletions libqfieldsync/project.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json


class ProjectProperties(object):
def __init__(self):
raise RuntimeError("This object holds only project property static variables")
Expand All @@ -22,6 +25,7 @@ def __init__(self):
GEOFENCING_LAYER = "/geofencingLayer"
GEOFENCING_BEHAVIOR = "/geofencingBehavior"
GEOFENCING_SHOULD_PREVENT_DIGITIZING = "/geofencingShouldPreventDigitizing"
MAP_THEMES_ACTIVE_LAYER = "/mapThemesActiveLayers"

class BaseMapType(object):
def __init__(self):
Expand Down Expand Up @@ -158,6 +162,27 @@ def geofencing_should_prevent_digitizing(self, value):
"qfieldsync", ProjectProperties.GEOFENCING_SHOULD_PREVENT_DIGITIZING, value
)

@property
def map_themes_active_layer(self):
entries_json, _ = self.project.readEntry(
"qfieldsync", ProjectProperties.MAP_THEMES_ACTIVE_LAYER
)

try:
entries = json.loads(entries_json)
except Exception:
entries = {}

return entries

@map_themes_active_layer.setter
def map_themes_active_layer(self, value):
self.project.writeEntry(
"qfieldsync",
ProjectProperties.MAP_THEMES_ACTIVE_LAYER,
json.dumps(value),
)

@property
def geofencing_is_active(self):
geofencing_is_active, _ = self.project.readBoolEntry(
Expand Down
Loading