From 715f5418887d0e4e14bb5e80491853396132b5bd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 23 Aug 2014 08:37:28 +0530 Subject: [PATCH] Edit book: Workaround for regression in Qt 5 that causes typing the Cmd+some letter to generate text in the editor instead of being ignored. https://bugreports.qt-project.org/browse/QTBUG-40933 --- src/calibre/gui2/tweak_book/editor/text.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index e8584572e3..52a93450b2 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -17,6 +17,7 @@ from PyQt5.Qt import ( QApplication, QMimeData, QColor, QColorDialog, QTimer, pyqtSignal) from calibre import prepare_string_for_xml, xml_entity_to_unicode +from calibre.constants import isosx from calibre.gui2.tweak_book import tprefs, TOP from calibre.gui2.tweak_book.editor import ( SYNTAX_PROPERTY, SPELL_PROPERTY, SPELL_LOCALE_PROPERTY, store_locale, LINK_PROPERTY) @@ -735,6 +736,11 @@ class TextEdit(PlainTextEdit): self.setOverwriteMode(self.overwriteMode() ^ True) ev.accept() return + if isosx and ev.modifiers() == Qt.ControlModifier and re.search(r'[a-zA-Z0-9]+', ev.text()) is not None: + # For some reason Qt 5 translates Cmd+key into text on OS X + # https://bugreports.qt-project.org/browse/QTBUG-40933 + ev.setAccepted(False) + return QPlainTextEdit.keyPressEvent(self, ev) if (ev.key() == Qt.Key_Semicolon or ';' in unicode(ev.text())) and tprefs['replace_entities_as_typed'] and self.syntax == 'html': self.replace_possible_entity()