mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-24 09:50:23 +00:00
Added update check to GUI.
This commit is contained in:
parent
74ccd2838b
commit
25ee6d0980
5 changed files with 50 additions and 8 deletions
|
|
@ -4,6 +4,9 @@ Changes:
|
|||
- checking: Parse PHP files recursively.
|
||||
- gui: Remove reset button from option dialog.
|
||||
|
||||
Features:
|
||||
- gui: Add update check for newer versions of LinkChecker.
|
||||
|
||||
|
||||
6.1 "Christmas Vacation" (released 23.12.2010)
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ from .urlmodel import UrlItemModel
|
|||
from .urlsave import urlsave
|
||||
from .settings import Settings
|
||||
from .. import configuration, checker, director, add_intern_pattern, \
|
||||
strformat, fileutil
|
||||
strformat, fileutil, updater
|
||||
from ..containers import enum
|
||||
from .. import url as urlutil
|
||||
from ..checker import httpheaders
|
||||
|
|
@ -233,6 +233,34 @@ to improve %(appname)s even more!
|
|||
"""Quit application."""
|
||||
urlsave(self, self.config, self.model.urls)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def on_actionCheckUpdates_triggered (self):
|
||||
"""Display update check result."""
|
||||
title = _('%(app)s update information') % dict(app=configuration.App)
|
||||
# XXX check for update in background thread
|
||||
result, value = updater.check_update()
|
||||
if result:
|
||||
dialog = QtGui.QMessageBox.information
|
||||
if value is None:
|
||||
# no update available: display info
|
||||
text = _('Congratulations: you have the latest version '
|
||||
'%(app)s installed.')
|
||||
attrs = dict(app=configuration.App)
|
||||
else:
|
||||
# display update link
|
||||
version, url = 'hulla', 'bulla'
|
||||
text = _('A new version %(version)s of %(app)s is '
|
||||
'available for <a href="%(url)s">download</a>.')
|
||||
attrs = dict(version=version, app=configuration.AppName,
|
||||
url=url)
|
||||
else:
|
||||
# value is an error message
|
||||
dialog = QtGui.QMessageBox.warning
|
||||
text = _('An error occured while checking for an '
|
||||
'update of %(app)s: %(error)s.')
|
||||
attrs = dict(error=value, app=configuration.AppName)
|
||||
dialog(self, title, text % attrs)
|
||||
|
||||
def start (self):
|
||||
"""Start a new check."""
|
||||
if self.status == Status.idle:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Form implementation generated from reading ui file 'ui/main.ui'
|
||||
#
|
||||
# Created: Sat Dec 18 08:03:50 2010
|
||||
# Created: Tue Jan 4 19:19:45 2011
|
||||
# by: PyQt4 UI code generator 4.7.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
|
@ -677,12 +677,15 @@ class Ui_MainWindow(object):
|
|||
icon8.addPixmap(QtGui.QPixmap(":/icons/exit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.actionQuit.setIcon(icon8)
|
||||
self.actionQuit.setObjectName("actionQuit")
|
||||
self.actionCheckUpdates = QtGui.QAction(MainWindow)
|
||||
self.actionCheckUpdates.setObjectName("actionCheckUpdates")
|
||||
self.menuEdit.addAction(self.actionOptions)
|
||||
self.menuLinkChecka.addAction(self.actionSave)
|
||||
self.menuLinkChecka.addAction(self.actionQuit)
|
||||
self.menuHelp.addAction(self.actionAbout)
|
||||
self.menuHelp.addAction(self.actionHelp)
|
||||
self.menuHelp.addAction(self.actionDebug)
|
||||
self.menuHelp.addAction(self.actionCheckUpdates)
|
||||
self.menubar.addAction(self.menuLinkChecka.menuAction())
|
||||
self.menubar.addAction(self.menuEdit.menuAction())
|
||||
self.menubar.addAction(self.menuHelp.menuAction())
|
||||
|
|
@ -746,6 +749,7 @@ class Ui_MainWindow(object):
|
|||
self.actionSave.setShortcut(_("Ctrl+S"))
|
||||
self.actionQuit.setText(_("Quit"))
|
||||
self.actionQuit.setShortcut(_("Ctrl+Q"))
|
||||
self.actionCheckUpdates.setText(_("Check for updates"))
|
||||
|
||||
from lineedit import LineEdit
|
||||
import linkchecker_rc
|
||||
|
|
|
|||
|
|
@ -1292,6 +1292,7 @@
|
|||
<addaction name="actionAbout"/>
|
||||
<addaction name="actionHelp"/>
|
||||
<addaction name="actionDebug"/>
|
||||
<addaction name="actionCheckUpdates"/>
|
||||
</widget>
|
||||
<addaction name="menuLinkChecka"/>
|
||||
<addaction name="menuEdit"/>
|
||||
|
|
@ -1413,6 +1414,11 @@
|
|||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCheckUpdates">
|
||||
<property name="text">
|
||||
<string>Check for updates</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
|||
|
|
@ -34,14 +34,15 @@ else:
|
|||
|
||||
|
||||
def check_update ():
|
||||
"""Return URL of new version, None if there is no update, or
|
||||
"""Return new version and URL, None if there is no update, or
|
||||
an error message if there was an error."""
|
||||
version, url = get_current_version()
|
||||
print "XXX", version, url
|
||||
version, value = get_current_version()
|
||||
if version is None:
|
||||
return False, url
|
||||
# value is an error message
|
||||
return False, value
|
||||
if is_newer_version(version):
|
||||
return True, url
|
||||
# value is an URL linking to the update package
|
||||
return True, (version, value)
|
||||
return True, None
|
||||
|
||||
|
||||
|
|
@ -49,7 +50,7 @@ def get_current_version ():
|
|||
"""Download update info and parse it."""
|
||||
info, content = get_content(UPDATE_URL)
|
||||
if info is None:
|
||||
None, _('Could not check for updates.')
|
||||
None, _('could not download update information')
|
||||
version, url = None, None
|
||||
for line in content.splitlines():
|
||||
if line.startswith(VERSION_TAG):
|
||||
|
|
|
|||
Loading…
Reference in a new issue