add action to reset all value icons

This commit is contained in:
un-pogaz 2025-01-18 14:21:58 +01:00
parent 6ecf4e8858
commit a1aba91928

View File

@ -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 action == 'clear_icon':
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)
self.recount()
return
if action == 'clear_icon':
else:
self._model.set_custom_category_icon(key, None)
self._model.remove_all_value_icons(key)
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()