diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-01 17:51:32 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-01 17:51:32 +0200 |
commit | 2e02692ec206a856f56538cfafb2a7bd2734523c (patch) | |
tree | 9c7cbb3ba8c232f3fa346fc3cd704d4279a9fa20 /src/gui | |
parent | 5b99f3a34fef527beb8767eb12657f81ee65b969 (diff) | |
parent | 07e92611050f78dae93bcd362112efd8efa7b41e (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: Ic8cdb1c2b7c0a786b1313b6c3a3bf7e9ec288712
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 14 | ||||
-rw-r--r-- | src/gui/kernel/qinputmethod.cpp | 18 | ||||
-rw-r--r-- | src/gui/kernel/qinputmethod_p.h | 2 |
3 files changed, 19 insertions, 15 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 9bf2a33e2a..34f453341f 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -84,6 +84,7 @@ #include "private/qcursor_p.h" #include "private/qopenglcontext_p.h" #include "private/qinputdevicemanager_p.h" +#include "private/qinputmethod_p.h" #include "private/qtouchdevice_p.h" #include <qpa/qplatformthemefactory_p.h> @@ -4030,18 +4031,7 @@ void QGuiApplicationPrivate::_q_updateFocusObject(QObject *object) Q_Q(QGuiApplication); QPlatformInputContext *inputContext = platformIntegration()->inputContext(); - bool enabled = false; - if (object && inputContext) { - QInputMethodQueryEvent query(Qt::ImEnabled | Qt::ImHints); - QGuiApplication::sendEvent(object, &query); - enabled = query.value(Qt::ImEnabled).toBool(); - if (enabled) { - static const bool supportsHiddenText = inputContext->hasCapability(QPlatformInputContext::HiddenTextCapability); - const Qt::InputMethodHints hints = static_cast<Qt::InputMethodHints>(query.value(Qt::ImHints).toInt()); - if ((hints & Qt::ImhHiddenText) && !supportsHiddenText) - enabled = false; - } - } + const bool enabled = inputContext && QInputMethodPrivate::objectAcceptsInputMethod(object); QPlatformInputContextPrivate::setInputMethodAccepted(enabled); if (inputContext) diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp index 365b088840..a319529442 100644 --- a/src/gui/kernel/qinputmethod.cpp +++ b/src/gui/kernel/qinputmethod.cpp @@ -390,15 +390,29 @@ void QInputMethod::invokeAction(Action a, int cursorPosition) ic->invokeAction(a, cursorPosition); } +static inline bool platformSupportsHiddenText() +{ + const QPlatformInputContext *inputContext = QGuiApplicationPrivate::platformIntegration()->inputContext(); + return inputContext && inputContext->hasCapability(QPlatformInputContext::HiddenTextCapability); +} + bool QInputMethodPrivate::objectAcceptsInputMethod(QObject *object) { bool enabled = false; if (object) { - QInputMethodQueryEvent query(Qt::ImEnabled); + // If the platform does not support hidden text, query the hints + // in addition and disable in case of ImhHiddenText. + static const bool supportsHiddenText = platformSupportsHiddenText(); + QInputMethodQueryEvent query(supportsHiddenText + ? Qt::InputMethodQueries(Qt::ImEnabled) + : Qt::InputMethodQueries(Qt::ImEnabled | Qt::ImHints)); QGuiApplication::sendEvent(object, &query); enabled = query.value(Qt::ImEnabled).toBool(); + if (enabled && !supportsHiddenText + && Qt::InputMethodHints(query.value(Qt::ImHints).toInt()).testFlag(Qt::ImhHiddenText)) { + enabled = false; + } } - return enabled; } diff --git a/src/gui/kernel/qinputmethod_p.h b/src/gui/kernel/qinputmethod_p.h index 81723bbe30..0c2b739d92 100644 --- a/src/gui/kernel/qinputmethod_p.h +++ b/src/gui/kernel/qinputmethod_p.h @@ -80,7 +80,7 @@ public: void _q_connectFocusObject(); void _q_checkFocusObject(QObject *object); - bool objectAcceptsInputMethod(QObject *object); + static bool objectAcceptsInputMethod(QObject *object); QTransform inputItemTransform; QRectF inputRectangle; |