Skip to content

Commit

Permalink
Edit book: Workaround for regression in Qt 5 that causes typing the C…
Browse files Browse the repository at this point in the history
…md+some letter to generate text in the editor instead of being ignored.

https://bugreports.qt-project.org/browse/QTBUG-40933
  • Loading branch information
kovidgoyal committed Aug 23, 2014
1 parent 683106f commit 715f541
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/calibre/gui2/tweak_book/editor/text.py
Expand Up @@ -17,6 +17,7 @@
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)
Expand Down Expand Up @@ -735,6 +736,11 @@ def keyPressEvent(self, ev):
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()
Expand Down

0 comments on commit 715f541

Please sign in to comment.