diff --git a/src/calibre/srv/render_book.py b/src/calibre/srv/render_book.py index e7afa7b073..af05359d4d 100644 --- a/src/calibre/srv/render_book.py +++ b/src/calibre/srv/render_book.py @@ -258,12 +258,14 @@ class Container(ContainerBase): ''' diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 2598f7f60b..691941312c 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -140,6 +140,7 @@ class IframeBoss: self.content_ready = False self.replace_history_on_next_cfi_update = True self.book = current_book.book = data.book + self.is_titlepage = data.is_titlepage spine = self.book.manifest.spine index = spine.indexOf(data.name) reset_paged_mode_globals() @@ -243,6 +244,8 @@ class IframeBoss: def content_loaded(self): document.documentElement.style.overflow = 'hidden' + if self.is_titlepage and not opts.cover_preserve_aspect_ratio: + document.body.classList.add('cover-fill') self.last_window_width, self.last_window_height = scroll_viewport.width(), scroll_viewport.height() apply_settings() self.fix_fullscreen_svg_images() diff --git a/src/pyj/read_book/prefs/layout.pyj b/src/pyj/read_book/prefs/layout.pyj index 3ce6966d93..9a7fa8b137 100644 --- a/src/pyj/read_book/prefs/layout.pyj +++ b/src/pyj/read_book/prefs/layout.pyj @@ -61,6 +61,10 @@ def create_layout_panel(container): E.tr(E.td(_('Max. height:')), E.td(E.input(type='number', name='height', min='0', step='10', value=str(sd.get('max_text_height'))))), )) + sec(_('Control how the cover is displayed')) + container.appendChild(E.div(style='margin: 1ex 2rem; display: flex;', + E.label(E.input(type='checkbox', name='cover_preserve_aspect_ratio', checked=sd.get('cover_preserve_aspect_ratio')), _('Preserve cover aspect ratio')))) + develop = create_layout_panel @@ -103,5 +107,10 @@ def commit_layout(onchange, container): was_changed = True sd.set('max_text_' + which, val) + cover_preserve_aspect_ratio = element(CONTAINER, 'input[name=cover_preserve_aspect_ratio]').checked + if cover_preserve_aspect_ratio is not sd.get('cover_preserve_aspect_ratio'): + was_changed = True + sd.set('cover_preserve_aspect_ratio', cover_preserve_aspect_ratio) + if was_changed: onchange() diff --git a/src/pyj/read_book/settings.pyj b/src/pyj/read_book/settings.pyj index 35aa58fc61..f1ff9c85e6 100644 --- a/src/pyj/read_book/settings.pyj +++ b/src/pyj/read_book/settings.pyj @@ -15,7 +15,8 @@ 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 + opts.hide_tooltips = settings.hide_tooltips + opts.cover_preserve_aspect_ratio = settings.cover_preserve_aspect_ratio update_settings() diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index e99bef036c..8b749b23e3 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -532,6 +532,7 @@ class View: 'user_stylesheet': sd.get('user_stylesheet'), 'keyboard_shortcuts': sd.get('keyboard_shortcuts'), 'hide_tooltips': sd.get('hide_tooltips'), + 'cover_preserve_aspect_ratio': sd.get('cover_preserve_aspect_ratio'), } def show_name(self, name, initial_position=None): @@ -744,6 +745,7 @@ class View: resource_data=resource_data, book=self.book, name=self.currently_showing.name, initial_position=self.currently_showing.initial_position, settings=self.currently_showing.settings, + is_titlepage=self.currently_showing.name is self.book.manifest.title_page_name, ) def on_content_loaded(self, data): diff --git a/src/pyj/session.pyj b/src/pyj/session.pyj index e336391869..853b14f02c 100644 --- a/src/pyj/session.pyj +++ b/src/pyj/session.pyj @@ -29,6 +29,7 @@ defaults = { 'margin_top': 20, 'margin_bottom': 20, 'read_mode': 'paged', + 'cover_preserve_aspect_ratio': True, 'max_text_height': 0, 'max_text_width': 0, 'columns_per_screen': {'portrait':0, 'landscape':0},