From e74e14fdb011f2caf2c122641f1263a9961f56a5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 23 May 2021 21:40:28 +0530 Subject: [PATCH] Viewer highlights panel: Fix the "Edit notes" link not saving the changes --- src/calibre/gui2/viewer/highlights.py | 2 ++ src/calibre/gui2/viewer/ui.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/calibre/gui2/viewer/highlights.py b/src/calibre/gui2/viewer/highlights.py index d4927da22b..10eb6cb5c6 100644 --- a/src/calibre/gui2/viewer/highlights.py +++ b/src/calibre/gui2/viewer/highlights.py @@ -422,6 +422,7 @@ class HighlightsPanel(QWidget): request_highlight_action = pyqtSignal(object, object) web_action = pyqtSignal(object, object) toggle_requested = pyqtSignal() + notes_edited_signal = pyqtSignal(object, object) def __init__(self, parent=None): QWidget.__init__(self, parent) @@ -471,6 +472,7 @@ class HighlightsPanel(QWidget): if h is not None: h['notes'] = text self.web_action.emit('set-notes-in-highlight', h) + self.notes_edited_signal.emit(h['uuid'], text) def set_tooltips(self, rmap): a = rmap.get('create_annotation') diff --git a/src/calibre/gui2/viewer/ui.py b/src/calibre/gui2/viewer/ui.py index e1842b595d..2a7dd21008 100644 --- a/src/calibre/gui2/viewer/ui.py +++ b/src/calibre/gui2/viewer/ui.py @@ -200,6 +200,7 @@ class EbookViewer(MainWindow): self.dock_visibility_changed() self.highlights_widget.request_highlight_action.connect(self.web_view.highlight_action) self.highlights_widget.web_action.connect(self.web_view.generic_action) + self.highlights_widget.notes_edited_signal.connect(self.notes_edited) if continue_reading: self.continue_reading() self.setup_mouse_auto_hide() @@ -649,6 +650,16 @@ class EbookViewer(MainWindow): self.highlights_widget.refresh(highlights) self.save_annotations() + def notes_edited(self, uuid, notes): + for h in self.current_book_data['annotations_map']['highlight']: + if h.get('uuid') == uuid: + h['notes'] = notes + h['timestamp'] = utcnow().isoformat() + break + else: + return + self.save_annotations() + def edit_book(self, file_name, progress_frac, selected_text): import subprocess