diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index fe84ff040..b073d84cf 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -1346,6 +1346,20 @@ class AnkiQt(QMainWindow): "type": ret } ) + def updateStarted(self): + self.updateProgressDialog = QProgressDialog(_( + "Updating Anki..\n(you can keep studying)"), "", 0, 0, self) + self.updateProgressDialog.setMinimum(0) + self.updateProgressDialog.setMaximum(100) + self.updateProgressDialog.setCancelButton(None) + self.updateProgressDialog.setMinimumDuration(0) + + def updateDownloading(self, perc): + self.updateProgressDialog.setValue(perc) + + def updateFinished(self): + self.updateProgressDialog.cancel() + # Plugins ########################################################################## diff --git a/ankiqt/ui/update.py b/ankiqt/ui/update.py index fa0203d1d..722e1e159 100644 --- a/ankiqt/ui/update.py +++ b/ankiqt/ui/update.py @@ -85,8 +85,8 @@ class Updater(QThread): filename = "anki-update.exe" # FIXME: get when checking version number - chunkSize = 428027 - percChange = 5 + chunkSize = 131018 + percChange = 1 def __init__(self): QThread.__init__(self) @@ -109,9 +109,9 @@ class Updater(QThread): self.setStatus(_("Unable to open file")) return perc = 0 + self.emit(SIGNAL("updateStarted"), perc) while 1: - self.setStatus( - _("Downloading anki updater - %d%% complete.") % perc) + self.emit(SIGNAL("updateDownloading"), perc) resp = f.read(self.chunkSize) if not resp: break @@ -120,7 +120,7 @@ class Updater(QThread): if perc > 99: perc = 99 newfile.close() - self.setStatus(_("Updating..")) + self.emit(SIGNAL("updateFinished"), perc) os.chdir(os.path.dirname(filename)) os.system(os.path.basename(filename)) self.setStatus(_("Update complete. Please restart Anki.")) @@ -129,10 +129,10 @@ class Updater(QThread): def askAndUpdate(parent, version=None): version = version['latestVersion'] baseStr = ( - _("""

Anki updated

Anki %s has been released.
+ _('''

Anki updated

Anki %s has been released.
The release notes are here. -

""") % +

''') % version) msg = QMessageBox(parent) msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) @@ -150,6 +150,15 @@ The release notes are parent.connect(parent.autoUpdate, SIGNAL("statusChanged"), parent.setStatus) + parent.connect(parent.autoUpdate, + SIGNAL("updateStarted"), + parent.updateStarted) + parent.connect(parent.autoUpdate, + SIGNAL("updateDownloading"), + parent.updateDownloading) + parent.connect(parent.autoUpdate, + SIGNAL("updateFinished"), + parent.updateFinished) parent.autoUpdate.start() else: QDesktopServices.openUrl(QUrl(ankiqt.appWebsite))