From 681c8dea9f91668646cc4aac4fa51b6a6c1fc47c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 8 Dec 2011 00:31:04 +0900 Subject: [PATCH] add autosync flag, make sure we close col windows on sync --- aqt/main.py | 19 ++++++++++++------- aqt/profiles.py | 1 + aqt/sync.py | 7 +------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/aqt/main.py b/aqt/main.py index 065300ed4..fedc05e52 100755 --- a/aqt/main.py +++ b/aqt/main.py @@ -456,14 +456,19 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors") ########################################################################## def onSync(self, auto=False, reload=True): - from aqt.sync import SyncManager - # close collection if loaded - if self.col: - self.col.close() - self.syncer = SyncManager(self, self.pm) - self.syncer.sync(auto) + if not auto or (self.pm.profile['syncKey'] and + self.pm.profile['autoSync']): + self.closeAllCollectionWindows() + from aqt.sync import SyncManager + # close collection if loaded + if self.col: + self.col.close() + self.col = None + self.syncer = SyncManager(self, self.pm) + self.syncer.sync() if reload: - self.loadCollection() + if not self.col: + self.loadCollection() def loadCollection(self): self.col = Collection(self.pm.collectionPath()) diff --git a/aqt/profiles.py b/aqt/profiles.py index 2a4c52e30..db5c30b42 100644 --- a/aqt/profiles.py +++ b/aqt/profiles.py @@ -52,6 +52,7 @@ profileConf = dict( # syncing syncKey=None, syncMedia=True, + autoSync=True, proxyHost='', proxyPass='', proxyPort=8080, diff --git a/aqt/sync.py b/aqt/sync.py index 31ddc648b..caab82995 100755 --- a/aqt/sync.py +++ b/aqt/sync.py @@ -13,9 +13,6 @@ from aqt.utils import tooltip, askUserDialog, showWarning # Sync manager ###################################################################### -# are we doing this in main? -# self.closeAllDeckWindows() - class SyncManager(QObject): def __init__(self, mw, pm): @@ -23,10 +20,8 @@ class SyncManager(QObject): self.mw = mw self.pm = pm - def sync(self, auto=False): + def sync(self): if not self.pm.profile['syncKey']: - if auto: - return auth = self._getUserPass() if not auth: return