mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 14:17:13 -05:00
clear compiled plugin files; make some strings translatable
This commit is contained in:
parent
5d5d796cd3
commit
5ecb4bde49
1 changed files with 24 additions and 2 deletions
|
|
@ -77,6 +77,17 @@ class AnkiQt(QMainWindow):
|
||||||
# activate & raise is useful when run from the command line on osx
|
# activate & raise is useful when run from the command line on osx
|
||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
self.raise_()
|
self.raise_()
|
||||||
|
# check if we've been updated
|
||||||
|
if "version" not in self.config:
|
||||||
|
# could be new user, or upgrade from older version
|
||||||
|
# which didn't have version variable
|
||||||
|
self.appUpdated = "first"
|
||||||
|
elif self.config['version'] != ankiqt.appVersion:
|
||||||
|
self.appUpdated = self.config['version']
|
||||||
|
else:
|
||||||
|
self.appUpdated = False
|
||||||
|
if self.appUpdated:
|
||||||
|
self.config['version'] = ankiqt.appVersion
|
||||||
# plugins might be looking at this
|
# plugins might be looking at this
|
||||||
self.state = "noDeck"
|
self.state = "noDeck"
|
||||||
self.loadPlugins()
|
self.loadPlugins()
|
||||||
|
|
@ -1588,8 +1599,8 @@ later by using File>Close.
|
||||||
|
|
||||||
def updateActives(self):
|
def updateActives(self):
|
||||||
labels = [
|
labels = [
|
||||||
u"Show All Due Cards",
|
_("Show All Due Cards"),
|
||||||
u"Show Chosen Categories"
|
_("Show Chosen Categories")
|
||||||
]
|
]
|
||||||
if self.deck.getVar("newActive") or self.deck.getVar("newInactive"):
|
if self.deck.getVar("newActive") or self.deck.getVar("newInactive"):
|
||||||
new = labels[1]
|
new = labels[1]
|
||||||
|
|
@ -2569,6 +2580,8 @@ This deck already exists on your computer. Overwrite the local copy?"""),
|
||||||
return os.path.join(dir, "plugins")
|
return os.path.join(dir, "plugins")
|
||||||
|
|
||||||
def loadPlugins(self):
|
def loadPlugins(self):
|
||||||
|
if self.appUpdated:
|
||||||
|
self.clearPluginCache()
|
||||||
plugdir = self.pluginsFolder()
|
plugdir = self.pluginsFolder()
|
||||||
sys.path.insert(0, plugdir)
|
sys.path.insert(0, plugdir)
|
||||||
plugins = self.enabledPlugins()
|
plugins = self.enabledPlugins()
|
||||||
|
|
@ -2584,6 +2597,15 @@ This deck already exists on your computer. Overwrite the local copy?"""),
|
||||||
self.checkForUpdatedPlugins()
|
self.checkForUpdatedPlugins()
|
||||||
self.disableCardMenuItems()
|
self.disableCardMenuItems()
|
||||||
|
|
||||||
|
def clearPluginCache(self):
|
||||||
|
"Clear .pyc files which may cause crashes if Python version updated."
|
||||||
|
dir = self.pluginsFolder()
|
||||||
|
for curdir, dirs, files in os.walk(dir):
|
||||||
|
for f in files:
|
||||||
|
if not f.endswith(".pyc"):
|
||||||
|
continue
|
||||||
|
os.unlink(os.path.join(curdir, f))
|
||||||
|
|
||||||
def rebuildPluginsMenu(self):
|
def rebuildPluginsMenu(self):
|
||||||
if getattr(self, "pluginActions", None) is None:
|
if getattr(self, "pluginActions", None) is None:
|
||||||
self.pluginActions = []
|
self.pluginActions = []
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue