diff --git a/ankiqt/ui/getshared.py b/ankiqt/ui/getshared.py index 992623560..e259afddc 100644 --- a/ankiqt/ui/getshared.py +++ b/ankiqt/ui/getshared.py @@ -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: diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 0998c6cd3..2b7dcfe06 100755 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -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(): diff --git a/ankiqt/ui/utils.py b/ankiqt/ui/utils.py index 44ed50ba5..5139f5202 100644 --- a/ankiqt/ui/utils.py +++ b/ankiqt/ui/utils.py @@ -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: