lib settings
This commit is contained in:
@@ -12,6 +12,7 @@ class ApplicationSettings:
|
||||
DEFAULT_LOG_LEVEL = logging.INFO
|
||||
SNAP_TO_GRID_SIZE_KEY = "graph/snap_to_grid_size"
|
||||
DEFAULT_SNAP_TO_GRID_SIZE = 4
|
||||
LIBRARY_PATHS_KEY = "libraries/paths"
|
||||
|
||||
def __init__(self, settings: QSettings | None = None) -> None:
|
||||
self._settings = settings if settings is not None else QSettings()
|
||||
@@ -38,6 +39,17 @@ class ApplicationSettings:
|
||||
raise ValueError("snap-to-grid size must be positive")
|
||||
self._settings.setValue(self.SNAP_TO_GRID_SIZE_KEY, size)
|
||||
|
||||
@property
|
||||
def library_paths(self) -> list[str]:
|
||||
value = self._settings.value(self.LIBRARY_PATHS_KEY, [])
|
||||
if isinstance(value, str):
|
||||
return [value]
|
||||
return [str(path) for path in value] if isinstance(value, (list, tuple)) else []
|
||||
|
||||
@library_paths.setter
|
||||
def library_paths(self, paths: list[str]) -> None:
|
||||
self._settings.setValue(self.LIBRARY_PATHS_KEY, list(dict.fromkeys(paths)))
|
||||
|
||||
class SimulationApplicationSettings:
|
||||
"""Typed access to persistent BEsim application settings."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user