mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
bulk media updater
This commit is contained in:
parent
ff26b14e44
commit
0060dc553a
2 changed files with 38 additions and 1 deletions
|
@ -1093,6 +1093,9 @@ class AnkiQt(QMainWindow):
|
||||||
self.connect(self.syncThread, SIGNAL("syncClockOff"), self.syncClockOff)
|
self.connect(self.syncThread, SIGNAL("syncClockOff"), self.syncClockOff)
|
||||||
self.connect(self.syncThread, SIGNAL("cleanNewDeck"), self.cleanNewDeck)
|
self.connect(self.syncThread, SIGNAL("cleanNewDeck"), self.cleanNewDeck)
|
||||||
self.connect(self.syncThread, SIGNAL("syncFinished"), self.syncFinished)
|
self.connect(self.syncThread, SIGNAL("syncFinished"), self.syncFinished)
|
||||||
|
self.connect(self.syncThread, SIGNAL("openSyncProgress"), self.openSyncProgress)
|
||||||
|
self.connect(self.syncThread, SIGNAL("closeSyncProgress"), self.closeSyncProgress)
|
||||||
|
self.connect(self.syncThread, SIGNAL("updateSyncProgress"), self.updateSyncProgress)
|
||||||
self.syncThread.start()
|
self.syncThread.start()
|
||||||
self.setEnabled(False)
|
self.setEnabled(False)
|
||||||
while not self.syncThread.isFinished():
|
while not self.syncThread.isFinished():
|
||||||
|
@ -1149,6 +1152,23 @@ class AnkiQt(QMainWindow):
|
||||||
ui.utils.showWarning(text, self)
|
ui.utils.showWarning(text, self)
|
||||||
self.setStatus("")
|
self.setStatus("")
|
||||||
|
|
||||||
|
def openSyncProgress(self):
|
||||||
|
self.syncProgressDialog = QProgressDialog(_("Syncing Media.."),
|
||||||
|
"", 0, 0, self)
|
||||||
|
self.syncProgressDialog.setCancelButton(None)
|
||||||
|
|
||||||
|
def closeSyncProgress(self):
|
||||||
|
self.syncProgressDialog.cancel()
|
||||||
|
|
||||||
|
def updateSyncProgress(self, args):
|
||||||
|
(type, x, y, fname) = args
|
||||||
|
self.syncProgressDialog.setMaximum(y)
|
||||||
|
self.syncProgressDialog.setValue(x)
|
||||||
|
if type == "up":
|
||||||
|
self.syncProgressDialog.setLabelText("Uploading %s.." % fname)
|
||||||
|
else:
|
||||||
|
self.syncProgressDialog.setLabelText("Downloading %s.." % fname)
|
||||||
|
|
||||||
# Menu, title bar & status
|
# Menu, title bar & status
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ from PyQt4.QtCore import *
|
||||||
import os, types, socket, time, traceback
|
import os, types, socket, time, traceback
|
||||||
import ankiqt
|
import ankiqt
|
||||||
import anki
|
import anki
|
||||||
from anki.sync import SyncClient, HttpSyncServerProxy
|
from anki.sync import SyncClient, HttpSyncServerProxy, BulkMediaSyncerProxy
|
||||||
|
from anki.sync import BulkMediaSyncer
|
||||||
from anki.errors import *
|
from anki.errors import *
|
||||||
from anki import DeckStorage
|
from anki import DeckStorage
|
||||||
import ankiqt.forms
|
import ankiqt.forms
|
||||||
|
@ -107,6 +108,10 @@ class Sync(QThread):
|
||||||
# apply reply
|
# apply reply
|
||||||
self.setStatus(_("Applying reply.."), 0)
|
self.setStatus(_("Applying reply.."), 0)
|
||||||
client.applyPayloadReply(res)
|
client.applyPayloadReply(res)
|
||||||
|
# bulk update?
|
||||||
|
if not client.bundleMedia:
|
||||||
|
# need to load bulk media fetcher now
|
||||||
|
self.doBulkDownload()
|
||||||
# finished. save deck, preserving mod time
|
# finished. save deck, preserving mod time
|
||||||
self.setStatus(_("Sync complete."))
|
self.setStatus(_("Sync complete."))
|
||||||
self.deck.lastLoaded = self.deck.modified
|
self.deck.lastLoaded = self.deck.modified
|
||||||
|
@ -151,6 +156,18 @@ class Sync(QThread):
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
self.emit(SIGNAL("syncFinished"))
|
self.emit(SIGNAL("syncFinished"))
|
||||||
|
|
||||||
|
def doBulkDownload(self):
|
||||||
|
self.emit(SIGNAL("openSyncProgress"))
|
||||||
|
client = BulkMediaSyncer(self.deck)
|
||||||
|
client.server = BulkMediaSyncerProxy(self.user, self.pwd)
|
||||||
|
client.server.deckName = self.parent.syncName
|
||||||
|
client.progressCallback = self.bulkCallback
|
||||||
|
client.sync()
|
||||||
|
self.emit(SIGNAL("closeSyncProgress"))
|
||||||
|
|
||||||
|
def bulkCallback(self, *args):
|
||||||
|
self.emit(SIGNAL("updateSyncProgress"), args)
|
||||||
|
|
||||||
# Choosing a deck to sync to
|
# Choosing a deck to sync to
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue