Fix #1895425 [[Enhancement] Browse annotations action in the dropdown menu for View in the toolbar](https://bugs.launchpad.net/calibre/+bug/1895425)

This commit is contained in:
Kovid Goyal 2020-09-13 16:46:03 +05:30
parent ceceff8cc3
commit f479fca692
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 19 additions and 13 deletions

View File

@ -112,9 +112,9 @@ the handles to the top or bottom margins to scroll while selecting.
You can use the :guilabel:`Browse highlights` button in the viewer
controls to show a separate panel with a list of all highlights in the book.
You can browse *all highlights* in your entire calibre library by going to
:guilabel:`Preferences->Toolbars` in calibre and adding the :guilabel:`Browse
annotations` tool to the toolbar.
You can browse *all highlights* in your entire calibre library by right
clicking the :guilabel:`View` button and choosing :guilabel:`Browse
annotations`.
Finally, if you use the calibre Content server's in browser viewer, you can
have the viewer sync its annotations with the browser viewer by going to

View File

@ -6,20 +6,22 @@ __license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os, time, json
import json
import os
import time
from functools import partial
from PyQt5.Qt import Qt, QAction, pyqtSignal
from PyQt5.Qt import QAction, QIcon, Qt, pyqtSignal
from calibre.constants import ismacos, iswindows, plugins
from calibre.gui2 import (
error_dialog, Dispatcher, question_dialog, config, open_local_file,
info_dialog, elided_text)
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
from calibre.utils.config import prefs, tweaks
from calibre.ptempfile import PersistentTemporaryFile
Dispatcher, config, elided_text, error_dialog, info_dialog, open_local_file,
question_dialog
)
from calibre.gui2.actions import InterfaceAction
from polyglot.builtins import unicode_type, as_bytes
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
from calibre.ptempfile import PersistentTemporaryFile
from calibre.utils.config import prefs, tweaks
from polyglot.builtins import as_bytes, unicode_type
class HistoryAction(QAction):
@ -55,6 +57,7 @@ class ViewAction(InterfaceAction):
self.internal_view_action = cm('internal', _('View with calibre E-book viewer'), triggered=self.view_internal)
self.action_pick_random = cm('pick random', _('Read a random book'),
icon='random.png', triggered=self.view_random)
self.view_menu.addAction(QIcon(I('highlight.png')), _('Browse annotations'), self.browse_annots)
self.clear_sep1 = self.view_menu.addSeparator()
self.clear_sep2 = self.view_menu.addSeparator()
self.clear_history_action = cm('clear history',
@ -79,6 +82,9 @@ class ViewAction(InterfaceAction):
ac.view_historical.connect(self.view_historical)
self.history_actions.append(ac)
def browse_annots(self):
self.gui.iactions['Browse Annotations'].show_browser()
def clear_history(self):
db = self.gui.current_db
db.new_api.set_pref('gui_view_history', [])
@ -100,8 +106,8 @@ class ViewAction(InterfaceAction):
self.view_format_by_id(id_, format)
def calibre_book_data(self, book_id, fmt):
from calibre.gui2.viewer.config import vprefs, get_session_pref
from calibre.db.annotations import merge_annotations
from calibre.gui2.viewer.config import get_session_pref, vprefs
vprefs.refresh()
sync_annots_user = get_session_pref('sync_annots_user', default='')
db = self.gui.current_db.new_api