mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: When hovering over the top/bottom margin show a button indicating that a click will open the viewer controls. Fixes #2064665 [[Enhancement] More Intuitive EPUB Reader Menu Access](https://bugs.launchpad.net/calibre/+bug/2064665)
This commit is contained in:
parent
b7551ef8e7
commit
a593a2ce7b
@ -3,12 +3,13 @@
|
||||
from __python__ import bound_methods, hash_literals
|
||||
|
||||
from elementmaker import E
|
||||
from gettext import gettext as _, ngettext
|
||||
from gettext import gettext as _
|
||||
from gettext import ngettext
|
||||
|
||||
from book_list.globals import get_session_data
|
||||
from dom import unique_id
|
||||
from dom import clear, unique_id
|
||||
from read_book.prefs.utils import create_button_box
|
||||
from session import session_defaults, get_interface_data
|
||||
from session import get_interface_data, session_defaults
|
||||
from utils import fmt_sidx
|
||||
|
||||
CONTAINER = unique_id('reader-hf-prefs')
|
||||
@ -38,6 +39,7 @@ def create_item(region, label, style):
|
||||
opt(_('View mode as icon'), 'view-mode-icon'),
|
||||
sep(),
|
||||
opt(_('Clock'), 'clock'),
|
||||
opt(_('Controls button on hover'), 'menu-icon-on-hover'),
|
||||
sep(),
|
||||
opt(_('Progress'), 'progress'),
|
||||
opt(_('Time to read book'), 'time-book'),
|
||||
@ -189,6 +191,10 @@ def render_head_foot(div, which, region, metadata, current_toc_node, current_toc
|
||||
has_clock = False
|
||||
if override:
|
||||
text = override
|
||||
elif field is 'menu-icon-on-hover':
|
||||
clear(div)
|
||||
div.appendChild(E.div(class_='visible-on-hover', E.span(_('Show controls')), title=_('Show viewer controls'), style='cursor: pointer'))
|
||||
return has_clock
|
||||
elif field is 'progress':
|
||||
percent = min(100, max(Math.round(pos.progress_frac * 100), 0))
|
||||
text = percent + '%'
|
||||
|
@ -60,6 +60,9 @@ add_extra_css(def():
|
||||
ans += build_rule(sel + ':active > .not-arrow', display='none')
|
||||
ans += build_rule(sel + ':hover > .arrow', display='block')
|
||||
ans += build_rule(sel + ':active > .arrow', display='block', transform='scale(2)')
|
||||
ans += build_rule('.book-h-margin .visible-on-hover', visibility='hidden')
|
||||
ans += build_rule('.book-h-margin:hover .visible-on-hover', visibility='visible')
|
||||
ans += build_rule('.book-h-margin .visible-on-hover:hover', color=get_color('window-hover-foreground'))
|
||||
return ans
|
||||
)
|
||||
|
||||
@ -180,7 +183,7 @@ def margin_elem(sd, which, id, onclick, oncontextmenu):
|
||||
fsz = header_footer_font_size(sz)
|
||||
s = '; text-overflow: ellipsis; white-space: nowrap; overflow: hidden'
|
||||
ans = E.div(
|
||||
style=f'height:{sz}px; overflow: hidden; font-size:{fsz}px; width:100%; padding: 0; display: flex; justify-content: space-between; align-items: center; user-select: none',
|
||||
style=f'height:{sz}px; overflow: hidden; font-size:{fsz}px; width:100%; padding: 0; display: flex; justify-content: space-between; align-items: center; user-select: none; cursor: pointer', class_='book-h-margin',
|
||||
id=id,
|
||||
E.div(style='margin-right: 1.5em' + s), E.div(style=s), E.div(style='margin-left: 1.5em' + s)
|
||||
)
|
||||
@ -406,7 +409,7 @@ class View:
|
||||
self.focus_iframe()
|
||||
|
||||
def bottom_margin_clicked(self, event):
|
||||
if event.button is 2:
|
||||
if event.button is 0 or event.button is 2:
|
||||
event.preventDefault(), event.stopPropagation()
|
||||
window.setTimeout(self.show_chrome, 0)
|
||||
self.focus_iframe()
|
||||
|
@ -33,8 +33,8 @@ all_settings = {
|
||||
'controls_help_shown_count_rtl_page_progression': {'default': 0, 'category': 'read_book', 'is_local': True, 'disallowed_in_profile': True},
|
||||
'cover_preserve_aspect_ratio': {'default': True, 'category': 'read_book'},
|
||||
'current_color_scheme': {'default': 'system', 'category': 'read_book'},
|
||||
'footer': {'default': {'right': 'progress'}, 'category': 'read_book'},
|
||||
'header': {'default': {}, 'category': 'read_book'},
|
||||
'footer': {'default': {'left': 'menu-icon-on-hover', 'right': 'progress'}, 'category': 'read_book'},
|
||||
'header': {'default': {'right': 'menu-icon-on-hover'}, 'category': 'read_book'},
|
||||
'controls_footer': {'default': {'right': 'progress'}, 'category': 'read_book'},
|
||||
'left-margin': {'default': {}, 'category': 'read_book'},
|
||||
'right-margin': {'default': {}, 'category': 'read_book'},
|
||||
|
Loading…
x
Reference in New Issue
Block a user