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,13 +456,18 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
##########################################################################
def onSync(self, auto=False, reload=True):
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(auto)
self.syncer.sync()
if reload:
if not self.col:
self.loadCollection()
def loadCollection(self):

View file

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

View file

@ -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