Fixes #2065614 [Another unescaped ampersand](https://bugs.launchpad.net/calibre/+bug/2065614)
Fixes #2065544 [{Enhancement)] Add Open With action menu to Tag browser Formats entries](https://bugs.launchpad.net/calibre/+bug/2065544)
This commit is contained in:
Kovid Goyal 2024-05-23 20:25:45 +05:30
commit 075fbe767b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 4 deletions

View File

@ -101,7 +101,7 @@ class TagBrowserMixin: # {{{
current_cat = model.column_map[col]
if current_cat in ('authors', 'series', 'publisher', 'tags') or current_cat in cust_cats:
cdn = cat_display_name(current_cat) or current_cat
m.addAction(get_icon(current_cat), cdn, menu_func(current_cat, None))
m.addAction(get_icon(current_cat), cdn.replace('&', '&&'), menu_func(current_cat, None))
proxy_md = db.new_api.get_proxy_metadata(db.id(idx.row()))
items = proxy_md.get(current_cat)
if isinstance(items, str):
@ -130,7 +130,7 @@ class TagBrowserMixin: # {{{
for cat in sorted(cust_cats, key=lambda v: sort_key(cat_display_name(v))):
if cat == current_cat:
continue
m.addAction(get_icon(cat), cat_display_name(cat), menu_func(cat, None))
m.addAction(get_icon(cat), cat_display_name(cat).replace('&', '&&'), menu_func(cat, None))
def init_tag_browser_mixin(self, db):
self.library_view.model().count_changed_signal.connect(self.tags_view.recount_with_position_based_index)

View File

@ -778,6 +778,14 @@ class TagsView(QTreeView): # {{{
gui = get_gui()
gui.iactions['Remove Books'].remove_format_from_selected_books(key)
return
if action == 'edit_open_with_apps':
from calibre.gui2.open_with import edit_programs
edit_programs(key, self)
return
if action == 'add_open_with_apps':
from calibre.gui2.open_with import choose_program
choose_program(key, self)
return
reset_filter_categories = True
if action == 'hide':
@ -1133,8 +1141,13 @@ class TagsView(QTreeView): # {{{
partial(self.context_menu_handler, action='manage_searches',
category=tag.name if tag else None))
elif key == 'formats' and tag is not None:
self.context_menu.addAction(_('Remove the {} format from selected books').format(tag.name), partial(
self.context_menu_handler, action='remove_format', key=tag.name))
self.context_menu.addAction(_('Remove the {} format from selected books').format(tag.name),
partial(self.context_menu_handler, action='remove_format', key=tag.name))
self.context_menu.addSeparator()
self.context_menu.addAction(_('Add other application for %s files') % format(tag.name.upper()),
partial(self.context_menu_handler, action='add_open_with_apps', key=tag.name))
self.context_menu.addAction(_('Edit Open with applications for {} files').format(tag.name),
partial(self.context_menu_handler, action='edit_open_with_apps', key=tag.name))
# Hide/Show/Restore categories
self.context_menu.addSeparator()