E-book viewer: Selection bar: Add keyboard shortcuts for all buttons. Hover over a button in the bar to see the shortcut.

This commit is contained in:
Kovid Goyal 2021-03-30 22:36:28 +05:30
parent 098885a465
commit 76364ec4c6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -184,17 +184,17 @@ def all_actions():
if not all_actions.ans:
all_actions.ans = {
'copy': a('copy', _('Copy to clipboard'), 'copy_to_clipboard'),
'lookup': a('library', _('Lookup/search selected word'), 'lookup'),
'quick_highlight': a('highlight', _('Quick highlight in current style'), 'quick_highlight'),
'highlight': a('highlight', _('Highlight selection'), 'create_highlight'),
'search': a('search', _('Search for selection in the book'), 'book_search'),
'bookmark': a('bookmark', _('Create a bookmark'), 'new_bookmark'),
'search_net': a('global-search', _('Search for selection on the net'), 'internet_search'),
'remove_highlight': a('trash', _('Remove this highlight'), 'remove_highlight', True),
'clear': a('close', _('Clear selection'), 'clear_selection'),
'speak': a('bullhorn', _('Read aloud'), 'speak_aloud'),
'cite': a('reference-mode', _('Copy citation to clipboard'), 'cite'),
'copy': a('copy', _('Copy to clipboard') + ' [Ctrl+c]', 'copy_to_clipboard'),
'lookup': a('library', _('Lookup/search selected word') + ' [l]', 'lookup'),
'quick_highlight': a('highlight', _('Quick highlight in current style') + ' [q]', 'quick_highlight'),
'highlight': a('highlight', _('Highlight selection') + ' [h]', 'create_highlight'),
'search': a('search', _('Search for selection in the book') + ' [f]', 'book_search'),
'bookmark': a('bookmark', _('Create a bookmark') + ' [Ctrl+Alt+b]', 'new_bookmark'),
'search_net': a('global-search', _('Search for selection on the net') + ' [s]', 'internet_search'),
'remove_highlight': a('trash', _('Remove this highlight') + ' [Delete]', 'remove_highlight', True),
'clear': a('close', _('Clear selection') + ' [Esc]', 'clear_selection'),
'speak': a('bullhorn', _('Read aloud') + ' [t]', 'speak_aloud'),
'cite': a('reference-mode', _('Copy citation to clipboard') + ' [x]', 'cite'),
}
qh = all_actions.ans.quick_highlight
qh.icon_function = quick_highlight_icon.bind(None, qh.icon, qh.text)
@ -569,11 +569,31 @@ class SelectionBar:
else:
self.clear_selection()
return
if ev.key is 'Delete' and self.state is WAITING:
self.remove_highlight()
if self.state is WAITING and not ev.ctrlKey and not ev.altKey and not ev.metaKey:
k = ev.key.toLowerCase()
if k is 'l':
self.lookup()
return
if ev.key and ev.key.toLowerCase() is 'c' and ev.ctrlKey:
self.copy_to_clipboard()
if k is 'q':
self.quick_highlight()
return
if k is 'h':
self.create_highlight()
return
if k is 'f':
self.book_search()
return
if k is 's':
self.internet_search()
return
if k is 't':
self.speak_aloud()
return
if k is 'x':
self.cite()
return
if k is 'Delete':
self.remove_highlight()
return
sc_name = shortcut_for_key_event(ev, self.view.keyboard_shortcut_map)
if not sc_name: