mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Improve the highlight deletion confirmation message to show some text from the highlight and mention if the highlight has associated notes
This commit is contained in:
parent
3b9fd595b4
commit
be4e875706
@ -215,6 +215,11 @@ class AnnotationsManager: # {{{
|
|||||||
if h:
|
if h:
|
||||||
return h.notes
|
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):
|
def set_notes_for_highlight(self, uuid, notes):
|
||||||
h = self.highlights[uuid]
|
h = self.highlights[uuid]
|
||||||
if h:
|
if h:
|
||||||
|
@ -1074,8 +1074,18 @@ class SelectionBar:
|
|||||||
def remove_highlight(self):
|
def remove_highlight(self):
|
||||||
annot_id = self.view.currently_showing.selection.annot_id
|
annot_id = self.view.currently_showing.selection.annot_id
|
||||||
if 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(
|
question_dialog(
|
||||||
_('Are you sure?'), _('Are you sure you want to delete this highlight permanently?'),
|
_('Are you sure?'), q,
|
||||||
def (yes):
|
def (yes):
|
||||||
if yes:
|
if yes:
|
||||||
self.remove_highlight_with_id(annot_id)
|
self.remove_highlight_with_id(annot_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user