mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Tag browser context menu: Move the show all categories action into the show category sub-menu. Fixes #1899868 [Enhancement Request: "Show Category" when right-clicking empty space in tag browser](https://bugs.launchpad.net/calibre/+bug/1899868)
This commit is contained in:
parent
bb21e82f75
commit
511351317f
@ -574,6 +574,20 @@ class TagsView(QTreeView): # {{{
|
|||||||
index = self.indexAt(point)
|
index = self.indexAt(point)
|
||||||
self.context_menu = QMenu(self)
|
self.context_menu = QMenu(self)
|
||||||
parent_index = None
|
parent_index = None
|
||||||
|
added_show_hidden_categories = False
|
||||||
|
|
||||||
|
def add_show_hidden_categories():
|
||||||
|
nonlocal added_show_hidden_categories
|
||||||
|
if self.hidden_categories and not added_show_hidden_categories:
|
||||||
|
added_show_hidden_categories = True
|
||||||
|
m = self.context_menu.addMenu(_('Show category'))
|
||||||
|
for col in sorted(self.hidden_categories,
|
||||||
|
key=lambda x: sort_key(self.db.field_metadata[x]['name'])):
|
||||||
|
m.addAction(self.db.field_metadata[col]['name'],
|
||||||
|
partial(self.context_menu_handler, action='show', category=col))
|
||||||
|
m.addSeparator()
|
||||||
|
m.addAction(_('All categories'),
|
||||||
|
partial(self.context_menu_handler, action='defaults'))
|
||||||
|
|
||||||
if index.isValid():
|
if index.isValid():
|
||||||
item = index.data(Qt.UserRole)
|
item = index.data(Qt.UserRole)
|
||||||
@ -722,12 +736,7 @@ class TagsView(QTreeView): # {{{
|
|||||||
self.context_menu.addAction(_('Hide category %s') % category,
|
self.context_menu.addAction(_('Hide category %s') % category,
|
||||||
partial(self.context_menu_handler, action='hide',
|
partial(self.context_menu_handler, action='hide',
|
||||||
category=key))
|
category=key))
|
||||||
if self.hidden_categories:
|
add_show_hidden_categories()
|
||||||
m = self.context_menu.addMenu(_('Show category'))
|
|
||||||
for col in sorted(self.hidden_categories,
|
|
||||||
key=lambda x: sort_key(self.db.field_metadata[x]['name'])):
|
|
||||||
m.addAction(self.db.field_metadata[col]['name'],
|
|
||||||
partial(self.context_menu_handler, action='show', category=col))
|
|
||||||
|
|
||||||
# search by category. Some categories are not searchable, such
|
# search by category. Some categories are not searchable, such
|
||||||
# as search and news
|
# as search and news
|
||||||
@ -810,8 +819,7 @@ class TagsView(QTreeView): # {{{
|
|||||||
if self.hidden_categories:
|
if self.hidden_categories:
|
||||||
if not self.context_menu.isEmpty():
|
if not self.context_menu.isEmpty():
|
||||||
self.context_menu.addSeparator()
|
self.context_menu.addSeparator()
|
||||||
self.context_menu.addAction(_('Show all categories'),
|
add_show_hidden_categories()
|
||||||
partial(self.context_menu_handler, action='defaults'))
|
|
||||||
|
|
||||||
m = self.context_menu.addMenu(_('Change sub-categorization scheme'))
|
m = self.context_menu.addMenu(_('Change sub-categorization scheme'))
|
||||||
da = m.addAction(_('Disable'),
|
da = m.addAction(_('Disable'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user