mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
show progress of deck/plugin download, don't process events
This commit is contained in:
parent
b014b53256
commit
5143da2132
3 changed files with 11 additions and 5 deletions
|
@ -189,6 +189,7 @@ class GetShared(QDialog):
|
|||
return QDialog.accept(self)
|
||||
h = QHttp(self)
|
||||
h.connect(h, SIGNAL("requestFinished(int,bool)"), self.onReqFin2)
|
||||
h.connect(h, SIGNAL("dataReadProgress(int,int)"), self.dataRead)
|
||||
h.connect(h, SIGNAL("proxyAuthenticationRequired(QNetworkProxy,"
|
||||
"QAuthenticator*)"),
|
||||
self.onProxyAuth)
|
||||
|
@ -199,6 +200,11 @@ class GetShared(QDialog):
|
|||
self.parent.setProgressParent(self)
|
||||
self.parent.startProgress()
|
||||
|
||||
def dataRead(self, done, total):
|
||||
self.parent.updateProgress(label=_("Downloaded %dKB") %
|
||||
(done/1024),
|
||||
process=False)
|
||||
|
||||
def onReqFin2(self, id, err):
|
||||
"File fetched."
|
||||
if id != self.conId:
|
||||
|
|
|
@ -2482,12 +2482,11 @@ Couldn't contact Anki Online. Please check your internet connection.""")
|
|||
p = ui.utils.ProgressWin(parent, max, min, title)
|
||||
self.progressWins.append(p)
|
||||
|
||||
def updateProgress(self, label=None, value=None):
|
||||
def updateProgress(self, label=None, value=None, process=True):
|
||||
if self.mainThread != QThread.currentThread():
|
||||
return
|
||||
if self.progressWins:
|
||||
self.progressWins[-1].update(label, value)
|
||||
self.app.processEvents()
|
||||
self.progressWins[-1].update(label, value, process)
|
||||
|
||||
def finishProgress(self):
|
||||
if self.mainThread != QThread.currentThread():
|
||||
|
|
|
@ -222,7 +222,7 @@ class ProgressWin(object):
|
|||
if max == 0:
|
||||
self.diag.setLabelText(_("Processing..."))
|
||||
|
||||
def update(self, label=None, value=None):
|
||||
def update(self, label=None, value=None, process=True):
|
||||
#print self.min, self.counter, self.max, label, time.time() - self.lastTime
|
||||
self.lastTime = time.time()
|
||||
if label:
|
||||
|
@ -233,7 +233,8 @@ class ProgressWin(object):
|
|||
else:
|
||||
self.counter = value + 1
|
||||
self.diag.setValue(value)
|
||||
self.app.processEvents()
|
||||
if process:
|
||||
self.app.processEvents()
|
||||
|
||||
def finish(self):
|
||||
if self.max:
|
||||
|
|
Loading…
Reference in a new issue