Skip to content
Snippets Groups Projects
Commit eabc344d authored by ave's avatar ave
Browse files

st3m/settings: load settings when imported

parent e97acf8e
No related branches found
No related tags found
No related merge requests found
...@@ -48,9 +48,6 @@ class ApplicationContext: ...@@ -48,9 +48,6 @@ class ApplicationContext:
class Application(BaseView): class Application(BaseView):
def __init__(self, app_ctx: ApplicationContext) -> None: def __init__(self, app_ctx: ApplicationContext) -> None:
self._app_ctx = app_ctx self._app_ctx = app_ctx
if not settings.settings_loaded:
settings.load_all()
if app_ctx and app_ctx.bundle_metadata and settings.onoff_wifi_preference.value: if app_ctx and app_ctx.bundle_metadata and settings.onoff_wifi_preference.value:
self._wifi_preference = app_ctx.bundle_metadata["app"].get( self._wifi_preference = app_ctx.bundle_metadata["app"].get(
"wifi_preference" "wifi_preference"
......
...@@ -151,8 +151,6 @@ def run_main() -> None: ...@@ -151,8 +151,6 @@ def run_main() -> None:
bundles = BundleManager() bundles = BundleManager()
bundles.update() bundles.update()
settings.load_all()
try: try:
network.hostname( network.hostname(
settings.str_hostname.value if settings.str_hostname.value else "flow3r" settings.str_hostname.value if settings.str_hostname.value else "flow3r"
......
...@@ -320,8 +320,6 @@ class ObfuscatedValueWidget(TunableWidget): ...@@ -320,8 +320,6 @@ class ObfuscatedValueWidget(TunableWidget):
pass pass
settings_loaded: bool = False
# Actual tunables / settings. # Actual tunables / settings.
onoff_button_swap = OnOffTunable("Swap Buttons", "system.swap_buttons", False) onoff_button_swap = OnOffTunable("Swap Buttons", "system.swap_buttons", False)
onoff_show_fps = OnOffTunable("Show FPS", "system.show_fps", False) onoff_show_fps = OnOffTunable("Show FPS", "system.show_fps", False)
...@@ -360,7 +358,6 @@ def load_all() -> None: ...@@ -360,7 +358,6 @@ def load_all() -> None:
try: try:
with open("/flash/settings.json", "r") as f: with open("/flash/settings.json", "r") as f:
data = json.load(f) data = json.load(f)
settings_loaded = True
except Exception as e: except Exception as e:
log.warning("Could not load settings: " + str(e)) log.warning("Could not load settings: " + str(e))
return return
...@@ -397,3 +394,6 @@ def save_all() -> None: ...@@ -397,3 +394,6 @@ def save_all() -> None:
return return
log.info("Saved settings to flash") log.info("Saved settings to flash")
load_all()
...@@ -14,21 +14,7 @@ from st3m.ui.menu import MenuItem, MenuItemBack ...@@ -14,21 +14,7 @@ from st3m.ui.menu import MenuItem, MenuItemBack
from st3m.application import BundleMetadata, MenuItemAppLaunch from st3m.application import BundleMetadata, MenuItemAppLaunch
from st3m.ui.elements.menus import SimpleMenu from st3m.ui.elements.menus import SimpleMenu
from st3m.ui.view import ViewManager from st3m.ui.view import ViewManager
from st3m.settings import ( from st3m.settings import *
UnaryTunable,
load_all,
save_all,
onoff_show_tray,
onoff_button_swap,
onoff_debug,
onoff_debug_touch,
onoff_wifi,
onoff_wifi_preference,
onoff_show_fps,
str_wifi_ssid,
str_wifi_psk,
str_hostname,
)
from ctx import Context from ctx import Context
log = logging.Log(__name__, level=logging.INFO) log = logging.Log(__name__, level=logging.INFO)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment