diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-07-30 13:32:53 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-07-31 09:03:26 +0200 |
commit | b5ce3d504c4cfe46725bfbcb4bfa37c7456a67c9 (patch) | |
tree | 266c500f28dcad2acca94520ba954b5f7cfeed42 /src/plugins/platforms/windows/qwindowsinputcontext.cpp | |
parent | 2eea6034bc98e201694cb419f606331e4ad07624 (diff) |
Windows plugin: Refactor input context.
- Use static invocation of QGuiApplication accessor.
- Use QInputMethod::queryFocusObject().
Task-number: QTBUG-40402
Change-Id: Ic1a7f66389df532acca88ddda37d35d6e7049a53
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsinputcontext.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsinputcontext.cpp | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 2429e8a4fa..bc7ffc9afd 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -88,18 +88,6 @@ static inline void imeNotifyCancelComposition(HWND hwnd) ImmReleaseContext(hwnd, himc); } -// Query a QObject for an InputMethod-related value -// by sending a QInputMethodQueryEvent. -template <class T> - bool inputMethodQuery(QObject *fo, Qt::InputMethodQuery query, T *result) -{ - QInputMethodQueryEvent queryEvent(query); - if (!QCoreApplication::sendEvent(fo, &queryEvent)) - return false; - *result = qvariant_cast<T>(queryEvent.value(query)); - return true; -} - /*! \class QWindowsInputContext \brief Windows Input context implementation @@ -170,7 +158,7 @@ QWindowsInputContext::QWindowsInputContext() : m_WM_MSIME_MOUSE(RegisterWindowMessage(L"MSIMEMouseOperation")), m_endCompositionRecursionGuard(false) { - connect(qApp->inputMethod(), SIGNAL(cursorRectangleChanged()), + connect(QGuiApplication::inputMethod(), SIGNAL(cursorRectangleChanged()), this, SLOT(cursorRectChanged())); } @@ -215,7 +203,7 @@ void QWindowsInputContext::cursorRectChanged() { if (!m_compositionContext.hwnd) return; - const QInputMethod *inputMethod = qApp->inputMethod(); + const QInputMethod *inputMethod = QGuiApplication::inputMethod(); QRect cursorRectangle = inputMethod->cursorRectangle().toRect(); if (!cursorRectangle.isValid()) return; @@ -536,9 +524,10 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv) if (!fo) return false; - QString surroundingText; - if (!inputMethodQuery(fo, Qt::ImSurroundingText, &surroundingText)) + const QVariant surroundingTextV = QInputMethod::queryFocusObject(Qt::ImSurroundingText, QVariant()); + if (!surroundingTextV.isValid()) return -1; + const QString surroundingText = surroundingTextV.toString(); const DWORD memSize = sizeof(RECONVERTSTRING) + (surroundingText.length() + 1) * sizeof(ushort); qCDebug(lcQpaInputMethods) << __FUNCTION__ << " reconv=" << reconv @@ -547,8 +536,8 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv) if (!reconv) return surroundingText.isEmpty() ? -1 : int(memSize); - int pos = 0; - inputMethodQuery(fo, Qt::ImCursorPosition, &pos); + const QVariant posV = QInputMethod::queryFocusObject(Qt::ImCursorPosition, QVariant()); + const int pos = posV.isValid() ? posV.toInt() : 0; // Find the word in the surrounding text. QTextBoundaryFinder bounds(QTextBoundaryFinder::Word, surroundingText); bounds.setPosition(pos); |