mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
E-book viewer: Fix blank pages after every page when viewing some comic files in paged mode
This commit is contained in:
parent
f2759fe04e
commit
dd7330c515
Binary file not shown.
@ -71,7 +71,7 @@ class PagedDisplay
|
||||
this.margin_side = margin_side
|
||||
this.margin_bottom = margin_bottom
|
||||
|
||||
layout: () ->
|
||||
layout: (is_single_page=false) ->
|
||||
# start_time = new Date().getTime()
|
||||
body_style = window.getComputedStyle(document.body)
|
||||
bs = document.body.style
|
||||
@ -151,6 +151,8 @@ class PagedDisplay
|
||||
has_svg = document.getElementsByTagName('svg').length > 0
|
||||
only_img = document.getElementsByTagName('img').length == 1 and document.getElementsByTagName('div').length < 3 and document.getElementsByTagName('p').length < 2
|
||||
this.is_full_screen_layout = (only_img or has_svg) and single_screen and document.body.scrollWidth > document.body.clientWidth
|
||||
if is_single_page
|
||||
this.is_full_screen_layout = true
|
||||
|
||||
this.in_paged_mode = true
|
||||
this.current_margin_side = sm
|
||||
|
@ -126,6 +126,7 @@ class EbookIterator(BookmarksMixin):
|
||||
self.spine = []
|
||||
Spiny = partial(SpineItem, read_anchor_map=read_anchor_map,
|
||||
run_char_count=run_char_count)
|
||||
is_comic = plumber.input_fmt.lower() in {'cbc', 'cbz', 'cbr', 'cb7'}
|
||||
for i in ordered:
|
||||
spath = i.path
|
||||
mt = None
|
||||
@ -135,6 +136,8 @@ class EbookIterator(BookmarksMixin):
|
||||
mt = guess_type(spath)[0]
|
||||
try:
|
||||
self.spine.append(Spiny(spath, mime_type=mt))
|
||||
if is_comic:
|
||||
self.spine[-1].is_single_page = True
|
||||
except:
|
||||
self.log.warn('Missing spine item:', repr(spath))
|
||||
|
||||
|
@ -53,6 +53,7 @@ class SpineItem(unicode):
|
||||
if mime_type is None:
|
||||
mime_type = guess_type(obj)[0]
|
||||
obj.mime_type = mime_type
|
||||
obj.is_single_page = None
|
||||
return obj
|
||||
|
||||
class IndexEntry(object):
|
||||
|
@ -204,7 +204,7 @@ class Document(QWebPage): # {{{
|
||||
_pass_json_value = pyqtProperty(QString, fget=_pass_json_value_getter,
|
||||
fset=_pass_json_value_setter)
|
||||
|
||||
def after_load(self):
|
||||
def after_load(self, last_loaded_path=None):
|
||||
self.javascript('window.paged_display.read_document_margins()')
|
||||
self.set_bottom_padding(0)
|
||||
self.fit_images()
|
||||
@ -213,7 +213,7 @@ class Document(QWebPage): # {{{
|
||||
if self.in_fullscreen_mode:
|
||||
self.switch_to_fullscreen_mode()
|
||||
if self.in_paged_mode:
|
||||
self.switch_to_paged_mode()
|
||||
self.switch_to_paged_mode(last_loaded_path=last_loaded_path)
|
||||
self.read_anchor_positions(use_cache=False)
|
||||
evaljs = self.mainFrame().evaluateJavaScript
|
||||
for pl in self.all_viewer_plugins:
|
||||
@ -240,7 +240,7 @@ class Document(QWebPage): # {{{
|
||||
self.anchor_positions = {}
|
||||
return {k:tuple(v) for k, v in self.anchor_positions.iteritems()}
|
||||
|
||||
def switch_to_paged_mode(self, onresize=False):
|
||||
def switch_to_paged_mode(self, onresize=False, last_loaded_path=None):
|
||||
if onresize and not self.loaded_javascript:
|
||||
return
|
||||
self.javascript('''
|
||||
@ -251,9 +251,12 @@ class Document(QWebPage): # {{{
|
||||
self.cols_per_screen, self.top_margin, self.side_margin,
|
||||
self.bottom_margin
|
||||
))
|
||||
side_margin = self.javascript('window.paged_display.layout()', typ=int)
|
||||
force_fullscreen_layout = bool(getattr(last_loaded_path,
|
||||
'is_single_page', False))
|
||||
f = 'true' if force_fullscreen_layout else 'false'
|
||||
side_margin = self.javascript('window.paged_display.layout(%s)'%f, typ=int)
|
||||
# Setup the contents size to ensure that there is a right most margin.
|
||||
# Without this webkit renders the final column with no margin, as the
|
||||
# Without this WebKit renders the final column with no margin, as the
|
||||
# columns extend beyond the boundaries (and margin) of body
|
||||
mf = self.mainFrame()
|
||||
sz = mf.contentsSize()
|
||||
@ -730,7 +733,7 @@ class DocumentView(QWebView): # {{{
|
||||
return
|
||||
self.loading_url = None
|
||||
self.document.load_javascript_libraries()
|
||||
self.document.after_load()
|
||||
self.document.after_load(self.last_loaded_path)
|
||||
self._size_hint = self.document.mainFrame().contentsSize()
|
||||
scrolled = False
|
||||
if self.to_bottom:
|
||||
|
Loading…
x
Reference in New Issue
Block a user