mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Add option to hide mouse-over tooltips
This commit is contained in:
parent
4d7045d92d
commit
997595dfd4
@ -8,6 +8,7 @@ from gettext import gettext as _
|
||||
from book_list.globals import get_session_data
|
||||
from dom import unique_id
|
||||
from widgets import create_button
|
||||
from session import defaults
|
||||
|
||||
CONTAINER = unique_id('standalone-misc-settings')
|
||||
DEFAULTS = {
|
||||
@ -21,6 +22,7 @@ def restore_defaults():
|
||||
container = get_container()
|
||||
for q in Object.keys(DEFAULTS):
|
||||
container.querySelector(f'[name={q}]').checked = DEFAULTS[q]
|
||||
container.querySelector(f'[name=hide_tooltips]').checked = defaults.hide_tooltips
|
||||
|
||||
|
||||
def get_container():
|
||||
@ -32,6 +34,7 @@ def create_misc_panel(container):
|
||||
container = container.lastChild
|
||||
sd = get_session_data()
|
||||
settings = sd.get('standalone_misc_settings')
|
||||
settings.hide_tooltips = sd.get('hide_tooltips')
|
||||
|
||||
def cb(name, text):
|
||||
ans = E.input(type='checkbox', name=name)
|
||||
@ -41,6 +44,7 @@ def create_misc_panel(container):
|
||||
container.append(cb('remember_window_geometry', _('Remember last used window size and position')))
|
||||
container.append(cb('remember_last_read', _('Remember current page when quitting')))
|
||||
container.append(cb('save_annotations_in_ebook', _('Keep a copy of annotations/bookmarks in the e-book file, for easy sharing')))
|
||||
container.append(cb('hide_tooltips', _('Hide mouse-over tooltips in the book text')))
|
||||
|
||||
container.appendChild(E.div(
|
||||
style='margin-top: 1rem', create_button(_('Restore defaults'), action=restore_defaults)
|
||||
@ -59,3 +63,6 @@ def commit_misc(onchange):
|
||||
if val is not DEFAULTS[q]:
|
||||
vals[q] = val
|
||||
sd.set('standalone_misc_settings', vals)
|
||||
hide_tooltips = container.querySelector(f'[name=hide_tooltips]').checked
|
||||
sd.set('hide_tooltips', None if hide_tooltips is defaults.hide_tooltips else hide_tooltips)
|
||||
onchange()
|
||||
|
@ -6,7 +6,8 @@ from elementmaker import E
|
||||
from encodings import base64decode, utf8_decode
|
||||
|
||||
from dom import clear, remove_all_attributes
|
||||
from read_book.globals import ui_operations, runtime
|
||||
from read_book.globals import runtime, ui_operations
|
||||
from read_book.settings import opts
|
||||
|
||||
JSON_XHTML_MIMETYPE = 'application/calibre+xhtml+json'
|
||||
|
||||
@ -168,6 +169,7 @@ js_types = {k: True for k in 'text/javascript text/ecmascript application/javasc
|
||||
resource_tag_names = {'script':'src', 'link':'href', 'img':'src', 'image':'xlink:href'}
|
||||
ns_rmap = {'http://www.w3.org/2000/svg':'svg', 'http://www.w3.org/1999/xlink':'xlink', 'http://www.w3.org/1998/Math/MathML':'math', 'http://www.w3.org/XML/1998/namespace': 'xml'}
|
||||
ns_count = 0
|
||||
hide_tooltips = False
|
||||
|
||||
def get_prefix(ns):
|
||||
nonlocal ns_count
|
||||
@ -186,6 +188,8 @@ def apply_attributes(src, elem, ns_map):
|
||||
ns = ns_map[a[2]]
|
||||
elem.setAttributeNS(ns, get_prefix(ns) + a[0], a[1])
|
||||
else:
|
||||
if hide_tooltips and (a[0] is 'title' or a[0] is 'alt'):
|
||||
continue
|
||||
elem.setAttribute(a[0], a[1])
|
||||
|
||||
def process_stack(stack, tag_map, ns_map, load_required, onload, resource_urls):
|
||||
@ -225,6 +229,7 @@ def process_stack(stack, tag_map, ns_map, load_required, onload, resource_urls):
|
||||
stack.push(v'[node[i], elem]')
|
||||
|
||||
def unserialize_html(serialized_data, proceed, postprocess_dom):
|
||||
nonlocal hide_tooltips
|
||||
tag_map = serialized_data.tag_map
|
||||
tree = serialized_data.tree
|
||||
ns_map = serialized_data.ns_map
|
||||
@ -243,6 +248,7 @@ def unserialize_html(serialized_data, proceed, postprocess_dom):
|
||||
load_required = set()
|
||||
proceeded = False
|
||||
hang_timeout = 5
|
||||
hide_tooltips = opts.hide_tooltips
|
||||
|
||||
def hangcheck():
|
||||
nonlocal proceeded
|
||||
|
@ -15,6 +15,7 @@ def update_settings(settings):
|
||||
opts.color_scheme = settings.color_scheme
|
||||
opts.base_font_size = max(8, min(settings.base_font_size or 16, 64))
|
||||
opts.user_stylesheet = settings.user_stylesheet or ''
|
||||
opts.hide_tooltips = settings.hide_tooltips or False
|
||||
|
||||
update_settings()
|
||||
|
||||
|
@ -531,6 +531,7 @@ class View:
|
||||
'base_font_size': sd.get('base_font_size'),
|
||||
'user_stylesheet': sd.get('user_stylesheet'),
|
||||
'keyboard_shortcuts': sd.get('keyboard_shortcuts'),
|
||||
'hide_tooltips': sd.get('hide_tooltips'),
|
||||
}
|
||||
|
||||
def show_name(self, name, initial_position=None):
|
||||
|
@ -40,6 +40,7 @@ defaults = {
|
||||
'header': {},
|
||||
'footer': {'right': 'progress'},
|
||||
'word_actions': v'[]',
|
||||
'hide_tooltips': False,
|
||||
'keyboard_shortcuts': {},
|
||||
'standalone_font_settings': {},
|
||||
'standalone_misc_settings': {},
|
||||
|
Loading…
x
Reference in New Issue
Block a user