From 2af441e4fad1b647cb4d64c18c51c6bcd36aa0f8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 14 Jun 2011 15:24:13 -0600 Subject: [PATCH] ... --- src/calibre/gui2/dialogs/plugin_updater.py | 5 ++--- src/calibre/gui2/update.py | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/calibre/gui2/dialogs/plugin_updater.py b/src/calibre/gui2/dialogs/plugin_updater.py index 855dbd148a..e7d641b43e 100644 --- a/src/calibre/gui2/dialogs/plugin_updater.py +++ b/src/calibre/gui2/dialogs/plugin_updater.py @@ -12,7 +12,7 @@ from lxml import html from PyQt4.Qt import (Qt, QUrl, QFrame, QVBoxLayout, QLabel, QBrush, QTextEdit, QComboBox, QAbstractItemView, QHBoxLayout, QDialogButtonBox, QAbstractTableModel, QVariant, QTableView, QModelIndex, - QSortFilterProxyModel, pyqtSignal, QAction, QIcon, QDialog, + QSortFilterProxyModel, QAction, QIcon, QDialog, QFont, QPixmap, QSize) from calibre import browser, prints from calibre.constants import numeric_version, iswindows, isosx, DEBUG @@ -447,7 +447,6 @@ class DisplayPluginModel(QAbstractTableModel): class PluginUpdaterDialog(SizePersistedDialog): - update_found = pyqtSignal(object) initial_extra_size = QSize(350, 100) 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 if self.model: 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() def _plugin_current_changed(self, current, previous): diff --git a/src/calibre/gui2/update.py b/src/calibre/gui2/update.py index ed159f4778..b246c4a3b1 100644 --- a/src/calibre/gui2/update.py +++ b/src/calibre/gui2/update.py @@ -122,19 +122,25 @@ class UpdateNotification(QDialog): class UpdateMixin(object): def __init__(self, opts): + self.last_newest_calibre_version = NO_CALIBRE_UPDATE if not opts.no_update_check: self.update_checker = CheckForUpdates(self) self.update_checker.update_found.connect(self.update_found, type=Qt.QueuedConnection) 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: calibre_version, plugin_updates = version.split(VSEP) plugin_updates = int(plugin_updates) except: traceback.print_exc() return + self.last_newest_calibre_version = calibre_version has_calibre_update = calibre_version and calibre_version != NO_CALIBRE_UPDATE has_plugin_updates = plugin_updates > 0 if not has_calibre_update and not has_plugin_updates: @@ -157,11 +163,12 @@ class UpdateMixin(object): self.plugin_update_found(plugin_updates) if has_calibre_update: - if force or (config.get('new_version_notification') and \ - dynamic.get('update to version %s'%calibre_version, True)): - self._update_notification__ = UpdateNotification(calibre_version, - plugin_updates, parent=self) - self._update_notification__.show() + if (force or (config.get('new_version_notification') and + dynamic.get('update to version %s'%calibre_version, True))): + if not no_show_popup: + self._update_notification__ = UpdateNotification(calibre_version, + plugin_updates, parent=self) + self._update_notification__.show() elif has_plugin_updates: if force: from calibre.gui2.dialogs.plugin_updater import (PluginUpdaterDialog,