reset only value icons and not template

This commit is contained in:
un-pogaz 2025-01-18 14:57:28 +01:00
parent a1aba91928
commit b4cef06f61
2 changed files with 6 additions and 4 deletions

View File

@ -470,12 +470,14 @@ class TagsModel(QAbstractItemModel): # {{{
self.prefs['tags_browser_value_icons'] =self.value_icons
self._remove_icon_file(file_name)
def remove_all_value_icons(self, key):
def remove_all_value_icons(self, key, keep_template=True):
self.value_icons = self.prefs['tags_browser_value_icons']
values = self.value_icons.pop(key, {})
self.value_icons[key] = {}
template = values.pop(TEMPLATE_ICON_INDICATOR, None)
if keep_template and template is not None:
self.value_icons[key][TEMPLATE_ICON_INDICATOR] = template
self.prefs['tags_browser_value_icons'] = self.value_icons
values.pop(TEMPLATE_ICON_INDICATOR, None)
for file_name,child in values.values():
self._remove_icon_file(file_name)

View File

@ -735,7 +735,7 @@ class TagsView(QTreeView): # {{{
return
if action == 'clear_icon':
if extra == 'all':
self._model.remove_all_value_icons(key)
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)
@ -1298,7 +1298,7 @@ class TagsView(QTreeView): # {{{
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'),
ma = im.addAction(_('Reset all value icons to the default icon'),
partial(self.context_menu_handler, action='clear_icon',
key=key, index=None, category=category, extra='all'))
im.addSeparator()