mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Shortcuts for UI panels
This commit is contained in:
parent
1102216d9f
commit
566855ed55
@ -147,10 +147,10 @@ def create_keyboard_panel(container, close_func):
|
|||||||
sd = get_session_data()
|
sd = get_session_data()
|
||||||
custom_shortcuts = sd.get('keyboard_shortcuts')
|
custom_shortcuts = sd.get('keyboard_shortcuts')
|
||||||
groups = as_groups(SHORTCUTS)
|
groups = as_groups(SHORTCUTS)
|
||||||
items = []
|
|
||||||
for group_name in Object.keys(groups):
|
for group_name in Object.keys(groups):
|
||||||
container.appendChild(E.h3(GROUP_DESC[group_name]))
|
container.appendChild(E.h3(style='margin-top: 1ex', GROUP_DESC[group_name]))
|
||||||
group = groups[group_name]
|
group = groups[group_name]
|
||||||
|
items = []
|
||||||
for sc_name in sorted(Object.keys(group), key=sort_group_key.bind(None, group)):
|
for sc_name in sorted(Object.keys(group), key=sort_group_key.bind(None, group)):
|
||||||
sc = group[sc_name]
|
sc = group[sc_name]
|
||||||
items.push(sc_as_item(sc_name, sc, custom_shortcuts[sc_name]))
|
items.push(sc_as_item(sc_name, sc, custom_shortcuts[sc_name]))
|
||||||
|
@ -67,7 +67,8 @@ def key_as_text(evt):
|
|||||||
|
|
||||||
|
|
||||||
GROUP_DESC = {
|
GROUP_DESC = {
|
||||||
'scroll': _('Navigation')
|
'scroll': _('Navigation'),
|
||||||
|
'ui': _('Interface'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,11 +151,35 @@ SHORTCUTS = {
|
|||||||
_('Forward'),
|
_('Forward'),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'toggle_toc': desc(
|
||||||
|
v"['Ctrl+t']",
|
||||||
|
'ui',
|
||||||
|
_('Show/hide Table of Contents'),
|
||||||
|
),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def add_standalone_viewer_shortcuts():
|
||||||
|
SHORTCUTS['toggle_bookmarks'] = desc(
|
||||||
|
v"['Ctrl+b']",
|
||||||
|
'ui',
|
||||||
|
_('Show/hide bookmarks'),
|
||||||
|
)
|
||||||
|
|
||||||
|
SHORTCUTS['toggle_inspector'] = desc(
|
||||||
|
v"['Ctrl+i']",
|
||||||
|
'ui',
|
||||||
|
_('Show/hide Inspector'),
|
||||||
|
)
|
||||||
|
|
||||||
|
SHORTCUTS['toggle_lookup'] = desc(
|
||||||
|
v"['Ctrl+l']",
|
||||||
|
'ui',
|
||||||
|
_('Show/hide the word lookup panel'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_shortcut_map(custom_shortcuts):
|
def create_shortcut_map(custom_shortcuts):
|
||||||
ans = {}
|
ans = {}
|
||||||
for sc_name in Object.keys(SHORTCUTS):
|
for sc_name in Object.keys(SHORTCUTS):
|
||||||
|
@ -68,6 +68,7 @@ class ReadUI:
|
|||||||
ui_operations.goto_bookpos = self.goto_bookpos.bind(self)
|
ui_operations.goto_bookpos = self.goto_bookpos.bind(self)
|
||||||
ui_operations.delete_book = self.delete_book.bind(self)
|
ui_operations.delete_book = self.delete_book.bind(self)
|
||||||
ui_operations.focus_iframe = self.focus_iframe.bind(self)
|
ui_operations.focus_iframe = self.focus_iframe.bind(self)
|
||||||
|
ui_operations.toggle_toc = self.toggle_toc.bind(self)
|
||||||
|
|
||||||
def on_resize(self):
|
def on_resize(self):
|
||||||
self.view.on_resize()
|
self.view.on_resize()
|
||||||
@ -166,6 +167,9 @@ class ReadUI:
|
|||||||
def focus_iframe(self):
|
def focus_iframe(self):
|
||||||
self.view.focus_iframe()
|
self.view.focus_iframe()
|
||||||
|
|
||||||
|
def toggle_toc(self):
|
||||||
|
self.view.overlay.show_toc()
|
||||||
|
|
||||||
def update_color_scheme(self):
|
def update_color_scheme(self):
|
||||||
self.view.update_color_scheme()
|
self.view.update_color_scheme()
|
||||||
|
|
||||||
|
@ -221,6 +221,14 @@ class View:
|
|||||||
window.history.back()
|
window.history.back()
|
||||||
elif data.name is 'forward':
|
elif data.name is 'forward':
|
||||||
window.history.forward()
|
window.history.forward()
|
||||||
|
elif data.name is 'toggle_toc':
|
||||||
|
ui_operations.toggle_toc()
|
||||||
|
elif data.name is 'toggle_bookmarks':
|
||||||
|
ui_operations.toggle_bookmarks()
|
||||||
|
elif data.name is 'toggle_inspector':
|
||||||
|
ui_operations.toggle_inspector()
|
||||||
|
elif data.name is 'toggle_lookup':
|
||||||
|
ui_operations.toggle_lookup()
|
||||||
|
|
||||||
def on_selection_change(self, data):
|
def on_selection_change(self, data):
|
||||||
self.currently_showing.selected_text = data.text
|
self.currently_showing.selected_text = data.text
|
||||||
|
@ -9,24 +9,25 @@ from gettext import gettext as _, install
|
|||||||
import initialize # noqa: unused-import
|
import initialize # noqa: unused-import
|
||||||
from ajax import ajax
|
from ajax import ajax
|
||||||
from book_list.globals import set_session_data
|
from book_list.globals import set_session_data
|
||||||
from book_list.theme import get_color, get_font_family
|
|
||||||
from book_list.library_data import library_data
|
from book_list.library_data import library_data
|
||||||
|
from book_list.theme import get_color, get_font_family
|
||||||
from dom import get_widget_css, set_css
|
from dom import get_widget_css, set_css
|
||||||
from modals import create_modal_container, error_dialog
|
from modals import create_modal_container, error_dialog
|
||||||
from qt import from_python, to_python
|
from qt import from_python, to_python
|
||||||
from read_book.db import new_book
|
from read_book.db import new_book
|
||||||
|
from read_book.footnotes import main as footnotes_main
|
||||||
from read_book.globals import runtime, ui_operations
|
from read_book.globals import runtime, ui_operations
|
||||||
from read_book.iframe import main as iframe_main
|
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.view import View
|
||||||
from read_book.footnotes import main as footnotes_main
|
|
||||||
from session import session_defaults
|
from session import session_defaults
|
||||||
from utils import encode_query_with_path, parse_url_params
|
from utils import encode_query_with_path, parse_url_params
|
||||||
from viewer.constants import FAKE_HOST, FAKE_PROTOCOL
|
from viewer.constants import FAKE_HOST, FAKE_PROTOCOL
|
||||||
|
|
||||||
|
|
||||||
runtime.is_standalone_viewer = True
|
runtime.is_standalone_viewer = True
|
||||||
runtime.FAKE_HOST = FAKE_HOST
|
runtime.FAKE_HOST = FAKE_HOST
|
||||||
runtime.FAKE_PROTOCOL = FAKE_PROTOCOL
|
runtime.FAKE_PROTOCOL = FAKE_PROTOCOL
|
||||||
|
add_standalone_viewer_shortcuts()
|
||||||
book = None
|
book = None
|
||||||
view = None
|
view = None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user