mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 15:17:12 -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):
|
||||
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())
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ profileConf = dict(
|
|||
# syncing
|
||||
syncKey=None,
|
||||
syncMedia=True,
|
||||
autoSync=True,
|
||||
proxyHost='',
|
||||
proxyPass='',
|
||||
proxyPort=8080,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue