Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cbhaley/calibre
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jan 31, 2025
2 parents f70641c + b831f13 commit 58d13cc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/calibre/gui2/tag_browser/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,12 @@ def context_menu_handler(self, action=None, category=None,
# category is None if the user asked to specify a template
# index is None if the user clicked on a category (top level) node
# extra is a tuple: (icon_file_name: string or None, children: True or False)
def make_icon_name(key, index):
def make_icon_name(key, index, db):
icon_file_name = 'icon_' + sanitize_file_name(key)
if index is not None:
item_val = self._model.get_node(index).tag.original_name
icon_file_name = icon_file_name + '@@' + sanitize_file_name(item_val)
item_id = db.new_api.get_item_id(key, item_val)
icon_file_name = f'{icon_file_name}@@{sanitize_file_name(item_val)}_{item_id}'
else:
item_val = None
icon_file_name += '.png'
Expand Down Expand Up @@ -713,7 +714,7 @@ def make_icon_name(key, index):
self.recount()
return
icon_file_name, for_children = extra if extra is not None else (None, None)
item_val, desired_file_name = make_icon_name(key, index)
item_val, desired_file_name = make_icon_name(key, index, self.db)
if icon_file_name is None:
# User wants to specify a specific icon
try:
Expand Down Expand Up @@ -753,7 +754,7 @@ def make_icon_name(key, index):
self._model.remove_all_value_icons(key, keep_template=True)
elif extra == 'value':
if index is not None:
val, icon_name = make_icon_name(key, index)
val, icon_name = make_icon_name(key, index, self.db)
if not confirm(
_('The icon for the value "{0}" of the "{1}" category '
'will be <b>permanently deleted</b>. Are you sure?').format(val, category),
Expand Down

0 comments on commit 58d13cc

Please sign in to comment.