From 205c6d4c38d0755266062ee0fa7f1a61de0c511c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 17 May 2013 15:32:17 +0900 Subject: [PATCH] add a 'safe mode' (#797) --- aqt/addons.py | 3 ++- aqt/main.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/aqt/addons.py b/aqt/addons.py index f7941c5ec..4e8f6cd7a 100644 --- a/aqt/addons.py +++ b/aqt/addons.py @@ -26,7 +26,8 @@ class AddonManager(object): if isWin: self.clearAddonCache() sys.path.insert(0, self.addonsFolder()) - self.loadAddons() + if not self.mw.safeMode: + self.loadAddons() def files(self): return [f for f in os.listdir(self.addonsFolder()) diff --git a/aqt/main.py b/aqt/main.py index a0d86e8bd..a75eec180 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -37,12 +37,17 @@ class AnkiQt(QMainWindow): self.pm.meta['firstRun'] = False self.pm.save() # init rest of app + self.safeMode = self.app.queryKeyboardModifiers() & Qt.ShiftModifier try: self.setupUI() self.setupAddons() except: showInfo(_("Error during startup:\n%s") % traceback.format_exc()) sys.exit(1) + # must call this after ui set up + if self.safeMode: + tooltip(_("Shift key was held down. Skipping automatic " + "syncing and add-on loading.")) # were we given a file to import? if args and args[0]: self.onAppMsg(unicode(args[0], "utf8", "ignore")) @@ -536,7 +541,8 @@ title="%s">%s''' % ( def onSync(self, auto=False, reload=True): if not auto or (self.pm.profile['syncKey'] and - self.pm.profile['autoSync']): + self.pm.profile['autoSync'] and + not self.safeMode): from aqt.sync import SyncManager if not self.unloadCollection(): return