mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
tweak update code
- support for message pushing - remove changelog from update message, as the path was wrong, and the changelog is mentioned in the download area instead
This commit is contained in:
parent
ffb28df83b
commit
3c5aaecd14
3 changed files with 16 additions and 7 deletions
|
@ -63,6 +63,7 @@ class Config(dict):
|
|||
'iconSize': 32,
|
||||
'id': genID(),
|
||||
'interfaceLang': "",
|
||||
'lastMsg': -1,
|
||||
'loadLastDeck': False,
|
||||
'mainWindowGeom': None,
|
||||
'mainWindowState': None,
|
||||
|
|
|
@ -2621,12 +2621,16 @@ This deck already exists on your computer. Overwrite the local copy?"""),
|
|||
def setupAutoUpdate(self):
|
||||
self.autoUpdate = ui.update.LatestVersionFinder(self)
|
||||
self.connect(self.autoUpdate, SIGNAL("newVerAvail"), self.newVerAvail)
|
||||
self.connect(self.autoUpdate, SIGNAL("newMsg"), self.newMsg)
|
||||
self.connect(self.autoUpdate, SIGNAL("clockIsOff"), self.clockIsOff)
|
||||
self.autoUpdate.start()
|
||||
|
||||
def newVerAvail(self, version):
|
||||
if self.config['suppressUpdate'] < version['latestVersion']:
|
||||
ui.update.askAndUpdate(self, version)
|
||||
def newVerAvail(self, data):
|
||||
if self.config['suppressUpdate'] < data['latestVersion']:
|
||||
ui.update.askAndUpdate(self, data)
|
||||
|
||||
def newMsg(self, data):
|
||||
ui.update.showMessages(self, data)
|
||||
|
||||
def clockIsOff(self, diff):
|
||||
if diff < 0:
|
||||
|
|
|
@ -23,6 +23,7 @@ class LatestVersionFinder(QThread):
|
|||
"pver": pver,
|
||||
"plat": plat,
|
||||
"id": self.config['id'],
|
||||
"lm": self.config['lastMsg'],
|
||||
"conf": self.config['created']}
|
||||
self.stats = d
|
||||
|
||||
|
@ -41,6 +42,8 @@ class LatestVersionFinder(QThread):
|
|||
except:
|
||||
# behind proxy, corrupt message, etc
|
||||
return
|
||||
if resp['msg']:
|
||||
self.emit(SIGNAL("newMsg"), resp)
|
||||
if resp['latestVersion'] > ankiqt.appVersion:
|
||||
self.emit(SIGNAL("newVerAvail"), resp)
|
||||
diff = resp['currentTime'] - time.time()
|
||||
|
@ -51,10 +54,7 @@ class LatestVersionFinder(QThread):
|
|||
def askAndUpdate(parent, version=None):
|
||||
version = version['latestVersion']
|
||||
baseStr = (
|
||||
_('''<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>''') %
|
||||
_('''<h1>Anki Updated</h1>Anki %s has been released.<br><br>''') %
|
||||
version)
|
||||
msg = QMessageBox(parent)
|
||||
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
|
||||
|
@ -68,3 +68,7 @@ The release notes are
|
|||
parent.config['suppressUpdate'] = version
|
||||
elif ret == QMessageBox.Yes:
|
||||
QDesktopServices.openUrl(QUrl(ankiqt.appWebsite))
|
||||
|
||||
def showMessages(main, data):
|
||||
ankiqt.ui.utils.showText(data['msg'], main, type="html")
|
||||
main.config['lastMsg'] = data['msgId']
|
||||
|
|
Loading…
Reference in a new issue