From 13862bdad57a97764ce05533594bf1020d53e41a Mon Sep 17 00:00:00 2001 From: SpookyDervish Date: Thu, 30 Oct 2025 12:38:14 +1100 Subject: [PATCH] implemented log settings --- plugin_loader.py | 7 +++++-- settings.py | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugin_loader.py b/plugin_loader.py index cc36b1c..67122ce 100644 --- a/plugin_loader.py +++ b/plugin_loader.py @@ -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() diff --git a/settings.py b/settings.py index b1a4b3a..e26b190 100644 --- a/settings.py +++ b/settings.py @@ -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") \ No newline at end of file