Dont gate annotations behind develop mode anymore

This commit is contained in:
Kovid Goyal 2020-07-14 09:28:09 +05:30
parent a0fabf3e57
commit 12dded643f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 28 additions and 41 deletions

View File

@ -8,7 +8,7 @@ import os, glob, re
from calibre import guess_type from calibre import guess_type
from calibre.customize import (FileTypePlugin, MetadataReaderPlugin, from calibre.customize import (FileTypePlugin, MetadataReaderPlugin,
MetadataWriterPlugin, PreferencesPlugin, InterfaceActionBase, StoreBase) MetadataWriterPlugin, PreferencesPlugin, InterfaceActionBase, StoreBase)
from calibre.constants import numeric_version, in_develop_mode from calibre.constants import numeric_version
from calibre.ebooks.metadata.archive import ArchiveExtract, KPFExtract, get_comic_metadata from calibre.ebooks.metadata.archive import ArchiveExtract, KPFExtract, get_comic_metadata
from calibre.ebooks.html.to_zip import HTML2ZIP from calibre.ebooks.html.to_zip import HTML2ZIP
@ -1101,9 +1101,7 @@ plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog,
ActionCopyToLibrary, ActionTweakEpub, ActionUnpackBook, ActionNextMatch, ActionStore, ActionCopyToLibrary, ActionTweakEpub, ActionUnpackBook, ActionNextMatch, ActionStore,
ActionPluginUpdater, ActionPickRandom, ActionEditToC, ActionSortBy, ActionPluginUpdater, ActionPickRandom, ActionEditToC, ActionSortBy,
ActionMarkBooks, ActionEmbed, ActionTemplateTester, ActionTagMapper, ActionAuthorMapper, ActionMarkBooks, ActionEmbed, ActionTemplateTester, ActionTagMapper, ActionAuthorMapper,
ActionVirtualLibrary] ActionVirtualLibrary, ActionBrowseAnnotations]
if in_develop_mode:
plugins.append(ActionBrowseAnnotations)
# }}} # }}}

View File

@ -12,7 +12,7 @@ from PyQt5.Qt import (
) )
from PyQt5.QtWebEngineWidgets import QWebEnginePage from PyQt5.QtWebEngineWidgets import QWebEnginePage
from calibre.constants import in_develop_mode, isosx from calibre.constants import isosx
from calibre.gui2 import elided_text from calibre.gui2 import elided_text
from calibre.gui2.viewer.config import get_session_pref from calibre.gui2.viewer.config import get_session_pref
from calibre.gui2.viewer.shortcuts import index_to_key_sequence from calibre.gui2.viewer.shortcuts import index_to_key_sequence
@ -64,26 +64,18 @@ def all_actions():
'print': Action('print.png', _('Print book'), 'print'), 'print': Action('print.png', _('Print book'), 'print'),
'preferences': Action('config.png', _('Preferences'), 'preferences'), 'preferences': Action('config.png', _('Preferences'), 'preferences'),
'metadata': Action('metadata.png', _('Show book metadata'), 'metadata'), 'metadata': Action('metadata.png', _('Show book metadata'), 'metadata'),
'highlight': Action('highlight.png', _('Highlight text in the book'), 'create_annotation'),
'toggle_highlights': Action('highlight_only_on.png', _('Browse highlights in book'), 'toggle_highlights'),
} }
if in_develop_mode:
amap['highlight'] = Action('highlight.png', _('Highlight text in the book'), 'create_annotation')
amap['toggle_highlights'] = Action('highlight_only_on.png', _('Browse highlights in book'), 'toggle_highlights')
all_actions.ans = Actions(amap) all_actions.ans = Actions(amap)
return all_actions.ans return all_actions.ans
if in_develop_mode: DEFAULT_ACTIONS = (
DEFAULT_ACTIONS = ( 'back', 'forward', None, 'open', 'copy', 'increase_font_size', 'decrease_font_size', 'fullscreen', 'color_scheme',
'back', 'forward', None, 'open', 'copy', 'increase_font_size', 'decrease_font_size', 'fullscreen', 'color_scheme', None, 'previous', 'next', None, 'toc', 'search', 'bookmarks', 'lookup', 'highlight', 'chrome', None,
None, 'previous', 'next', None, 'toc', 'search', 'bookmarks', 'lookup', 'highlight', 'chrome', None, 'mode', 'print', 'preferences', 'metadata', 'inspector'
'mode', 'print', 'preferences', 'metadata', 'inspector' )
)
else:
DEFAULT_ACTIONS = (
'back', 'forward', None, 'open', 'copy', 'increase_font_size', 'decrease_font_size', 'fullscreen', 'color_scheme',
None, 'previous', 'next', None, 'toc', 'search', 'bookmarks', 'lookup', 'reference', 'chrome', None,
'mode', 'print', 'preferences', 'metadata', 'inspector'
)
def current_actions(): def current_actions():

View File

@ -322,12 +322,11 @@ class MainOverlay: # {{{
ac(_('Lookup/search word'), _('Lookup or search for the currently selected word'), ac(_('Lookup/search word'), _('Lookup or search for the currently selected word'),
def(): self.overlay.hide(), ui_operations.toggle_lookup();, 'library') def(): self.overlay.hide(), ui_operations.toggle_lookup();, 'library')
)) ))
if runtime.in_develop_mode: actions_div.lastChild.appendChild(highlight_action)
actions_div.lastChild.appendChild(highlight_action) actions_div.lastChild.appendChild(
actions_div.lastChild.appendChild( ac(_('Browse highlights'), _('Browse all highlights'),
ac(_('Browse highlights'), _('Browse all highlights'), def(): self.overlay.hide(), ui_operations.toggle_highlights();, 'image')
def(): self.overlay.hide(), ui_operations.toggle_highlights();, 'image') )
)
copy_actions = E.ul() copy_actions = E.ul()
if self.overlay.view.currently_showing.selected_text: if self.overlay.view.currently_showing.selected_text:
copy_actions.appendChild(ac(_('Copy selection'), _('Copy the current selection'), def(): copy_actions.appendChild(ac(_('Copy selection'), _('Copy the current selection'), def():
@ -356,8 +355,7 @@ class MainOverlay: # {{{
def(): self.overlay.hide(), ui_operations.quit();, 'remove'), def(): self.overlay.hide(), ui_operations.quit();, 'remove'),
)) ))
else: else:
if runtime.in_develop_mode: actions_div.appendChild(E.ul(highlight_action))
actions_div.appendChild(E.ul(highlight_action))
container.appendChild(set_css(E.div(class_=MAIN_OVERLAY_TS_CLASS, # top section container.appendChild(set_css(E.div(class_=MAIN_OVERLAY_TS_CLASS, # top section
onclick=def (evt):evt.stopPropagation();, onclick=def (evt):evt.stopPropagation();,

View File

@ -3,7 +3,6 @@
from __python__ import bound_methods, hash_literals from __python__ import bound_methods, hash_literals
from gettext import gettext as _ from gettext import gettext as _
from read_book.globals import runtime
def parse_key_repr(sc): def parse_key_repr(sc):
@ -329,13 +328,13 @@ def shortcuts_definition():
_('Auto scroll slower'), _('Auto scroll slower'),
), ),
'create_annotation': desc(
"Ctrl+h",
'ui',
_('Create a highlight'),
),
} }
if runtime.in_develop_mode:
ans.create_annotation = desc(
"Ctrl+h",
'ui',
_('Create a highlight'),
)
return ans return ans
@ -395,12 +394,12 @@ def add_standalone_viewer_shortcuts():
'ui', 'ui',
_('Toggle the toolbar'), _('Toggle the toolbar'),
) )
if runtime.in_develop_mode:
sc['toggle_highlights'] = desc( sc['toggle_highlights'] = desc(
"Ctrl+Alt+h", "Ctrl+Alt+h",
'ui', 'ui',
_('Toggle the highlights panel') _('Toggle the highlights panel')
) )
def create_shortcut_map(custom_shortcuts): def create_shortcut_map(custom_shortcuts):