Skip to content

Commit

Permalink
Propagate "update check" prompt to UI checkbox
Browse files Browse the repository at this point in the history
The "check for updates" button wasn't showing up immediately as checked
as soon as the user is prompted for checking updates. This fixes that.

Fixes #513
  • Loading branch information
deeplow committed Aug 14, 2023
1 parent 6f1f098 commit f1e2e3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions dangerzone/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def open_files(filenames: List[str] = []) -> None:
# Check for updates
log.debug("Setting up Dangezone updater")
updater = UpdaterThread(dangerzone)
updater.update_check_toggled.connect(window.refresh_updates_checkbox)
window.register_update_handler(updater.finished)

log.debug("Consulting updater settings before checking for updates")
Expand Down
5 changes: 5 additions & 0 deletions dangerzone/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ def toggle_updates_triggered(self) -> None:
self.dangerzone.settings.set("updater_check", check)
self.dangerzone.settings.save()

def refresh_updates_checkbox(self) -> None:
"""Refreshes the "check for updates" checkbox according to the settings"""
check = self.dangerzone.settings.get("updater_check")
self.toggle_updates_action.setChecked(check)

def handle_updates(self, report: UpdateReport) -> None:
"""Handle update reports from the update checker thread.
Expand Down
2 changes: 2 additions & 0 deletions dangerzone/gui/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class UpdaterThread(QtCore.QThread):
"""

finished = QtCore.Signal(UpdateReport)
update_check_toggled = QtCore.Signal()

GH_RELEASE_URL = (
"https://api.github.com/repos/freedomofpress/dangerzone/releases/latest"
Expand Down Expand Up @@ -176,6 +177,7 @@ def should_check_for_updates(self) -> bool:
if self.check is None:
log.debug("User has not been asked yet for update checks")
self.check = self.prompt_for_checks()
self.update_check_toggled.emit()
return bool(self.check)
elif not self.check:
log.debug("User has expressed that they don't want to check for updates")
Expand Down

0 comments on commit f1e2e3f

Please sign in to comment.