actually load the settings when you open the app

This commit is contained in:
SpookyDervish
2025-10-30 07:20:01 +11:00
parent 7bc671ef63
commit 4f23e7570c
3 changed files with 40 additions and 12 deletions

View File

@@ -3,10 +3,6 @@ from textual.widgets import Label, Select, TabbedContent, TabPane, Switch
from textual.containers import Vertical, HorizontalGroup, VerticalGroup
from textual.binding import Binding
from settings_store import ConfigHandler
import os
class SettingsScreen(ModalScreen):
border_title = "Settings"
@@ -58,7 +54,6 @@ class SettingsScreen(ModalScreen):
def __init__(self):
super().__init__()
self.config_handler = ConfigHandler()
def action_close(self):
self.dismiss()
@@ -66,13 +61,12 @@ class SettingsScreen(ModalScreen):
def on_switch_changed(self, event: Switch.Changed):
if event.switch.id == "word-wrap":
self.app.query_one("#code-editor").soft_wrap = event.value
self.config_handler.set("editor", "word_wrap", str(int(event.value)))
self.notify(str(int(event.value)))
self.app.config_handler.set("editor", "word_wrap", str(int(event.value)))
def on_select_changed(self, event: Select.Changed):
if event.select.id == "colour-theme":
self.app.theme = event.value
self.config_handler.set("appearance", "colour_theme", str(event.value))
self.app.config_handler.set("appearance", "colour_theme", str(event.value))
def compose(self):
with Vertical(id="window") as window:
@@ -97,7 +91,7 @@ class SettingsScreen(ModalScreen):
with VerticalGroup():
yield Label("Word Wrap", classes="setting-name")
yield Label("Enable word wrap in the code editor.", classes="setting-desc")
yield Switch(value=bool(int(self.config_handler.get("editor", "word_wrap"))), id="word-wrap")
yield Switch(value=bool(int(self.app.config_handler.get("editor", "word_wrap"))), id="word-wrap")
with TabPane("Plugins"):
with HorizontalGroup(classes="setting"):
with VerticalGroup():