mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 14:17:13 -05:00
progress for import, export, everything else
This commit is contained in:
parent
2e2e756436
commit
ad159aec86
4 changed files with 37 additions and 14 deletions
|
|
@ -52,6 +52,7 @@ class ExportDialog(QDialog):
|
||||||
def accept(self):
|
def accept(self):
|
||||||
file = ui.utils.getSaveFile(self, _("Choose file to export to"), "export",
|
file = ui.utils.getSaveFile(self, _("Choose file to export to"), "export",
|
||||||
self.exporter.key, self.exporter.ext)
|
self.exporter.key, self.exporter.ext)
|
||||||
|
self.hide()
|
||||||
if file:
|
if file:
|
||||||
self.exporter.includeSchedulingInfo = (
|
self.exporter.includeSchedulingInfo = (
|
||||||
self.dialog.includeScheduling.isChecked())
|
self.dialog.includeScheduling.isChecked())
|
||||||
|
|
|
||||||
|
|
@ -106,13 +106,8 @@ class ImportDialog(QDialog):
|
||||||
self.maybePreview()
|
self.maybePreview()
|
||||||
|
|
||||||
def doImport(self):
|
def doImport(self):
|
||||||
self.dialog.status.setText(_("Importing. Anki will freeze for a while.."))
|
self.dialog.status.setText(_("Importing..."))
|
||||||
t = time.time()
|
t = time.time()
|
||||||
while self.parent.app.hasPendingEvents():
|
|
||||||
self.parent.app.processEvents()
|
|
||||||
if time.time() - t > 1:
|
|
||||||
# windows sometimes has pending events permanently?
|
|
||||||
break
|
|
||||||
self.importer.mapping = self.mapping
|
self.importer.mapping = self.mapping
|
||||||
self.importer.tagsToAdd = unicode(self.tags.text())
|
self.importer.tagsToAdd = unicode(self.tags.text())
|
||||||
self.importer.tagDuplicates = self.dialog.tagDuplicates.isChecked()
|
self.importer.tagDuplicates = self.dialog.tagDuplicates.isChecked()
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ class AnkiQt(QMainWindow):
|
||||||
self.setupButtons()
|
self.setupButtons()
|
||||||
self.setupAnchors()
|
self.setupAnchors()
|
||||||
self.setupToolbar()
|
self.setupToolbar()
|
||||||
|
self.setupProgressInfo()
|
||||||
self.show()
|
self.show()
|
||||||
if sys.platform.startswith("darwin"):
|
if sys.platform.startswith("darwin"):
|
||||||
self.setUnifiedTitleAndToolBarOnMac(True)
|
self.setUnifiedTitleAndToolBarOnMac(True)
|
||||||
|
|
@ -1407,7 +1408,6 @@ day = :d""", d=yesterday)
|
||||||
p.update()
|
p.update()
|
||||||
self.deck.s.statement(
|
self.deck.s.statement(
|
||||||
"update fields set factId = (select new from idmap where old = factId)")
|
"update fields set factId = (select new from idmap where old = factId)")
|
||||||
p.update()
|
|
||||||
self.reset()
|
self.reset()
|
||||||
p.finish()
|
p.finish()
|
||||||
|
|
||||||
|
|
@ -1929,6 +1929,25 @@ day = :d""", d=yesterday)
|
||||||
if self.state != "showQuestion":
|
if self.state != "showQuestion":
|
||||||
playFromText(self.currentCard.answer)
|
playFromText(self.currentCard.answer)
|
||||||
|
|
||||||
|
# Progress info
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
def setupProgressInfo(self):
|
||||||
|
addHook("startProgress", self.onStartProgress)
|
||||||
|
addHook("updateProgress", self.onUpdateProgress)
|
||||||
|
addHook("finishProgress", self.onFinishProgress)
|
||||||
|
|
||||||
|
def onStartProgress(self, title, min, max):
|
||||||
|
self.progressWin = ui.utils.ProgressWin(self.app.activeWindow() or self,
|
||||||
|
title, min, max)
|
||||||
|
|
||||||
|
def onUpdateProgress(self, label=None, value=None):
|
||||||
|
self.progressWin.update(label, value)
|
||||||
|
|
||||||
|
def onFinishProgress(self):
|
||||||
|
self.progressWin.finish()
|
||||||
|
self.progressWin = None
|
||||||
|
|
||||||
# Advanced features
|
# Advanced features
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from anki.sound import playFromText, stripSounds
|
||||||
from anki.latex import renderLatex, stripLatex
|
from anki.latex import renderLatex, stripLatex
|
||||||
from ankiqt import ui
|
from ankiqt import ui
|
||||||
|
|
||||||
import re, os, sys, urllib
|
import re, os, sys, urllib, time
|
||||||
import ankiqt
|
import ankiqt
|
||||||
|
|
||||||
def openLink(link):
|
def openLink(link):
|
||||||
|
|
@ -197,19 +197,27 @@ class ProgressWin(object):
|
||||||
self.diag.setMinimumDuration(0)
|
self.diag.setMinimumDuration(0)
|
||||||
self.diag.show()
|
self.diag.show()
|
||||||
self.counter = min
|
self.counter = min
|
||||||
self.app = QApplication.instance()
|
|
||||||
self.app.processEvents()
|
|
||||||
self.min = min
|
self.min = min
|
||||||
self.max = max
|
self.max = max
|
||||||
|
self.lastTime = time.time()
|
||||||
|
self.app = QApplication.instance()
|
||||||
|
self.app.processEvents()
|
||||||
|
|
||||||
def update(self, label=None, val=None):
|
def update(self, label=None, value=None):
|
||||||
|
self.app.processEvents()
|
||||||
|
print self.min, self.counter, self.max, label, time.time() - self.lastTime
|
||||||
|
self.lastTime = time.time()
|
||||||
if label:
|
if label:
|
||||||
self.diag.setLabelText(label)
|
self.diag.setLabelText(label)
|
||||||
if val is None:
|
if value is None:
|
||||||
val = self.counter
|
value = self.counter
|
||||||
self.counter += 1
|
self.counter += 1
|
||||||
self.diag.setValue(val)
|
else:
|
||||||
|
self.counter = value + 1
|
||||||
|
self.diag.setValue(value)
|
||||||
self.app.processEvents()
|
self.app.processEvents()
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
|
self.diag.setValue(self.max)
|
||||||
|
self.app.processEvents()
|
||||||
self.diag.cancel()
|
self.diag.cancel()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue