From be4e875706ed66f94456337dd754f4e69eeefece Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 2 Feb 2023 15:23:20 +0530 Subject: [PATCH] Improve the highlight deletion confirmation message to show some text from the highlight and mention if the highlight has associated notes --- src/pyj/read_book/annotations.pyj | 5 +++++ src/pyj/read_book/selection_bar.pyj | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/annotations.pyj b/src/pyj/read_book/annotations.pyj index 55197ecc3a..59a214e0de 100644 --- a/src/pyj/read_book/annotations.pyj +++ b/src/pyj/read_book/annotations.pyj @@ -215,6 +215,11 @@ class AnnotationsManager: # {{{ if h: return h.notes + def text_for_highlight(self, uuid): + h = self.highlights[uuid] if uuid else None + if h: + return h.highlighted_text + def set_notes_for_highlight(self, uuid, notes): h = self.highlights[uuid] if h: diff --git a/src/pyj/read_book/selection_bar.pyj b/src/pyj/read_book/selection_bar.pyj index 5b97f0b3f3..eddc740822 100644 --- a/src/pyj/read_book/selection_bar.pyj +++ b/src/pyj/read_book/selection_bar.pyj @@ -1074,8 +1074,18 @@ class SelectionBar: def remove_highlight(self): annot_id = self.view.currently_showing.selection.annot_id if annot_id: + q = _('Are you sure you want to delete this highlight permanently?') + text = self.annotations_manager.text_for_highlight(annot_id) + if text and text.length: + if text.length > 20: + text = text[:20] + '…' + notes = self.annotations_manager.notes_for_highlight(annot_id) + if notes and notes.length: + q = _('Are you sure you want to delete the highlighting of "{}" and the associated notes permanently?').format(text) + else: + q = _('Are you sure you want to delete the highlighting of "{}" permanently?').format(text) question_dialog( - _('Are you sure?'), _('Are you sure you want to delete this highlight permanently?'), + _('Are you sure?'), q, def (yes): if yes: self.remove_highlight_with_id(annot_id)