mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Refactor shortcut definitions
Now they are directly keyed on runtime.is_standalone_viewer since that is the canonical reference as to which mode we are running in.
This commit is contained in:
parent
8a999ef17f
commit
1df2ed477e
@ -90,10 +90,8 @@ def key_as_text(evt):
|
||||
return mods + key
|
||||
|
||||
|
||||
def shortcuts_definition():
|
||||
ans = shortcuts_definition.ans
|
||||
if not ans:
|
||||
ans = shortcuts_definition.ans = {
|
||||
def common_shortcuts(): # {{{
|
||||
return {
|
||||
'start_of_file': desc(
|
||||
v"['Ctrl+ArrowUp', 'Ctrl+ArrowLeft', 'Home']",
|
||||
'scroll',
|
||||
@ -364,14 +362,22 @@ def shortcuts_definition():
|
||||
_('Auto scroll slower'),
|
||||
),
|
||||
|
||||
}
|
||||
} # }}}
|
||||
|
||||
if not runtime.is_standalone_viewer:
|
||||
ans['sync_book'] = desc(
|
||||
v"[]",
|
||||
'ui',
|
||||
_('Sync last read position/annotations'),
|
||||
)
|
||||
|
||||
def shortcuts_definition():
|
||||
ans = shortcuts_definition.ans
|
||||
if not ans:
|
||||
ans = shortcuts_definition.ans = common_shortcuts()
|
||||
|
||||
if runtime.is_standalone_viewer:
|
||||
add_standalone_viewer_shortcuts(ans)
|
||||
else:
|
||||
ans['sync_book'] = desc(
|
||||
v"[]",
|
||||
'ui',
|
||||
_('Sync last read position/annotations'),
|
||||
)
|
||||
|
||||
return ans
|
||||
|
||||
@ -387,9 +393,8 @@ def shortcuts_group_desc():
|
||||
|
||||
|
||||
|
||||
def add_standalone_viewer_shortcuts():
|
||||
def add_standalone_viewer_shortcuts(sc):
|
||||
ismacos = 'macos' in window.navigator.userAgent
|
||||
sc = shortcuts_definition()
|
||||
sc['toggle_inspector'] = desc(
|
||||
v"['Ctrl+i']",
|
||||
'ui',
|
||||
|
@ -19,7 +19,6 @@ from read_book.db import new_book
|
||||
from read_book.footnotes import main as footnotes_main
|
||||
from read_book.globals import runtime, set_system_colors, ui_operations, default_color_schemes
|
||||
from read_book.iframe import main as iframe_main
|
||||
from read_book.shortcuts import add_standalone_viewer_shortcuts
|
||||
from read_book.view import View
|
||||
from read_book.prefs.head_foot import set_time_formatter
|
||||
from session import local_storage, session_defaults
|
||||
@ -303,7 +302,6 @@ if window is window.top:
|
||||
TRANSLATIONS_DATA = v'__TRANSLATIONS_DATA__'
|
||||
if TRANSLATIONS_DATA:
|
||||
install(TRANSLATIONS_DATA)
|
||||
add_standalone_viewer_shortcuts()
|
||||
ui_operations.get_file = get_file
|
||||
ui_operations.get_mathjax_files = get_mathjax_files
|
||||
ui_operations.update_url_state = update_url_state
|
||||
@ -430,4 +428,3 @@ else:
|
||||
footnotes_main()
|
||||
else:
|
||||
iframe_main()
|
||||
add_standalone_viewer_shortcuts()
|
||||
|
Loading…
x
Reference in New Issue
Block a user