mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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
This commit is contained in:
parent
683106fd89
commit
715f541888
@ -17,6 +17,7 @@ from PyQt5.Qt import (
|
|||||||
QApplication, QMimeData, QColor, QColorDialog, QTimer, pyqtSignal)
|
QApplication, QMimeData, QColor, QColorDialog, QTimer, pyqtSignal)
|
||||||
|
|
||||||
from calibre import prepare_string_for_xml, xml_entity_to_unicode
|
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 import tprefs, TOP
|
||||||
from calibre.gui2.tweak_book.editor import (
|
from calibre.gui2.tweak_book.editor import (
|
||||||
SYNTAX_PROPERTY, SPELL_PROPERTY, SPELL_LOCALE_PROPERTY, store_locale, LINK_PROPERTY)
|
SYNTAX_PROPERTY, SPELL_PROPERTY, SPELL_LOCALE_PROPERTY, store_locale, LINK_PROPERTY)
|
||||||
@ -735,6 +736,11 @@ class TextEdit(PlainTextEdit):
|
|||||||
self.setOverwriteMode(self.overwriteMode() ^ True)
|
self.setOverwriteMode(self.overwriteMode() ^ True)
|
||||||
ev.accept()
|
ev.accept()
|
||||||
return
|
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)
|
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':
|
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()
|
self.replace_possible_entity()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user