Add option for toggling update checks (#3346)

This commit is contained in:
Voczi 2024-08-10 12:46:49 +02:00 committed by GitHub
parent 06d5256f4e
commit 1065941767
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 26 additions and 1 deletions

View file

@ -185,6 +185,7 @@ Expertium <https://github.com/Expertium>
Christian Donat <https://github.com/cdonat2>
Asuka Minato <https://asukaminato.eu.org>
Dillon Baldwin <https://github.com/DillBal>
Voczi <https://github.com/voczi>
********************
The text of the 3 clause BSD license follows:

View file

@ -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,

View file

@ -82,6 +82,19 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="check_for_updates">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>preferences_check_for_updates</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View file

@ -1431,6 +1431,7 @@ title="{}" {}>{}</button>""".format(
def setup_auto_update(self, _log: list[DownloadLogEntry]) -> None:
from aqt.update import check_for_update
if aqt.mw.pm.check_for_updates():
check_for_update()
# Timers

View file

@ -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)

View file

@ -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)