Skip to content

Commit 075fbe7

Browse files
committed
Merge branch 'master' of https://github.com/cbhaley/calibre
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)
2 parents fad178b + b38bf68 commit 075fbe7

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/calibre/gui2/tag_browser/ui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def menu_func(cat_name, item):
101101
current_cat = model.column_map[col]
102102
if current_cat in ('authors', 'series', 'publisher', 'tags') or current_cat in cust_cats:
103103
cdn = cat_display_name(current_cat) or current_cat
104-
m.addAction(get_icon(current_cat), cdn, menu_func(current_cat, None))
104+
m.addAction(get_icon(current_cat), cdn.replace('&', '&&'), menu_func(current_cat, None))
105105
proxy_md = db.new_api.get_proxy_metadata(db.id(idx.row()))
106106
items = proxy_md.get(current_cat)
107107
if isinstance(items, str):
@@ -130,7 +130,7 @@ def menu_func(cat_name, item):
130130
for cat in sorted(cust_cats, key=lambda v: sort_key(cat_display_name(v))):
131131
if cat == current_cat:
132132
continue
133-
m.addAction(get_icon(cat), cat_display_name(cat), menu_func(cat, None))
133+
m.addAction(get_icon(cat), cat_display_name(cat).replace('&', '&&'), menu_func(cat, None))
134134

135135
def init_tag_browser_mixin(self, db):
136136
self.library_view.model().count_changed_signal.connect(self.tags_view.recount_with_position_based_index)

src/calibre/gui2/tag_browser/view.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,14 @@ def context_menu_handler(self, action=None, category=None,
778778
gui = get_gui()
779779
gui.iactions['Remove Books'].remove_format_from_selected_books(key)
780780
return
781+
if action == 'edit_open_with_apps':
782+
from calibre.gui2.open_with import edit_programs
783+
edit_programs(key, self)
784+
return
785+
if action == 'add_open_with_apps':
786+
from calibre.gui2.open_with import choose_program
787+
choose_program(key, self)
788+
return
781789

782790
reset_filter_categories = True
783791
if action == 'hide':
@@ -1133,8 +1141,13 @@ def add_node_tree(tree_dict, m, path):
11331141
partial(self.context_menu_handler, action='manage_searches',
11341142
category=tag.name if tag else None))
11351143
elif key == 'formats' and tag is not None:
1136-
self.context_menu.addAction(_('Remove the {} format from selected books').format(tag.name), partial(
1137-
self.context_menu_handler, action='remove_format', key=tag.name))
1144+
self.context_menu.addAction(_('Remove the {} format from selected books').format(tag.name),
1145+
partial(self.context_menu_handler, action='remove_format', key=tag.name))
1146+
self.context_menu.addSeparator()
1147+
self.context_menu.addAction(_('Add other application for %s files') % format(tag.name.upper()),
1148+
partial(self.context_menu_handler, action='add_open_with_apps', key=tag.name))
1149+
self.context_menu.addAction(_('Edit Open with applications for {} files').format(tag.name),
1150+
partial(self.context_menu_handler, action='edit_open_with_apps', key=tag.name))
11381151

11391152
# Hide/Show/Restore categories
11401153
self.context_menu.addSeparator()

0 commit comments

Comments
 (0)