mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Fix keyboard shortcuts using ctrl+alt+letter key not working on windows. Fixes #1900946 [E-book viewer: the "Create a new bookmark" shortcut only works after removing and recreating](https://bugs.launchpad.net/calibre/+bug/1900946)
This commit is contained in:
parent
19035570b7
commit
bdc5554ca9
@ -45,22 +45,17 @@ def shortcut_differs(a, b):
|
||||
return not (a.key is b.key and a.altKey is b.altKey and a.ctrlKey is b.ctrlKey and a.metaKey is b.metaKey and a.shiftKey is b.shiftKey)
|
||||
|
||||
|
||||
capital_letters = {x: True for x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
|
||||
|
||||
|
||||
def get_key_text(evt):
|
||||
key = evt.key
|
||||
if key:
|
||||
cc = key.charCodeAt(0)
|
||||
# on windows in webengine pressing ctrl+ascii char gives us an ascii
|
||||
# control code
|
||||
# see https://bugreports.qt.io/browse/QTBUG-81783
|
||||
if (0 < cc < 32 or key is 'Enter' or key is 'Tab') and evt.ctrlKey and not evt.metaKey and not evt.altKey:
|
||||
if key is 'Enter':
|
||||
if evt.code and evt.code is not 'Enter':
|
||||
key = 'm'
|
||||
elif key is 'Tab':
|
||||
if evt.code and evt.code is not 'Tab':
|
||||
key = 'i'
|
||||
else:
|
||||
key = chr(96 + cc)
|
||||
# on Windows pressing ctrl+alt+ascii char gives capital letters. On all
|
||||
# platforms shift+key gives capital letters # we define shortcuts using
|
||||
# lowercase letters, so lowercase them here.
|
||||
if evt.code and key.toLowerCase() is not key and evt.code.startsWith('Key') and capital_letters[key]:
|
||||
key = key.toLowerCase()
|
||||
return key
|
||||
|
||||
|
||||
@ -191,7 +186,7 @@ def shortcuts_definition():
|
||||
),
|
||||
|
||||
'copy_to_clipboard': desc(
|
||||
'Ctrl+C',
|
||||
'Ctrl+c',
|
||||
'ui',
|
||||
_('Copy to clipboard'),
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user