From a1aba91928bd64169ed635d255193e56456e0c88 Mon Sep 17 00:00:00 2001 From: un-pogaz <46523284+un-pogaz@users.noreply.github.com> Date: Sat, 18 Jan 2025 14:21:58 +0100 Subject: [PATCH] add action to reset all value icons --- src/calibre/gui2/tag_browser/view.py | 32 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/calibre/gui2/tag_browser/view.py b/src/calibre/gui2/tag_browser/view.py index ab1ba9b2f6..a9fd94ef8f 100644 --- a/src/calibre/gui2/tag_browser/view.py +++ b/src/calibre/gui2/tag_browser/view.py @@ -733,17 +733,17 @@ class TagsView(QTreeView): # {{{ self._model.set_value_icon(key, item_val, icon_file_name, bool(for_children)) self.recount() return - if action == 'clear_icon_value': - if index is not None: - val, icon_name = make_icon_name(key, index) - self._model.remove_value_icon(key, val, icon_name) - else: - self._model.remove_value_icon(key, TEMPLATE_ICON_INDICATOR, None) - self.recount() - return if action == 'clear_icon': - self._model.set_custom_category_icon(key, None) - self._model.remove_all_value_icons(key) + if extra == 'all': + self._model.remove_all_value_icons(key) + elif extra == 'value': + if index is not None: + val, icon_name = make_icon_name(key, index) + self._model.remove_value_icon(key, val, icon_name) + else: + self._model.remove_value_icon(key, TEMPLATE_ICON_INDICATOR, None) + else: + self._model.set_custom_category_icon(key, None) self.recount() return @@ -1286,17 +1286,21 @@ class TagsView(QTreeView): # {{{ key=key, index=index, category=category, extra=(icon_name, True))) ma.setEnabled(icon_name is not None and not for_child) ma = im.addAction(_('Use the default icon for {}').format(for_name), - partial(self.context_menu_handler, action='clear_icon_value', - key=key, index=index, category=category)) + partial(self.context_menu_handler, action='clear_icon', + key=key, index=index, category=category, extra='value')) ma.setEnabled(name is not None and icon_name is not None) im.addSection(_('Defaults')) im.addAction(_('Use/edit a template to choose the default value icon'), partial(self.context_menu_handler, action='set_icon', key=key, index=index, category=None, extra=(None, None))) ma = im.addAction(_('Use the category icon for the default value icon'), - partial(self.context_menu_handler, action='clear_icon_value', - key=key, index=None, category=category)) + partial(self.context_menu_handler, action='clear_icon', + key=key, index=None, category=category, extra='value')) ma.setEnabled(self._model.value_icons.get(key, {}).get(TEMPLATE_ICON_INDICATOR) is not None) + im.addSection(_('All values')) + ma = im.addAction(_('Reset all value icons to category icon'), + partial(self.context_menu_handler, action='clear_icon', + key=key, index=None, category=category, extra='all')) im.addSeparator() # Always show the User categories editor self.context_menu.addSeparator()