add autosync flag, make sure we close col windows on sync

This commit is contained in:
Damien Elmes 2011-12-08 00:31:04 +09:00
parent 58433be7b4
commit 681c8dea9f
3 changed files with 14 additions and 13 deletions

View file

@ -456,14 +456,19 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
########################################################################## ##########################################################################
def onSync(self, auto=False, reload=True): def onSync(self, auto=False, reload=True):
from aqt.sync import SyncManager if not auto or (self.pm.profile['syncKey'] and
# close collection if loaded self.pm.profile['autoSync']):
if self.col: self.closeAllCollectionWindows()
self.col.close() from aqt.sync import SyncManager
self.syncer = SyncManager(self, self.pm) # close collection if loaded
self.syncer.sync(auto) if self.col:
self.col.close()
self.col = None
self.syncer = SyncManager(self, self.pm)
self.syncer.sync()
if reload: if reload:
self.loadCollection() if not self.col:
self.loadCollection()
def loadCollection(self): def loadCollection(self):
self.col = Collection(self.pm.collectionPath()) self.col = Collection(self.pm.collectionPath())

View file

@ -52,6 +52,7 @@ profileConf = dict(
# syncing # syncing
syncKey=None, syncKey=None,
syncMedia=True, syncMedia=True,
autoSync=True,
proxyHost='', proxyHost='',
proxyPass='', proxyPass='',
proxyPort=8080, proxyPort=8080,

View file

@ -13,9 +13,6 @@ from aqt.utils import tooltip, askUserDialog, showWarning
# Sync manager # Sync manager
###################################################################### ######################################################################
# are we doing this in main?
# self.closeAllDeckWindows()
class SyncManager(QObject): class SyncManager(QObject):
def __init__(self, mw, pm): def __init__(self, mw, pm):
@ -23,10 +20,8 @@ class SyncManager(QObject):
self.mw = mw self.mw = mw
self.pm = pm self.pm = pm
def sync(self, auto=False): def sync(self):
if not self.pm.profile['syncKey']: if not self.pm.profile['syncKey']:
if auto:
return
auth = self._getUserPass() auth = self._getUserPass()
if not auth: if not auth:
return return