mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 07:07:13 -05:00
add autosync flag, make sure we close col windows on sync
This commit is contained in:
parent
58433be7b4
commit
681c8dea9f
3 changed files with 14 additions and 13 deletions
19
aqt/main.py
19
aqt/main.py
|
|
@ -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())
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue