From 2e3a0e57bf427025cc1f91a962cfaf4cb3d82677 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 5 Aug 2013 10:37:29 +0530 Subject: [PATCH] Fix book count in tooltip of choose library button not updating Fixes #1208217 [library toolbar button not updated on book deletion](https://bugs.launchpad.net/calibre/+bug/1208217) --- src/calibre/gui2/actions/choose_library.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/actions/choose_library.py b/src/calibre/gui2/actions/choose_library.py index f50aa95443..9c6a666a92 100644 --- a/src/calibre/gui2/actions/choose_library.py +++ b/src/calibre/gui2/actions/choose_library.py @@ -292,16 +292,22 @@ class ChooseLibraryAction(InterfaceAction): path = path.replace(os.sep, '/') return self.stats.pretty(path) + def update_tooltip(self, count): + tooltip = self.action_spec[2] + '\n\n' + _('{0} [{1} books]').format( + getattr(self, 'last_lname', ''), count) + a = self.qaction + a.setToolTip(tooltip) + a.setStatusTip(tooltip) + a.setWhatsThis(tooltip) + def library_changed(self, db): lname = self.stats.library_used(db) - tooltip = self.action_spec[2] + '\n\n' + _('{0} [{1} books]').format(lname, db.count()) + self.last_lname = lname if len(lname) > 16: lname = lname[:16] + u'…' a = self.qaction a.setText(lname) - a.setToolTip(tooltip) - a.setStatusTip(tooltip) - a.setWhatsThis(tooltip) + self.update_tooltip(db.count()) self.build_menus() state = self.view_state_map.get(self.stats.canonicalize_path( db.library_path), None) @@ -557,7 +563,7 @@ class ChooseLibraryAction(InterfaceAction): self.switch_requested(self.qs_locations[idx]) def count_changed(self, new_count): - pass + self.update_tooltip(new_count) def choose_library(self, *args): if not self.change_library_allowed():