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)
|
return QDialog.accept(self)
|
||||||
h = QHttp(self)
|
h = QHttp(self)
|
||||||
h.connect(h, SIGNAL("requestFinished(int,bool)"), self.onReqFin2)
|
h.connect(h, SIGNAL("requestFinished(int,bool)"), self.onReqFin2)
|
||||||
|
h.connect(h, SIGNAL("dataReadProgress(int,int)"), self.dataRead)
|
||||||
h.connect(h, SIGNAL("proxyAuthenticationRequired(QNetworkProxy,"
|
h.connect(h, SIGNAL("proxyAuthenticationRequired(QNetworkProxy,"
|
||||||
"QAuthenticator*)"),
|
"QAuthenticator*)"),
|
||||||
self.onProxyAuth)
|
self.onProxyAuth)
|
||||||
|
@ -199,6 +200,11 @@ class GetShared(QDialog):
|
||||||
self.parent.setProgressParent(self)
|
self.parent.setProgressParent(self)
|
||||||
self.parent.startProgress()
|
self.parent.startProgress()
|
||||||
|
|
||||||
|
def dataRead(self, done, total):
|
||||||
|
self.parent.updateProgress(label=_("Downloaded %dKB") %
|
||||||
|
(done/1024),
|
||||||
|
process=False)
|
||||||
|
|
||||||
def onReqFin2(self, id, err):
|
def onReqFin2(self, id, err):
|
||||||
"File fetched."
|
"File fetched."
|
||||||
if id != self.conId:
|
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)
|
p = ui.utils.ProgressWin(parent, max, min, title)
|
||||||
self.progressWins.append(p)
|
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():
|
if self.mainThread != QThread.currentThread():
|
||||||
return
|
return
|
||||||
if self.progressWins:
|
if self.progressWins:
|
||||||
self.progressWins[-1].update(label, value)
|
self.progressWins[-1].update(label, value, process)
|
||||||
self.app.processEvents()
|
|
||||||
|
|
||||||
def finishProgress(self):
|
def finishProgress(self):
|
||||||
if self.mainThread != QThread.currentThread():
|
if self.mainThread != QThread.currentThread():
|
||||||
|
|
|
@ -222,7 +222,7 @@ class ProgressWin(object):
|
||||||
if max == 0:
|
if max == 0:
|
||||||
self.diag.setLabelText(_("Processing..."))
|
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
|
#print self.min, self.counter, self.max, label, time.time() - self.lastTime
|
||||||
self.lastTime = time.time()
|
self.lastTime = time.time()
|
||||||
if label:
|
if label:
|
||||||
|
@ -233,7 +233,8 @@ class ProgressWin(object):
|
||||||
else:
|
else:
|
||||||
self.counter = value + 1
|
self.counter = value + 1
|
||||||
self.diag.setValue(value)
|
self.diag.setValue(value)
|
||||||
self.app.processEvents()
|
if process:
|
||||||
|
self.app.processEvents()
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
if self.max:
|
if self.max:
|
||||||
|
|
Loading…
Reference in a new issue