From 4e17a5e8814576a1d86d2eb7c594ca0fed3e15bd Mon Sep 17 00:00:00 2001 From: Acly Date: Sat, 21 Sep 2024 12:34:08 +0200 Subject: [PATCH] Synchronize auto-update settings between different dialogs --- ai_diffusion/ui/diffusion.py | 4 ++++ ai_diffusion/ui/settings.py | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ai_diffusion/ui/diffusion.py b/ai_diffusion/ui/diffusion.py index 971a7e9c6..1f218dfb5 100644 --- a/ai_diffusion/ui/diffusion.py +++ b/ai_diffusion/ui/diffusion.py @@ -47,9 +47,12 @@ def __init__(self, parent: QWidget): root.auto_update.latest_version_changed.connect(self.update_content) root.auto_update.error_changed.connect(self.update_content) + settings.changed.connect(self.update_content) self.update_content() def update_content(self): + self._update_checkbox.setChecked(settings.auto_update) + au = root.auto_update match au.state: case UpdateState.available: @@ -80,6 +83,7 @@ def is_visible(self): def _toggle_auto_update(self): settings.auto_update = self._update_checkbox.isChecked() settings.save() + root.auto_update.state_changed.emit(root.auto_update.state) def _run_update(self): root.auto_update.run() diff --git a/ai_diffusion/ui/settings.py b/ai_diffusion/ui/settings.py index 0ea966b32..aeb98b3b7 100644 --- a/ai_diffusion/ui/settings.py +++ b/ai_diffusion/ui/settings.py @@ -645,7 +645,7 @@ def __init__(self): self._update_checkbox = QCheckBox(_("Check for updates on startup"), self) self._update_checkbox.setChecked(settings.auto_update) - self._update_checkbox.stateChanged.connect(self._toggle_auto_update) + self._update_checkbox.stateChanged.connect(self.write) self._check_button = QPushButton(_("Check for Updates"), self) self._check_button.setMinimumWidth(font_height * 6) @@ -733,16 +733,18 @@ def _update_content(self): _("Please restart Krita to complete the update!") ) - def _toggle_auto_update(self): - settings.auto_update = self._update_checkbox.isChecked() - settings.save() - def _check_updates(self): root.auto_update.check() def _run_update(self): root.auto_update.run() + def _read(self): + self._update_checkbox.setChecked(settings.auto_update) + + def _write(self): + settings.auto_update = self._update_checkbox.isChecked() + _links_text = """ Website

@@ -783,6 +785,7 @@ def __init__(self, server: Server): self.diffusion = DiffusionSettings() self.interface = InterfaceSettings() self.performance = PerformanceSettings() + self.about = AboutSettings() self._stack = QStackedWidget(self) self._list = QListWidget(self) @@ -798,7 +801,7 @@ def create_list_item(text: str, widget: QWidget): create_list_item(_("Diffusion"), self.diffusion) create_list_item(_("Interface"), self.interface) create_list_item(_("Performance"), self.performance) - create_list_item(_("Plugin"), AboutSettings()) + create_list_item(_("Plugin"), self.about) self._list.setCurrentRow(0) self._list.currentRowChanged.connect(self._change_page) @@ -842,6 +845,7 @@ def read(self): self.diffusion.read() self.interface.read() self.performance.read() + self.about.read() def restore_defaults(self): settings.restore()