mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Browser viewer: Fix font size and color scheme settings not being respected in the footnote popup
This commit is contained in:
parent
347d40c639
commit
cfb5185dde
@ -135,7 +135,7 @@ class ContentPopupOverlay:
|
|||||||
def show_footnote_item_stage2(self, resource_data):
|
def show_footnote_item_stage2(self, resource_data):
|
||||||
self.iframe_wrapper.send_unencrypted_message('display',
|
self.iframe_wrapper.send_unencrypted_message('display',
|
||||||
resource_data=resource_data, book=self.view.book, name=self.current_footnote_data.name,
|
resource_data=resource_data, book=self.view.book, name=self.current_footnote_data.name,
|
||||||
frag=self.current_footnote_data.frag)
|
frag=self.current_footnote_data.frag, settings=self.view.iframe_settings())
|
||||||
|
|
||||||
def on_content_loaded(self, data):
|
def on_content_loaded(self, data):
|
||||||
self.iframe.style.height = f'{data.height}px'
|
self.iframe.style.height = f'{data.height}px'
|
||||||
|
@ -5,6 +5,7 @@ from __python__ import bound_methods, hash_literals
|
|||||||
from dom import clear
|
from dom import clear
|
||||||
from read_book.comm import IframeClient
|
from read_book.comm import IframeClient
|
||||||
from read_book.resources import finalize_resources, unserialize_html
|
from read_book.resources import finalize_resources, unserialize_html
|
||||||
|
from read_book.settings import apply_settings, opts
|
||||||
|
|
||||||
|
|
||||||
block_names = dict.fromkeys(v"['p', 'div', 'li', 'td', 'h1', 'h2', 'h2', 'h3', 'h4', 'h5', 'h6', 'body']", True).as_object()
|
block_names = dict.fromkeys(v"['p', 'div', 'li', 'td', 'h1', 'h2', 'h2', 'h3', 'h4', 'h5', 'h6', 'body']", True).as_object()
|
||||||
@ -200,6 +201,7 @@ class PopupIframeBoss:
|
|||||||
window.URL.revokeObjectURL(self.blob_url_map[name])
|
window.URL.revokeObjectURL(self.blob_url_map[name])
|
||||||
root_data, self.mathjax, self.blob_url_map = finalize_resources(self.book, data.name, data.resource_data)
|
root_data, self.mathjax, self.blob_url_map = finalize_resources(self.book, data.name, data.resource_data)
|
||||||
self.resource_urls = unserialize_html(root_data, self.content_loaded, self.show_only_footnote)
|
self.resource_urls = unserialize_html(root_data, self.content_loaded, self.show_only_footnote)
|
||||||
|
apply_settings(data.settings)
|
||||||
|
|
||||||
def on_clear(self, data):
|
def on_clear(self, data):
|
||||||
clear(document.head)
|
clear(document.head)
|
||||||
@ -216,4 +218,14 @@ class PopupIframeBoss:
|
|||||||
show_footnote(self.frag, known_anchors)
|
show_footnote(self.frag, known_anchors)
|
||||||
|
|
||||||
def content_loaded(self):
|
def content_loaded(self):
|
||||||
|
self.apply_colors()
|
||||||
|
self.apply_font_size()
|
||||||
self.comm.send_message('content_loaded', height=document.documentElement.scrollHeight + 25)
|
self.comm.send_message('content_loaded', height=document.documentElement.scrollHeight + 25)
|
||||||
|
|
||||||
|
def apply_font_size(self):
|
||||||
|
document.documentElement.style.fontSize = document.body.style.fontSize = '{}px'.format(opts.base_font_size)
|
||||||
|
|
||||||
|
def apply_colors(self):
|
||||||
|
for elem in (document.documentElement, document.body):
|
||||||
|
elem.style.color = opts.color_scheme.foreground
|
||||||
|
elem.style.backgroundColor = opts.color_scheme.background
|
||||||
|
@ -353,12 +353,9 @@ class View:
|
|||||||
def redisplay_book(self):
|
def redisplay_book(self):
|
||||||
self.display_book(self.book)
|
self.display_book(self.book)
|
||||||
|
|
||||||
def show_name(self, name, initial_position=None):
|
def iframe_settings(self, name):
|
||||||
if self.currently_showing.loading:
|
|
||||||
return
|
|
||||||
self.processing_spine_item_display = False
|
|
||||||
sd = get_session_data()
|
sd = get_session_data()
|
||||||
settings={
|
return {
|
||||||
'margin_left': 0 if name is self.book.manifest.title_page_name else sd.get('margin_left'),
|
'margin_left': 0 if name is self.book.manifest.title_page_name else sd.get('margin_left'),
|
||||||
'margin_right': 0 if name is self.book.manifest.title_page_name else sd.get('margin_right'),
|
'margin_right': 0 if name is self.book.manifest.title_page_name else sd.get('margin_right'),
|
||||||
'read_mode': sd.get('read_mode'),
|
'read_mode': sd.get('read_mode'),
|
||||||
@ -366,8 +363,13 @@ class View:
|
|||||||
'color_scheme': self.get_color_scheme(True),
|
'color_scheme': self.get_color_scheme(True),
|
||||||
'base_font_size': sd.get('base_font_size'),
|
'base_font_size': sd.get('base_font_size'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def show_name(self, name, initial_position=None):
|
||||||
|
if self.currently_showing.loading:
|
||||||
|
return
|
||||||
|
self.processing_spine_item_display = False
|
||||||
initial_position = initial_position or {'replace_history':False}
|
initial_position = initial_position or {'replace_history':False}
|
||||||
self.currently_showing = {'name':name, 'settings':settings, 'initial_position':initial_position, 'loading':True}
|
self.currently_showing = {'name':name, 'settings':self.iframe_settings(name), 'initial_position':initial_position, 'loading':True}
|
||||||
self.show_loading()
|
self.show_loading()
|
||||||
spine = self.book.manifest.spine
|
spine = self.book.manifest.spine
|
||||||
idx = spine.indexOf(name)
|
idx = spine.indexOf(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user