Use a standard delete confirmation for deleting annotations fromthe browse tool

This commit is contained in:
Kovid Goyal 2020-08-09 17:34:08 +05:30
parent 31acd459a9
commit 5de7f24814
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -7,16 +7,15 @@ from textwrap import fill
from PyQt5.Qt import ( from PyQt5.Qt import (
QApplication, QCheckBox, QComboBox, QCursor, QDateTime, QFont, QHBoxLayout, QApplication, QCheckBox, QComboBox, QCursor, QDateTime, QFont, QHBoxLayout,
QIcon, QLabel, QPalette, QPlainTextEdit, QSize, QSplitter, Qt, QIcon, QLabel, QPalette, QPlainTextEdit, QSize, QSplitter, Qt, QTextBrowser,
QTextBrowser, QTimer, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QTimer, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget,
QWidget, pyqtSignal pyqtSignal
) )
from calibre import prepare_string_for_xml from calibre import prepare_string_for_xml
from calibre.ebooks.metadata import authors_to_string, fmt_sidx from calibre.ebooks.metadata import authors_to_string, fmt_sidx
from calibre.gui2 import ( from calibre.gui2 import Application, config, error_dialog, gprefs
Application, config, error_dialog, gprefs, question_dialog from calibre.gui2.dialogs.confirm_delete import confirm
)
from calibre.gui2.viewer.widgets import ResultsDelegate, SearchBox from calibre.gui2.viewer.widgets import ResultsDelegate, SearchBox
from calibre.gui2.widgets2 import Dialog from calibre.gui2.widgets2 import Dialog
@ -570,10 +569,10 @@ class AnnotationsBrowser(Dialog):
self.delete_annotations(ids) self.delete_annotations(ids)
def delete_annotations(self, ids): def delete_annotations(self, ids):
if question_dialog(self, _('Are you sure?'), ngettext( if confirm(ngettext(
'Are you sure you want to <b>permanently</b> delete this annotation?', 'Are you sure you want to <b>permanently</b> delete this annotation?',
'Are you sure you want to <b>permanently</b> delete these {} annotations?', 'Are you sure you want to <b>permanently</b> delete these {} annotations?',
len(ids)).format(len(ids)) len(ids)).format(len(ids)), 'delete-annotation-from-browse', parent=self
): ):
db = current_db() db = current_db()
db.delete_annotations(ids) db.delete_annotations(ids)