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.in_paged_mode = false
|
||||||
this.current_margin_side = 0
|
this.current_margin_side = 0
|
||||||
this.is_full_screen_layout = false
|
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) ->
|
set_geometry: (cols_per_screen=1, margin_top=20, margin_side=40, margin_bottom=20) ->
|
||||||
this.margin_top = margin_top
|
this.margin_top = margin_top
|
||||||
@ -108,6 +109,11 @@ class PagedDisplay
|
|||||||
# Minimum column width, for the cases when the window is too
|
# Minimum column width, for the cases when the window is too
|
||||||
# narrow
|
# narrow
|
||||||
col_width = Math.max(100, ((ww - adjust)/n) - 2*sm)
|
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.page_width = col_width + 2*sm
|
||||||
this.screen_width = this.page_width * this.cols_per_screen
|
this.screen_width = this.page_width * this.cols_per_screen
|
||||||
|
|
||||||
@ -360,5 +366,4 @@ if window?
|
|||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# Resizing of images
|
# Resizing of images
|
||||||
# Full screen mode
|
|
||||||
# Highlight on jump_to_anchor
|
# Highlight on jump_to_anchor
|
||||||
|
@ -234,21 +234,27 @@ class Document(QWebPage): # {{{
|
|||||||
|
|
||||||
def switch_to_fullscreen_mode(self):
|
def switch_to_fullscreen_mode(self):
|
||||||
self.in_fullscreen_mode = True
|
self.in_fullscreen_mode = True
|
||||||
self.javascript('''
|
if self.in_paged_mode:
|
||||||
var s = document.body.style;
|
self.javascript('paged_display.max_col_width = %d'%self.max_fs_width)
|
||||||
s.maxWidth = "%dpx";
|
else:
|
||||||
s.marginLeft = "auto";
|
self.javascript('''
|
||||||
s.marginRight = "auto";
|
var s = document.body.style;
|
||||||
'''%self.max_fs_width)
|
s.maxWidth = "%dpx";
|
||||||
|
s.marginLeft = "auto";
|
||||||
|
s.marginRight = "auto";
|
||||||
|
'''%self.max_fs_width)
|
||||||
|
|
||||||
def switch_to_window_mode(self):
|
def switch_to_window_mode(self):
|
||||||
self.in_fullscreen_mode = False
|
self.in_fullscreen_mode = False
|
||||||
self.javascript('''
|
if self.in_paged_mode:
|
||||||
var s = document.body.style;
|
self.javascript('paged_display.max_col_width = %d'%-1)
|
||||||
s.maxWidth = "none";
|
else:
|
||||||
s.marginLeft = "%s";
|
self.javascript('''
|
||||||
s.marginRight = "%s";
|
var s = document.body.style;
|
||||||
'''%(self.initial_left_margin, self.initial_right_margin))
|
s.maxWidth = "none";
|
||||||
|
s.marginLeft = "%s";
|
||||||
|
s.marginRight = "%s";
|
||||||
|
'''%(self.initial_left_margin, self.initial_right_margin))
|
||||||
|
|
||||||
@pyqtSignature("QString")
|
@pyqtSignature("QString")
|
||||||
def debug(self, msg):
|
def debug(self, msg):
|
||||||
|
@ -477,6 +477,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
|||||||
else:
|
else:
|
||||||
self.view.document.switch_to_window_mode()
|
self.view.document.switch_to_window_mode()
|
||||||
self.view.document.page_position.restore()
|
self.view.document.page_position.restore()
|
||||||
|
self.scrolled(self.view.scroll_fraction)
|
||||||
|
|
||||||
def goto(self, ref):
|
def goto(self, ref):
|
||||||
if ref:
|
if ref:
|
||||||
@ -754,12 +755,12 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
|||||||
# There hasn't been a resize event for some time
|
# There hasn't been a resize event for some time
|
||||||
# restore the current page position.
|
# restore the current page position.
|
||||||
self.resize_in_progress = False
|
self.resize_in_progress = False
|
||||||
self.view.document.after_resize()
|
|
||||||
if self.window_mode_changed:
|
if self.window_mode_changed:
|
||||||
# This resize is part of a window mode change, special case it
|
# This resize is part of a window mode change, special case it
|
||||||
self.handle_window_mode_toggle()
|
self.handle_window_mode_toggle()
|
||||||
else:
|
else:
|
||||||
self.view.document.page_position.restore()
|
self.view.document.page_position.restore()
|
||||||
|
self.view.document.after_resize()
|
||||||
|
|
||||||
def close_progress_indicator(self):
|
def close_progress_indicator(self):
|
||||||
self.pi.stop()
|
self.pi.stop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user