mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Library Quick switch menu: Highlight the previously switched from library in bold. Fixes #1775888 [[Enhancement] Higlight last library in quick switch](https://bugs.launchpad.net/calibre/+bug/1775888)
This commit is contained in:
parent
dc922e5a33
commit
7879e35337
@ -209,6 +209,7 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
restore_view_state = pyqtSignal(object)
|
restore_view_state = pyqtSignal(object)
|
||||||
|
|
||||||
def genesis(self):
|
def genesis(self):
|
||||||
|
self.prev_lname = self.last_lname = ''
|
||||||
self.count_changed(0)
|
self.count_changed(0)
|
||||||
self.action_choose = self.menuless_qaction
|
self.action_choose = self.menuless_qaction
|
||||||
self.action_exim = ac = QAction(_('Export/import all calibre data'), self.gui)
|
self.action_exim = ac = QAction(_('Export/import all calibre data'), self.gui)
|
||||||
@ -318,6 +319,7 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
a.setWhatsThis(tooltip)
|
a.setWhatsThis(tooltip)
|
||||||
|
|
||||||
def library_changed(self, db):
|
def library_changed(self, db):
|
||||||
|
self.prev_lname = self.last_lname
|
||||||
lname = self.stats.library_used(db)
|
lname = self.stats.library_used(db)
|
||||||
self.last_lname = lname
|
self.last_lname = lname
|
||||||
if len(lname) > 16:
|
if len(lname) > 16:
|
||||||
@ -350,10 +352,15 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
self.delete_menu.clear()
|
self.delete_menu.clear()
|
||||||
quick_actions, rename_actions, delete_actions = [], [], []
|
quick_actions, rename_actions, delete_actions = [], [], []
|
||||||
for name, loc in locations:
|
for name, loc in locations:
|
||||||
|
is_prev_lib = name == self.prev_lname
|
||||||
name = name.replace('&', '&&')
|
name = name.replace('&', '&&')
|
||||||
ac = self.quick_menu.addAction(name, Dispatcher(partial(self.switch_requested,
|
ac = self.quick_menu.addAction(name, Dispatcher(partial(self.switch_requested,
|
||||||
loc)))
|
loc)))
|
||||||
ac.setStatusTip(_('Switch to: %s') % loc)
|
ac.setStatusTip(_('Switch to: %s') % loc)
|
||||||
|
if is_prev_lib:
|
||||||
|
f = ac.font()
|
||||||
|
f.setBold(True)
|
||||||
|
ac.setFont(f)
|
||||||
quick_actions.append(ac)
|
quick_actions.append(ac)
|
||||||
ac = self.rename_menu.addAction(name, Dispatcher(partial(self.rename_requested,
|
ac = self.rename_menu.addAction(name, Dispatcher(partial(self.rename_requested,
|
||||||
name, loc)))
|
name, loc)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user