Add option to toggle add-on updates on and off

This commit is contained in:
SecretX33 2025-12-27 10:50:44 -03:00
parent 8f2144534b
commit a657f91fe6
5 changed files with 32 additions and 0 deletions

View file

@ -41,6 +41,7 @@ preferences-theme-light = Light
preferences-theme-dark = Dark
preferences-v3-scheduler = V3 scheduler
preferences-check-for-updates = Check for program updates
preferences-check-for-addon-updates = Check for add-on 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

@ -95,6 +95,19 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="check_for_addon_updates">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>preferences_check_for_addon_updates</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -1254,6 +1267,7 @@
<tabstop>lang</tabstop>
<tabstop>video_driver</tabstop>
<tabstop>check_for_updates</tabstop>
<tabstop>check_for_addon_updates</tabstop>
<tabstop>theme</tabstop>
<tabstop>styleComboBox</tabstop>
<tabstop>uiScale</tabstop>

View file

@ -1022,6 +1022,11 @@ title="{}" {}>{}</button>""".format(
def maybe_check_for_addon_updates(
self, on_done: Callable[[list[DownloadLogEntry]], None] | None = None
) -> None:
if not self.pm.check_for_addon_updates():
if on_done:
on_done([])
return
last_check = self.pm.last_addon_update_check()
elap = int_time() - last_check

View file

@ -224,6 +224,12 @@ class Preferences(QDialog):
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.form.check_for_addon_updates.setChecked(self.mw.pm.check_for_addon_updates())
qconnect(
self.form.check_for_addon_updates.stateChanged,
self.mw.pm.set_check_for_addon_updates,
)
self.update_login_status()
qconnect(self.form.syncLogout.clicked, self.sync_logout)
qconnect(self.form.syncLogin.clicked, self.sync_login)

View file

@ -596,6 +596,12 @@ create table if not exists profiles
def set_last_addon_update_check(self, secs: int) -> None:
self.meta["last_addon_update_check"] = secs
def check_for_addon_updates(self) -> bool:
return self.meta.get("check_for_addon_updates", True)
def set_check_for_addon_updates(self, on: bool) -> None:
self.meta["check_for_addon_updates"] = on
@deprecated(info="use theme_manager.night_mode")
def night_mode(self) -> bool:
return theme_manager.night_mode