This commit is contained in:
Kovid Goyal 2011-06-14 15:24:13 -06:00
parent 230cfe0877
commit 2af441e4fa
2 changed files with 15 additions and 9 deletions

View File

@ -12,7 +12,7 @@ from lxml import html
from PyQt4.Qt import (Qt, QUrl, QFrame, QVBoxLayout, QLabel, QBrush, QTextEdit, from PyQt4.Qt import (Qt, QUrl, QFrame, QVBoxLayout, QLabel, QBrush, QTextEdit,
QComboBox, QAbstractItemView, QHBoxLayout, QDialogButtonBox, QComboBox, QAbstractItemView, QHBoxLayout, QDialogButtonBox,
QAbstractTableModel, QVariant, QTableView, QModelIndex, QAbstractTableModel, QVariant, QTableView, QModelIndex,
QSortFilterProxyModel, pyqtSignal, QAction, QIcon, QDialog, QSortFilterProxyModel, QAction, QIcon, QDialog,
QFont, QPixmap, QSize) QFont, QPixmap, QSize)
from calibre import browser, prints from calibre import browser, prints
from calibre.constants import numeric_version, iswindows, isosx, DEBUG from calibre.constants import numeric_version, iswindows, isosx, DEBUG
@ -447,7 +447,6 @@ class DisplayPluginModel(QAbstractTableModel):
class PluginUpdaterDialog(SizePersistedDialog): class PluginUpdaterDialog(SizePersistedDialog):
update_found = pyqtSignal(object)
initial_extra_size = QSize(350, 100) initial_extra_size = QSize(350, 100)
def __init__(self, gui, initial_filter=FILTER_UPDATE_AVAILABLE): def __init__(self, gui, initial_filter=FILTER_UPDATE_AVAILABLE):
@ -587,7 +586,7 @@ class PluginUpdaterDialog(SizePersistedDialog):
# Force our toolbar/action to be updated based on uninstalled updates # Force our toolbar/action to be updated based on uninstalled updates
if self.model: if self.model:
update_plugins = filter(filter_upgradeable_plugins, self.model.display_plugins) update_plugins = filter(filter_upgradeable_plugins, self.model.display_plugins)
self.update_found.emit(update_plugins) self.gui.recalc_update_label(len(update_plugins))
self.reject() self.reject()
def _plugin_current_changed(self, current, previous): def _plugin_current_changed(self, current, previous):

View File

@ -122,19 +122,25 @@ class UpdateNotification(QDialog):
class UpdateMixin(object): class UpdateMixin(object):
def __init__(self, opts): def __init__(self, opts):
self.last_newest_calibre_version = NO_CALIBRE_UPDATE
if not opts.no_update_check: if not opts.no_update_check:
self.update_checker = CheckForUpdates(self) self.update_checker = CheckForUpdates(self)
self.update_checker.update_found.connect(self.update_found, self.update_checker.update_found.connect(self.update_found,
type=Qt.QueuedConnection) type=Qt.QueuedConnection)
self.update_checker.start() self.update_checker.start()
def update_found(self, version, force=False): def recalc_update_label(self, number_of_plugin_updates):
self.update_found('%s%s%d'%(self.last_newest_calibre_version, VSEP,
number_of_plugin_updates), no_show_popup=True)
def update_found(self, version, force=False, no_show_popup=False):
try: try:
calibre_version, plugin_updates = version.split(VSEP) calibre_version, plugin_updates = version.split(VSEP)
plugin_updates = int(plugin_updates) plugin_updates = int(plugin_updates)
except: except:
traceback.print_exc() traceback.print_exc()
return return
self.last_newest_calibre_version = calibre_version
has_calibre_update = calibre_version and calibre_version != NO_CALIBRE_UPDATE has_calibre_update = calibre_version and calibre_version != NO_CALIBRE_UPDATE
has_plugin_updates = plugin_updates > 0 has_plugin_updates = plugin_updates > 0
if not has_calibre_update and not has_plugin_updates: if not has_calibre_update and not has_plugin_updates:
@ -157,8 +163,9 @@ class UpdateMixin(object):
self.plugin_update_found(plugin_updates) self.plugin_update_found(plugin_updates)
if has_calibre_update: if has_calibre_update:
if force or (config.get('new_version_notification') and \ if (force or (config.get('new_version_notification') and
dynamic.get('update to version %s'%calibre_version, True)): dynamic.get('update to version %s'%calibre_version, True))):
if not no_show_popup:
self._update_notification__ = UpdateNotification(calibre_version, self._update_notification__ = UpdateNotification(calibre_version,
plugin_updates, parent=self) plugin_updates, parent=self)
self._update_notification__.show() self._update_notification__.show()