Skip to content

Commit

Permalink
Merge pull request #91 from opengisch/map_themes_active_layer
Browse files Browse the repository at this point in the history
Add a project settting to keep track of map themes' default active layer
  • Loading branch information
nirvn authored Jul 23, 2024
2 parents 9d2faac + 2e847e4 commit c670dcf
Showing 1 changed file with 25 additions and 0 deletions.
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

0 comments on commit c670dcf

Please sign in to comment.