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)
|
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):
|
def get_key_text(evt):
|
||||||
key = evt.key
|
key = evt.key
|
||||||
if key:
|
if key:
|
||||||
cc = key.charCodeAt(0)
|
# on Windows pressing ctrl+alt+ascii char gives capital letters. On all
|
||||||
# on windows in webengine pressing ctrl+ascii char gives us an ascii
|
# platforms shift+key gives capital letters # we define shortcuts using
|
||||||
# control code
|
# lowercase letters, so lowercase them here.
|
||||||
# see https://bugreports.qt.io/browse/QTBUG-81783
|
if evt.code and key.toLowerCase() is not key and evt.code.startsWith('Key') and capital_letters[key]:
|
||||||
if (0 < cc < 32 or key is 'Enter' or key is 'Tab') and evt.ctrlKey and not evt.metaKey and not evt.altKey:
|
key = key.toLowerCase()
|
||||||
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)
|
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
|
||||||
@ -191,7 +186,7 @@ def shortcuts_definition():
|
|||||||
),
|
),
|
||||||
|
|
||||||
'copy_to_clipboard': desc(
|
'copy_to_clipboard': desc(
|
||||||
'Ctrl+C',
|
'Ctrl+c',
|
||||||
'ui',
|
'ui',
|
||||||
_('Copy to clipboard'),
|
_('Copy to clipboard'),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user