add a 'safe mode' (#797)

This commit is contained in:
Damien Elmes 2013-05-17 15:32:17 +09:00
parent a492e95aed
commit 205c6d4c38
2 changed files with 9 additions and 2 deletions

View file

@ -26,6 +26,7 @@ class AddonManager(object):
if isWin: if isWin:
self.clearAddonCache() self.clearAddonCache()
sys.path.insert(0, self.addonsFolder()) sys.path.insert(0, self.addonsFolder())
if not self.mw.safeMode:
self.loadAddons() self.loadAddons()
def files(self): def files(self):

View file

@ -37,12 +37,17 @@ class AnkiQt(QMainWindow):
self.pm.meta['firstRun'] = False self.pm.meta['firstRun'] = False
self.pm.save() self.pm.save()
# init rest of app # init rest of app
self.safeMode = self.app.queryKeyboardModifiers() & Qt.ShiftModifier
try: try:
self.setupUI() self.setupUI()
self.setupAddons() self.setupAddons()
except: except:
showInfo(_("Error during startup:\n%s") % traceback.format_exc()) showInfo(_("Error during startup:\n%s") % traceback.format_exc())
sys.exit(1) 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? # were we given a file to import?
if args and args[0]: if args and args[0]:
self.onAppMsg(unicode(args[0], "utf8", "ignore")) self.onAppMsg(unicode(args[0], "utf8", "ignore"))
@ -536,7 +541,8 @@ title="%s">%s</button>''' % (
def onSync(self, auto=False, reload=True): def onSync(self, auto=False, reload=True):
if not auto or (self.pm.profile['syncKey'] and 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 from aqt.sync import SyncManager
if not self.unloadCollection(): if not self.unloadCollection():
return return