Viewer: Fix zoom step size setting ignored. Fixes #1875840 [Viewer's font "zoom step size" preference dysfunctional](https://bugs.launchpad.net/calibre/+bug/1875840)

This commit is contained in:
Kovid Goyal 2020-04-30 14:07:39 +05:30
parent 7602c059b6
commit b3cd50806c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 16 additions and 10 deletions

View File

@ -549,12 +549,6 @@ class WebView(RestartingWebEngineView):
if ans is not None and not sip.isdeleted(ans): if ans is not None and not sip.isdeleted(ans):
return ans return ans
def change_zoom_by(self, steps=1):
# TODO: Add UI for this
ss = vprefs['session_data'].get('zoom_step_size') or 20
amt = (ss / 100) * steps
self._page.setZoomFactor(max(0.25, min(self._page.zoomFactor() + amt, 5)))
def render_process_died(self): def render_process_died(self):
if self.dead_renderer_error_shown: if self.dead_renderer_error_shown:
return return

View File

@ -37,9 +37,10 @@ def set_custom_size(ev):
sz = int(element(CONTAINER, 'input').value) sz = int(element(CONTAINER, 'input').value)
change_font_size(sz) change_font_size(sz)
def change_font_size_by(amt): def change_font_size_by(frac):
sd = get_session_data() sd = get_session_data()
sz = sd.get('base_font_size') sz = sd.get('base_font_size')
amt = sz * frac
nsz = sz + amt nsz = sz + amt
nsz = max(8, min(nsz, 80)) nsz = max(8, min(nsz, 80))
change_font_size(nsz) change_font_size(nsz)

View File

@ -16,6 +16,11 @@ DEFAULT_MINIMUM_FONT_SIZE = 8
DEFAULT_ZOOM_STEP_SIZE = 20 DEFAULT_ZOOM_STEP_SIZE = 20
def current_zoom_step_size():
s = get_session_data().get('standalone_font_settings')
return s.zoom_step_size or DEFAULT_ZOOM_STEP_SIZE
def font_select(name, settings): def font_select(name, settings):
ans = E.select(name=name) ans = E.select(name=name)
ans.appendChild(E.option(_('— Choose a font —'), value='')) ans.appendChild(E.option(_('— Choose a font —'), value=''))

View File

@ -13,7 +13,9 @@ from dom import add_extra_css, build_rule, clear, set_css, svgicon, unique_id
from iframe_comm import IframeWrapper from iframe_comm import IframeWrapper
from modals import error_dialog, warning_dialog from modals import error_dialog, warning_dialog
from read_book.content_popup import ContentPopupOverlay from read_book.content_popup import ContentPopupOverlay
from read_book.create_annotation import AnnotationsManager, CreateAnnotation, ViewAnnotation from read_book.create_annotation import (
AnnotationsManager, CreateAnnotation, ViewAnnotation
)
from read_book.globals import ( from read_book.globals import (
current_book, runtime, set_current_spine_item, ui_operations current_book, runtime, set_current_spine_item, ui_operations
) )
@ -22,6 +24,7 @@ from read_book.open_book import add_book_to_recently_viewed
from read_book.overlay import Overlay from read_book.overlay import Overlay
from read_book.prefs.colors import resolve_color_scheme from read_book.prefs.colors import resolve_color_scheme
from read_book.prefs.font_size import change_font_size_by from read_book.prefs.font_size import change_font_size_by
from read_book.prefs.fonts import current_zoom_step_size
from read_book.prefs.head_foot import render_head_foot from read_book.prefs.head_foot import render_head_foot
from read_book.prefs.scrolling import ( from read_book.prefs.scrolling import (
MIN_SCROLL_SPEED_AUTO as SCROLL_SPEED_STEP, change_scroll_speed MIN_SCROLL_SPEED_AUTO as SCROLL_SPEED_STEP, change_scroll_speed
@ -570,8 +573,11 @@ class View:
) )
def bump_font_size(self, data): def bump_font_size(self, data):
delta = 2 if data.increase else -2 mult = 1 if data.increase else -1
change_font_size_by(delta) frac = 0.2
if runtime.is_standalone_viewer:
frac = current_zoom_step_size() / 100
change_font_size_by(mult * frac)
def on_show_footnote(self, data): def on_show_footnote(self, data):
self.show_content_popup() self.show_content_popup()