From 106594176755ba6d273e208dcadc11a50d08b79c Mon Sep 17 00:00:00 2001 From: Voczi Date: Sat, 10 Aug 2024 12:46:49 +0200 Subject: [PATCH] Add option for toggling update checks (#3346) --- CONTRIBUTORS | 1 + ftl/core/preferences.ftl | 1 + qt/aqt/forms/preferences.ui | 13 +++++++++++++ qt/aqt/main.py | 3 ++- qt/aqt/preferences.py | 3 +++ qt/aqt/profiles.py | 6 ++++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a05949544..b2f34ebf5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -185,6 +185,7 @@ Expertium Christian Donat Asuka Minato Dillon Baldwin +Voczi ******************** The text of the 3 clause BSD license follows: diff --git a/ftl/core/preferences.ftl b/ftl/core/preferences.ftl index 3e0a2414b..1da294b5a 100644 --- a/ftl/core/preferences.ftl +++ b/ftl/core/preferences.ftl @@ -41,6 +41,7 @@ preferences-theme-follow-system = Follow System preferences-theme-light = Light preferences-theme-dark = Dark preferences-v3-scheduler = V3 scheduler +preferences-check-for-updates = Check for program updates preferences-ignore-accents-in-search = Ignore accents in search (slower) preferences-backup-explanation = Anki periodically backs up your collection. After backups are more than 2 days old, diff --git a/qt/aqt/forms/preferences.ui b/qt/aqt/forms/preferences.ui index 671b45600..319ff47cb 100644 --- a/qt/aqt/forms/preferences.ui +++ b/qt/aqt/forms/preferences.ui @@ -82,6 +82,19 @@ + + + + + 0 + 0 + + + + preferences_check_for_updates + + + diff --git a/qt/aqt/main.py b/qt/aqt/main.py index 022afd2cd..9508cc10d 100644 --- a/qt/aqt/main.py +++ b/qt/aqt/main.py @@ -1431,7 +1431,8 @@ title="{}" {}>{}""".format( def setup_auto_update(self, _log: list[DownloadLogEntry]) -> None: from aqt.update import check_for_update - check_for_update() + if aqt.mw.pm.check_for_updates(): + check_for_update() # Timers ########################################################################## diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index 565163158..d0f7b07f4 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -207,6 +207,9 @@ class Preferences(QDialog): self.form.custom_sync_url.setText(self.mw.pm.custom_sync_url()) self.form.network_timeout.setValue(self.mw.pm.network_timeout()) + self.form.check_for_updates.setChecked(self.mw.pm.check_for_updates()) + qconnect(self.form.check_for_updates.stateChanged, self.mw.pm.set_update_check) + self.update_login_status() qconnect(self.form.syncLogout.clicked, self.sync_logout) qconnect(self.form.syncLogin.clicked, self.sync_login) diff --git a/qt/aqt/profiles.py b/qt/aqt/profiles.py index f70000543..ceecf50f2 100644 --- a/qt/aqt/profiles.py +++ b/qt/aqt/profiles.py @@ -652,6 +652,12 @@ create table if not exists profiles def set_host_number(self, val: int | None) -> None: self.profile["hostNum"] = val or 0 + def check_for_updates(self) -> bool: + return self.meta.get("check_for_updates", True) + + def set_update_check(self, on: bool) -> None: + self.meta["check_for_updates"] = on + def media_syncing_enabled(self) -> bool: return self.profile.get("syncMedia", True)