mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Add last version check for add-on updates (#1608)
* Add last version check for add-on updates * Remove second add-on update check * Show tooltip after toggling/deleting add-on
This commit is contained in:
parent
a8d4774cdb
commit
f6546c9f35
3 changed files with 26 additions and 4 deletions
|
@ -726,6 +726,7 @@ class AddonsDialog(QDialog):
|
||||||
def __init__(self, addonsManager: AddonManager) -> None:
|
def __init__(self, addonsManager: AddonManager) -> None:
|
||||||
self.mgr = addonsManager
|
self.mgr = addonsManager
|
||||||
self.mw = addonsManager.mw
|
self.mw = addonsManager.mw
|
||||||
|
self._require_restart = False
|
||||||
|
|
||||||
super().__init__(self.mw)
|
super().__init__(self.mw)
|
||||||
|
|
||||||
|
@ -768,6 +769,8 @@ class AddonsDialog(QDialog):
|
||||||
self.onInstallFiles(paths)
|
self.onInstallFiles(paths)
|
||||||
|
|
||||||
def reject(self) -> None:
|
def reject(self) -> None:
|
||||||
|
if self._require_restart:
|
||||||
|
tooltip(tr.addons_changes_will_take_effect_when_anki(), parent=self.mw)
|
||||||
saveGeom(self, "addons")
|
saveGeom(self, "addons")
|
||||||
aqt.dialogs.markClosed("AddonsDialog")
|
aqt.dialogs.markClosed("AddonsDialog")
|
||||||
|
|
||||||
|
@ -854,6 +857,7 @@ class AddonsDialog(QDialog):
|
||||||
def onToggleEnabled(self) -> None:
|
def onToggleEnabled(self) -> None:
|
||||||
for module in self.selectedAddons():
|
for module in self.selectedAddons():
|
||||||
self.mgr.toggleEnabled(module)
|
self.mgr.toggleEnabled(module)
|
||||||
|
self._require_restart = True
|
||||||
self.redrawAddons()
|
self.redrawAddons()
|
||||||
|
|
||||||
def onViewPage(self) -> None:
|
def onViewPage(self) -> None:
|
||||||
|
@ -885,6 +889,9 @@ class AddonsDialog(QDialog):
|
||||||
return
|
return
|
||||||
gui_hooks.addons_dialog_will_delete_addons(self, selected)
|
gui_hooks.addons_dialog_will_delete_addons(self, selected)
|
||||||
for module in selected:
|
for module in selected:
|
||||||
|
# doing this before deleting, as `enabled` is always True afterwards
|
||||||
|
if self.mgr.addon_meta(module).enabled:
|
||||||
|
self._require_restart = True
|
||||||
if not self.mgr.deleteAddon(module):
|
if not self.mgr.deleteAddon(module):
|
||||||
break
|
break
|
||||||
self.form.addonList.clearSelection()
|
self.form.addonList.clearSelection()
|
||||||
|
|
|
@ -31,7 +31,16 @@ from anki.decks import DeckDict, DeckId
|
||||||
from anki.hooks import runHook
|
from anki.hooks import runHook
|
||||||
from anki.notes import NoteId
|
from anki.notes import NoteId
|
||||||
from anki.sound import AVTag, SoundOrVideoTag
|
from anki.sound import AVTag, SoundOrVideoTag
|
||||||
from anki.utils import dev_mode, ids2str, int_time, is_lin, is_mac, is_win, split_fields
|
from anki.utils import (
|
||||||
|
dev_mode,
|
||||||
|
ids2str,
|
||||||
|
int_time,
|
||||||
|
is_lin,
|
||||||
|
is_mac,
|
||||||
|
is_win,
|
||||||
|
point_version,
|
||||||
|
split_fields,
|
||||||
|
)
|
||||||
from aqt import gui_hooks
|
from aqt import gui_hooks
|
||||||
from aqt.addons import DownloadLogEntry, check_and_prompt_for_updates, show_log_to_user
|
from aqt.addons import DownloadLogEntry, check_and_prompt_for_updates, show_log_to_user
|
||||||
from aqt.dbcheck import check_db
|
from aqt.dbcheck import check_db
|
||||||
|
@ -713,7 +722,6 @@ class AnkiQt(QMainWindow):
|
||||||
gui_hooks.state_did_change(state, oldState)
|
gui_hooks.state_did_change(state, oldState)
|
||||||
|
|
||||||
def _deckBrowserState(self, oldState: str) -> None:
|
def _deckBrowserState(self, oldState: str) -> None:
|
||||||
self.maybe_check_for_addon_updates()
|
|
||||||
self.deckBrowser.show()
|
self.deckBrowser.show()
|
||||||
|
|
||||||
def _selectedDeck(self) -> DeckDict | None:
|
def _selectedDeck(self) -> DeckDict | None:
|
||||||
|
@ -933,7 +941,7 @@ title="{}" {}>{}</button>""".format(
|
||||||
last_check = self.pm.last_addon_update_check()
|
last_check = self.pm.last_addon_update_check()
|
||||||
elap = int_time() - last_check
|
elap = int_time() - last_check
|
||||||
|
|
||||||
if elap > 86_400:
|
if elap > 86_400 or self.pm.last_run_version() != point_version():
|
||||||
check_and_prompt_for_updates(
|
check_and_prompt_for_updates(
|
||||||
self,
|
self,
|
||||||
self.addonManager,
|
self.addonManager,
|
||||||
|
@ -1112,6 +1120,7 @@ title="{}" {}>{}</button>""".format(
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def closeEvent(self, event: QCloseEvent) -> None:
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
|
self.pm.set_last_run_version()
|
||||||
if self.state == "profileManager":
|
if self.state == "profileManager":
|
||||||
# if profile manager active, this event may fire via OS X menu bar's
|
# if profile manager active, this event may fire via OS X menu bar's
|
||||||
# quit option
|
# quit option
|
||||||
|
|
|
@ -20,7 +20,7 @@ from anki.collection import Collection
|
||||||
from anki.db import DB
|
from anki.db import DB
|
||||||
from anki.lang import without_unicode_isolation
|
from anki.lang import without_unicode_isolation
|
||||||
from anki.sync import SyncAuth
|
from anki.sync import SyncAuth
|
||||||
from anki.utils import int_time, is_mac, is_win
|
from anki.utils import int_time, is_mac, is_win, point_version
|
||||||
from aqt import appHelpSite
|
from aqt import appHelpSite
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.theme import Theme
|
from aqt.theme import Theme
|
||||||
|
@ -499,6 +499,12 @@ create table if not exists profiles
|
||||||
# Shared options
|
# Shared options
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
def last_run_version(self) -> int:
|
||||||
|
return self.meta.get("last_run_version", 0)
|
||||||
|
|
||||||
|
def set_last_run_version(self) -> None:
|
||||||
|
self.meta["last_run_version"] = point_version()
|
||||||
|
|
||||||
def uiScale(self) -> float:
|
def uiScale(self) -> float:
|
||||||
scale = self.meta.get("uiScale", 1.0)
|
scale = self.meta.get("uiScale", 1.0)
|
||||||
return max(scale, 1)
|
return max(scale, 1)
|
||||||
|
|
Loading…
Reference in a new issue