mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement #4040 (Periodic check for updates)
This commit is contained in:
parent
2fdc5b946c
commit
2d41520783
@ -221,10 +221,10 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.vanity.setText(self.vanity_template%dict(version=' ', device=' '))
|
||||
self.device_info = ' '
|
||||
if not opts.no_update_check:
|
||||
self.update_checker = CheckForUpdates()
|
||||
self.update_checker = CheckForUpdates(self)
|
||||
QObject.connect(self.update_checker,
|
||||
SIGNAL('update_found(PyQt_PyObject)'), self.update_found)
|
||||
self.update_checker.start()
|
||||
self.update_checker.start(2000)
|
||||
####################### Status Bar #####################
|
||||
self.status_bar = StatusBar(self.jobs_dialog, self.system_tray_icon)
|
||||
self.setStatusBar(self.status_bar)
|
||||
@ -1755,6 +1755,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
if write_settings:
|
||||
self.write_settings()
|
||||
self.check_messages_timer.stop()
|
||||
self.update_checker.stop()
|
||||
self.listener.close()
|
||||
self.job_manager.server.close()
|
||||
while self.spare_servers:
|
||||
|
@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import traceback
|
||||
|
||||
from PyQt4.QtCore import QThread, SIGNAL
|
||||
from PyQt4.QtCore import QObject, SIGNAL, QTimer
|
||||
import mechanize
|
||||
|
||||
from calibre.constants import __version__, iswindows, isosx
|
||||
@ -11,9 +11,21 @@ from calibre import browser
|
||||
|
||||
URL = 'http://status.calibre-ebook.com/latest'
|
||||
|
||||
class CheckForUpdates(QThread):
|
||||
class CheckForUpdates(QObject):
|
||||
|
||||
def __init__(self, parent):
|
||||
QObject.__init__(self, parent)
|
||||
self.timer = QTimer(self)
|
||||
self.first = True
|
||||
self.connect(self.timer, SIGNAL('timeout()'), self)
|
||||
self.start = self.timer.start
|
||||
self.stop = self.timer.stop
|
||||
|
||||
def __call__(self):
|
||||
if self.first:
|
||||
self.timer.setInterval(1000*24*60*60)
|
||||
self.first = False
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
br = browser()
|
||||
req = mechanize.Request(URL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user