implemented log settings

This commit is contained in:
2025-10-30 12:38:14 +11:00
parent f6cfc7c630
commit 13862bdad5
2 changed files with 14 additions and 3 deletions

View File

@@ -189,12 +189,15 @@ class PluginLoader(Window):
plugin_paths.append(plugin_folder)
log.write("\n[b]Done loading plugins![/]")
if no_errors:
if no_errors and int(self.app.config_handler.get("plugins", "log_timeout")) != -1:
log.write("[d]Window will automatically close in 10 seconds.[/]")
await asyncio.sleep(10)
await asyncio.sleep(int(self.app.config_handler.get("plugins", "log_timeout")))
self.close_window()
async def on_mount(self):
if bool(int(self.app.config_handler.get("plugins", "log"))) == False:
self.display = "none"
self.find_plugins()

View File

@@ -67,12 +67,20 @@ class SettingsScreen(ModalScreen):
elif event.switch.id == "plugins-enabled":
self.app.config_handler.set("plugins", "enabled", str(int(event.value)))
self.notify("Restart for changes to apply.", title="Restart Required", severity="warning")
elif event.switch.id == "plugins-log":
self.app.config_handler.set("plugins", "log", str(int(event.value)))
def on_select_changed(self, event: Select.Changed):
if event.select.id == "colour-theme":
self.app.theme = event.value
self.app.config_handler.set("appearance", "colour_theme", str(event.value))
def on_input_changed(self, event: Input.Changed):
if not event.input.is_valid: return
if event.input.id == "log-timeout":
self.app.config_handler.set("plugins", "log_timeout", str(event.input.value))
def compose(self):
with Vertical(id="window") as window:
window.border_title = "Settings"
@@ -114,5 +122,5 @@ class SettingsScreen(ModalScreen):
with HorizontalGroup(classes="setting"):
with VerticalGroup():
yield Label("Log Timeout", classes="setting-name")
yield Label("How many seconds before the log automatically closes. This gets overriden by the [b]Plugins Log[/] option. The window doesn't automatically close if there was an error.", classes="setting-desc")
yield Label("How many seconds before the log automatically closes. This gets overriden by the [b]Plugins Log[/] option. The window doesn't automatically close if there was an error. If this is set to -1, the log will not close automatically.", classes="setting-desc")
yield Input(value=self.app.config_handler.get("plugins", "log_timeout"), id="log-timeout", type="integer")