From b85b78f17d3d18887b409a3ce9d2f2c71ae68844 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 27 Jan 2015 16:53:48 +0100 Subject: Suppress Ctrl/Ctrl+Shift keypresses in line/text edits. Ctrl/Ctrl+Shift should not cause any characters to be input (as opposed to AltGr(Alt+Ctrl) as used on German keyboards). Extend the tests in QLineEdit and QPlainTextEdit to check the modifiers, remove test from QTextEdit since it is handled by QWidgetTextControl. Task-number: QTBUG-35734 Change-Id: Ie0004fac68cf840c68247f27547e84b021355cd2 Reviewed-by: Gatis Paeglis --- src/widgets/widgets/qwidgetlinecontrol.cpp | 5 ++++- src/widgets/widgets/qwidgettextcontrol.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 7033eeea22..86a830a9f9 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1879,7 +1879,10 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) unknown = false; } - if (unknown && !isReadOnly()) { + // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards + if (unknown && !isReadOnly() + && event->modifiers() != Qt::ControlModifier + && event->modifiers() != (Qt::ControlModifier | Qt::ShiftModifier)) { QString t = event->text(); if (!t.isEmpty() && t.at(0).isPrint()) { insert(t); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 8c48533a03..2e1e87be72 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1339,6 +1339,12 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e) process: { + // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards + if (e->modifiers() == Qt::ControlModifier + || e->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) { + e->ignore(); + return; + } QString text = e->text(); if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) { if (overwriteMode -- cgit v1.2.3