mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Dont enter fullscreen mode automatically when reading on desktop like devices (this can be controlled via a setting in in the viewer preferences under Page layout)
This commit is contained in:
parent
e617f65470
commit
762f1b659a
@ -6,7 +6,7 @@ from elementmaker import E
|
|||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
from book_list.constants import book_list_container_id, read_book_container_id
|
from book_list.constants import book_list_container_id, read_book_container_id
|
||||||
from book_list.globals import get_current_query
|
from book_list.globals import get_current_query, get_session_data
|
||||||
from book_list.library_data import current_library_id
|
from book_list.library_data import current_library_id
|
||||||
from modals import close_all_modals
|
from modals import close_all_modals
|
||||||
from utils import (
|
from utils import (
|
||||||
@ -56,6 +56,11 @@ def apply_url(ignore_handler):
|
|||||||
|
|
||||||
|
|
||||||
def open_book(book_id, fmt, library_id=None, replace=False):
|
def open_book(book_id, fmt, library_id=None, replace=False):
|
||||||
|
opt = get_session_data().get('fullscreen_when_opening')
|
||||||
|
has_touch = v'"ontouchstart" in window'
|
||||||
|
at_left = window.screenLeft is 0
|
||||||
|
likely_wants_fullscreen = has_touch and at_left
|
||||||
|
if (opt is 'auto' and likely_wants_fullscreen) or opt is 'always':
|
||||||
# Note that full screen requests only succeed if they are in response to a
|
# Note that full screen requests only succeed if they are in response to a
|
||||||
# user action like clicking/tapping a button
|
# user action like clicking/tapping a button
|
||||||
request_full_screen()
|
request_full_screen()
|
||||||
|
@ -8,11 +8,13 @@ from gettext import gettext as _
|
|||||||
from book_list.globals import get_session_data
|
from book_list.globals import get_session_data
|
||||||
from dom import add_extra_css, build_rule, element, unique_id
|
from dom import add_extra_css, build_rule, element, unique_id
|
||||||
from read_book.prefs.utils import create_button_box
|
from read_book.prefs.utils import create_button_box
|
||||||
|
from read_book.globals import runtime
|
||||||
from session import defaults
|
from session import defaults
|
||||||
|
|
||||||
CONTAINER = unique_id('reader-page-layout')
|
CONTAINER = unique_id('reader-page-layout')
|
||||||
MARGINS = unique_id('reader-page-margins')
|
MARGINS = unique_id('reader-page-margins')
|
||||||
READ_MODE = unique_id('read-mode')
|
READ_MODE = unique_id('read-mode')
|
||||||
|
FS_MODE = unique_id('fs-mode')
|
||||||
COLS = unique_id('cols-per-screen')
|
COLS = unique_id('cols-per-screen')
|
||||||
TEXT_AREA = unique_id('text-area')
|
TEXT_AREA = unique_id('text-area')
|
||||||
|
|
||||||
@ -28,7 +30,8 @@ def restore_defaults():
|
|||||||
for which in 'top bottom left right'.split(' '):
|
for which in 'top bottom left right'.split(' '):
|
||||||
container.querySelector('input[name={}]'.format(which)).value = str(defaults['margin_' + which])
|
container.querySelector('input[name={}]'.format(which)).value = str(defaults['margin_' + which])
|
||||||
for name in 'paged flow'.split(' '):
|
for name in 'paged flow'.split(' '):
|
||||||
container.querySelector('input[data-name={}]'.format(name)).checked = defaults.read_mode is name
|
container.querySelector(f'#{READ_MODE} input[data-name={name}]').checked = defaults.read_mode is name
|
||||||
|
container.querySelector(f'#{FS_MODE} input[value={defaults.fullscreen_when_opening}]').checked = True
|
||||||
for name in 'portrait landscape'.split(' '):
|
for name in 'portrait landscape'.split(' '):
|
||||||
container.querySelector('input[name={}]'.format(name)).value = str(defaults.columns_per_screen[name])
|
container.querySelector('input[name={}]'.format(name)).value = str(defaults.columns_per_screen[name])
|
||||||
for which in 'width height'.split(' '):
|
for which in 'width height'.split(' '):
|
||||||
@ -89,9 +92,23 @@ def create_layout_panel(container, apply_func, cancel_func):
|
|||||||
E.td(_('Height:')), E.td(E.input(type='number', name='height', min='0', step='10', max='99999', value=str(sd.get('max_text_height')))),
|
E.td(_('Height:')), E.td(E.input(type='number', name='height', min='0', step='10', max='99999', value=str(sd.get('max_text_height')))),
|
||||||
)))
|
)))
|
||||||
|
|
||||||
sec(_('Control how the cover is displayed'))
|
sec(_('Miscellaneous'))
|
||||||
container.appendChild(E.div(style='margin: 1ex 2rem; display: flex;',
|
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'))))
|
E.label(E.input(type='checkbox', name='cover_preserve_aspect_ratio', checked=sd.get('cover_preserve_aspect_ratio')), _('Preserve cover aspect ratio'))))
|
||||||
|
if not runtime.is_standalone_viewer:
|
||||||
|
name = 'fullscreen_when_opening'
|
||||||
|
val = sd.get(name)
|
||||||
|
container.appendChild(E.div(
|
||||||
|
E.div(style='margin: 1ex 2rem', id=FS_MODE,
|
||||||
|
_('When opening a book enter fullscreen:'), ' ',
|
||||||
|
E.label(E.input(type='radio', name=name, value='auto', checked=val is 'auto'), _('Auto')),
|
||||||
|
'\xa0',
|
||||||
|
E.label(E.input(type='radio', name=name, value='always', checked=val is 'always'), _('Always')),
|
||||||
|
'\xa0',
|
||||||
|
E.label(E.input(type='radio', name=name, value='never', checked=val is 'never'), _('Never')),
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
container.appendChild(E.div(style='margin: 1rem', create_button_box(restore_defaults, apply_func, cancel_func)))
|
container.appendChild(E.div(style='margin: 1rem', create_button_box(restore_defaults, apply_func, cancel_func)))
|
||||||
|
|
||||||
|
|
||||||
@ -116,6 +133,11 @@ def commit_layout(onchange, container):
|
|||||||
if rm is not crm:
|
if rm is not crm:
|
||||||
was_changed = True
|
was_changed = True
|
||||||
sd.set('read_mode', crm)
|
sd.set('read_mode', crm)
|
||||||
|
fs = sd.get('fullscreen_when_opening')
|
||||||
|
cfs = document.querySelector(f'#{FS_MODE} input[name="fullscreen_when_opening"]:checked').value
|
||||||
|
if cfs is not fs:
|
||||||
|
was_changed = True
|
||||||
|
sd.set('fullscreen_when_opening', cfs)
|
||||||
cps = sd.get('columns_per_screen')
|
cps = sd.get('columns_per_screen')
|
||||||
cps = {'portrait': cps.portrait, 'landscape': cps.landscape}
|
cps = {'portrait': cps.portrait, 'landscape': cps.landscape}
|
||||||
for which in ('portrait', 'landscape'):
|
for which in ('portrait', 'landscape'):
|
||||||
|
@ -71,6 +71,7 @@ defaults = {
|
|||||||
'skipped_dialogs': v'{}',
|
'skipped_dialogs': v'{}',
|
||||||
'tts': v'{}',
|
'tts': v'{}',
|
||||||
'tts_backend': v'{}',
|
'tts_backend': v'{}',
|
||||||
|
'fullscreen_when_opening': 'auto',
|
||||||
}
|
}
|
||||||
|
|
||||||
is_local_setting = {
|
is_local_setting = {
|
||||||
@ -102,6 +103,7 @@ is_local_setting = {
|
|||||||
'highlight_style': True,
|
'highlight_style': True,
|
||||||
'tts': True,
|
'tts': True,
|
||||||
'tts_backend': True,
|
'tts_backend': True,
|
||||||
|
'fullscreen_when_opening': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user