add confirm dialog for all deleting icon action

This commit is contained in:
un-pogaz 2025-01-18 15:53:03 +01:00
parent b4cef06f61
commit 9ec00f0ca5

View File

@ -47,6 +47,7 @@ from calibre.constants import config_dir
from calibre.ebooks.metadata import rating_to_stars
from calibre.gui2 import FunctionDispatcher, choose_files, config, empty_index, gprefs, pixmap_to_data, question_dialog, rating_font, safe_open_url
from calibre.gui2.complete2 import EditWithComplete
from calibre.gui2.dialogs.confirm_delete import confirm
from calibre.gui2.dialogs.edit_category_notes import EditNoteDialog
from calibre.gui2.tag_browser.model import (
COUNT_ROLE,
@ -735,14 +736,34 @@ class TagsView(QTreeView): # {{{
return
if action == 'clear_icon':
if extra == 'all':
if not confirm(
_('<b>All</b> the value icons for the category "{}" '
'will be <b>permanently deleted</b>. Are you sure?').format(category),
'clear_category_all_value_icons', parent=get_gui()):
return
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)
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),
'clear_category_value_icon_single', parent=get_gui()):
return
self._model.remove_value_icon(key, val, icon_name)
else:
if not confirm(
_('The template to choose the default value icons for the category "{}" '
'will be <b>permanently deleted</b>. Are you sure?').format(category),
'clear_category_value_icon_template', parent=get_gui()):
return
self._model.remove_value_icon(key, TEMPLATE_ICON_INDICATOR, None)
else:
if not confirm(
_('The icon for the category "{}" '
'will be <b>permanently deleted</b>. Are you sure?').format(category),
'clear_category_icon', parent=get_gui()):
return
self._model.set_custom_category_icon(key, None)
self.recount()
return