Viewer highlights panel: Fix the "Edit notes" link not saving the changes

This commit is contained in:
Kovid Goyal 2021-05-23 21:40:28 +05:30
parent 3e633713d9
commit e74e14fdb0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 0 deletions

View File

@ -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')

View File

@ -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