mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Paged display: Add support for full screen mode
This commit is contained in:
parent
12d28edd4d
commit
50a13872c8
@ -66,6 +66,7 @@ class PagedDisplay
|
||||
this.in_paged_mode = false
|
||||
this.current_margin_side = 0
|
||||
this.is_full_screen_layout = false
|
||||
this.max_col_width = -1
|
||||
|
||||
set_geometry: (cols_per_screen=1, margin_top=20, margin_side=40, margin_bottom=20) ->
|
||||
this.margin_top = margin_top
|
||||
@ -108,6 +109,11 @@ class PagedDisplay
|
||||
# Minimum column width, for the cases when the window is too
|
||||
# narrow
|
||||
col_width = Math.max(100, ((ww - adjust)/n) - 2*sm)
|
||||
if this.max_col_width > 0 and col_width > this.max_col_width
|
||||
# Increase the side margin to ensure that col_width is no larger
|
||||
# than max_col_width
|
||||
sm += Math.ceil( (col_width - this.max_col_width) / 2.0 )
|
||||
col_width = Math.max(100, ((ww - adjust)/n) - 2*sm)
|
||||
this.page_width = col_width + 2*sm
|
||||
this.screen_width = this.page_width * this.cols_per_screen
|
||||
|
||||
@ -360,5 +366,4 @@ if window?
|
||||
|
||||
# TODO:
|
||||
# Resizing of images
|
||||
# Full screen mode
|
||||
# Highlight on jump_to_anchor
|
||||
|
@ -234,21 +234,27 @@ class Document(QWebPage): # {{{
|
||||
|
||||
def switch_to_fullscreen_mode(self):
|
||||
self.in_fullscreen_mode = True
|
||||
self.javascript('''
|
||||
var s = document.body.style;
|
||||
s.maxWidth = "%dpx";
|
||||
s.marginLeft = "auto";
|
||||
s.marginRight = "auto";
|
||||
'''%self.max_fs_width)
|
||||
if self.in_paged_mode:
|
||||
self.javascript('paged_display.max_col_width = %d'%self.max_fs_width)
|
||||
else:
|
||||
self.javascript('''
|
||||
var s = document.body.style;
|
||||
s.maxWidth = "%dpx";
|
||||
s.marginLeft = "auto";
|
||||
s.marginRight = "auto";
|
||||
'''%self.max_fs_width)
|
||||
|
||||
def switch_to_window_mode(self):
|
||||
self.in_fullscreen_mode = False
|
||||
self.javascript('''
|
||||
var s = document.body.style;
|
||||
s.maxWidth = "none";
|
||||
s.marginLeft = "%s";
|
||||
s.marginRight = "%s";
|
||||
'''%(self.initial_left_margin, self.initial_right_margin))
|
||||
if self.in_paged_mode:
|
||||
self.javascript('paged_display.max_col_width = %d'%-1)
|
||||
else:
|
||||
self.javascript('''
|
||||
var s = document.body.style;
|
||||
s.maxWidth = "none";
|
||||
s.marginLeft = "%s";
|
||||
s.marginRight = "%s";
|
||||
'''%(self.initial_left_margin, self.initial_right_margin))
|
||||
|
||||
@pyqtSignature("QString")
|
||||
def debug(self, msg):
|
||||
|
@ -477,6 +477,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
else:
|
||||
self.view.document.switch_to_window_mode()
|
||||
self.view.document.page_position.restore()
|
||||
self.scrolled(self.view.scroll_fraction)
|
||||
|
||||
def goto(self, ref):
|
||||
if ref:
|
||||
@ -754,12 +755,12 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
# There hasn't been a resize event for some time
|
||||
# restore the current page position.
|
||||
self.resize_in_progress = False
|
||||
self.view.document.after_resize()
|
||||
if self.window_mode_changed:
|
||||
# This resize is part of a window mode change, special case it
|
||||
self.handle_window_mode_toggle()
|
||||
else:
|
||||
self.view.document.page_position.restore()
|
||||
self.view.document.after_resize()
|
||||
|
||||
def close_progress_indicator(self):
|
||||
self.pi.stop()
|
||||
|
Loading…
x
Reference in New Issue
Block a user