summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-07-06 15:59:37 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-07-08 12:18:24 +0000
commitc0db9e9082d9b8adededbc3694b02129e9b47020 (patch)
treed0b2018523dd6c6b194a76a091a2d90fc4a29118 /src/widgets/kernel/qwidget.cpp
parentc9c3f578831ed6876fc98d08067ff410406df9e6 (diff)
QWidget: use WA_InputMethodEnabled when ImEnabled is not implemented
In Qt 6.3, a check for WA_InputMethodEnabled was removed in QWidget, to support IM queries also for read-only widgets (7c6e4af48). This caused a regression on iOS, which made the input panel open for widgets that didn't support IM at all. A patch was merged that solved the regression (3b12305575), but it didn't take the widget attribute into account. Since not doing so has the potential to cause regressions, this patch will modify the affected code once more, so that we instead fall back to test WA_InputMethodEnabled when ImEnabled is not implemented. This will match closely to the way ImEnabled was implemented in Qt 6.2. Since we, with this change, now require that either ImEnabled or WA_InputMethodEnabled is set, our own input widgets will fail to support IM text selection when they're read-only, since they actually don't implement ImEnabled. This patch will therefore also make sure that we do so. Task-number: QTBUG-104527 Change-Id: I70ad910aec38d0a74f4dd7d3115d3c45c16d2b3b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit e44edaac2c575df9b2f065b18b716cb21a0c2b75) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 1160471194..f0da19f9c8 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -8898,15 +8898,12 @@ bool QWidget::event(QEvent *event)
QVariant v = inputMethodQuery(q);
if (q == Qt::ImEnabled && !v.isValid() && isEnabled()) {
// Qt:ImEnabled was added in Qt 5.3. So not all widgets support it, even
- // if they implement IM otherwise (and override inputMethodQuery()).
- // So for legacy reasons, we need to check by other means if IM is supported when
- // Qt::ImEnabled is not implemented (the query returns an invalid QVariant).
- // Since QWidget implements inputMethodQuery(), and return valid values for
- // some of the IM properties, we cannot just query for Qt::ImQueryAll.
- // Instead we assume that if a widget supports IM, it will implement
- // Qt::ImSurroundingText (which is not implemented by QWidget).
- const bool imEnabledFallback = inputMethodQuery(Qt::ImSurroundingText).isValid();
- v = QVariant(imEnabledFallback);
+ // if they implement IM otherwise (by overriding inputMethodQuery()). Instead
+ // they set the widget attribute Qt::WA_InputMethodEnabled. But this attribute
+ // will only be set if the widget supports IM _and_ is not read-only. So for
+ // read-only widgets, not all IM features will be supported when ImEnabled is
+ // not implemented explicitly (e.g selection handles for read-only widgets on iOS).
+ v = QVariant(testAttribute(Qt::WA_InputMethodEnabled));
}
query->setValue(q, v);
}