From 577f6ff9b45024dfdcd6383bb782340928a96d62 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 18 Apr 2022 16:41:52 +0530 Subject: [PATCH] Fix #1969302 [AltGr + { causes action of Ctrl + { in ebook editor](https://bugs.launchpad.net/calibre/+bug/1969302) --- src/calibre/gui2/tweak_book/editor/smarts/html.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/tweak_book/editor/smarts/html.py b/src/calibre/gui2/tweak_book/editor/smarts/html.py index 81058ff7d3..f64c58b8d1 100644 --- a/src/calibre/gui2/tweak_book/editor/smarts/html.py +++ b/src/calibre/gui2/tweak_book/editor/smarts/html.py @@ -675,6 +675,8 @@ class Smarts(NullSmarts): ev_text = ev.text() key = ev.key() is_xml = editor.syntax == 'xml' + mods = ev.modifiers() & ( + Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier | Qt.KeyboardModifier.MetaModifier | Qt.KeyboardModifier.KeypadModifier) if tprefs['replace_entities_as_typed'] and ( ';' in ev_text or @@ -722,7 +724,6 @@ class Smarts(NullSmarts): return True if key == Qt.Key.Key_Tab: - mods = ev.modifiers() if not mods & Qt.KeyboardModifier.ControlModifier and smart_tab(editor, ev): return True @@ -730,11 +731,10 @@ class Smarts(NullSmarts): return True if key in (Qt.Key.Key_BraceLeft, Qt.Key.Key_BraceRight): - mods = ev.modifiers() - if int(mods & Qt.KeyboardModifier.ControlModifier): + if mods == Qt.KeyboardModifier.ControlModifier: if self.jump_to_enclosing_tag(editor, key == Qt.Key.Key_BraceLeft): return True - if key == Qt.Key.Key_T and int(ev.modifiers() & (Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier)): + if key == Qt.Key.Key_T and mods == (Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier): return self.select_tag_contents(editor) return False