mirror of
https://github.com/ankitects/anki.git
synced 2025-12-15 15:50:59 -05:00
new updater
This commit is contained in:
parent
8c0c4a5c39
commit
ab20511bab
2 changed files with 30 additions and 7 deletions
|
|
@ -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
|
||||
##########################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = (
|
||||
_("""<h1>Anki updated</h1>Anki %s has been released.<br>
|
||||
_('''<h1>Anki updated</h1>Anki %s has been released.<br>
|
||||
The release notes are
|
||||
<a href="http://ichi2.net/anki/download/index.html#changes">here</a>.
|
||||
<br><br>""") %
|
||||
<br><br>''') %
|
||||
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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue