GeoDonkey for QGIS 1.12
This commit is contained in:
commit
20ab32da30
63 files changed
+11157
No files matched your search
@@ -0,0 +1,39 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from qgis.core import QgsSettings
|
||||
|
||||
from . import config
|
||||
|
||||
_PREFIX = config.SETTINGS_GROUP + "/"
|
||||
|
||||
DEFAULTS = {
|
||||
"api_url": config.DEFAULT_API_URL,
|
||||
"limit": config.OSM_LIMIT_DEFAULT,
|
||||
"style": config.FALLBACK_STYLES[0]["id"],
|
||||
"last_query": "",
|
||||
"mode": "words",
|
||||
}
|
||||
|
||||
|
||||
def get(name: str, default=None):
|
||||
fallback = DEFAULTS.get(name) if default is None else default
|
||||
value = QgsSettings().value(_PREFIX + name, fallback)
|
||||
if isinstance(fallback, int) and not isinstance(fallback, bool):
|
||||
try:
|
||||
return int(value)
|
||||
except (TypeError, ValueError):
|
||||
return fallback
|
||||
return value
|
||||
|
||||
|
||||
def set(name: str, value) -> None: # noqa: A001
|
||||
QgsSettings().setValue(_PREFIX + name, value)
|
||||
|
||||
|
||||
def language() -> str:
|
||||
locale = str(QgsSettings().value("locale/userLocale", "en") or "en")
|
||||
return "de" if locale.lower().startswith("de") else "en"
|
||||
|
||||
|
||||
def api_url() -> str:
|
||||
return str(get("api_url") or config.DEFAULT_API_URL).rstrip("/")
|
||||
Reference in new issue
Block a user