Skip to content

Commit

Permalink
Synchronize auto-update settings between different dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
Acly committed Sep 21, 2024
1 parent a396277 commit 4e17a5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ai_diffusion/ui/diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
16 changes: 10 additions & 6 deletions ai_diffusion/ui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = """
<a href='https://www.interstice.cloud'>Website</a><br><br>
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4e17a5e

Please sign in to comment.