From 34cb6901638eb65e4db742ea70bbc0fe3e55e366 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Thu, 15 Dec 2011 15:11:55 +0200 Subject: [PATCH] Adapt from QInputContext interface to QInputPanel Change-Id: I4143c3b516e7b0e46c706b8a6560bca9d8951572 Reviewed-by: Lars Knoll Reviewed-by: Joona Petrell --- src/widgets/widgets/qwidgettextcontrol.cpp | 50 ++++++++++------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 2a6831eb93..e2be1cb2bf 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -1688,11 +1689,8 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button emit q->cursorPositionChanged(); _q_updateCurrentCharFormatAndSelection(); #ifndef QT_NO_IM - if (contextWidget) { - if (QInputContext *ic = qApp->inputContext()) { - ic->update(); - } - } + if (contextWidget) + qApp->inputPanel()->update(Qt::ImQueryInput); #endif //QT_NO_IM } else { //emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1))); @@ -1821,34 +1819,32 @@ bool QWidgetTextControlPrivate::sendMouseEventToInputContext( QEvent *e, QEvent::Type eventType, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos) { -#if !defined(QT_NO_IM) - Q_Q(QWidgetTextControl); - - if (contextWidget && isPreediting()) { - QTextLayout *layout = cursor.block().layout(); - QInputContext *ctx = qApp->inputContext(); - int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position(); - - if (cursorPos < 0 || cursorPos > layout->preeditAreaText().length()) - cursorPos = -1; - - if (ctx && cursorPos >= 0) { - QMouseEvent ev(eventType, contextWidget->mapFromGlobal(globalPos), - contextWidget->topLevelWidget()->mapFromGlobal(globalPos), globalPos, - button, buttons, modifiers); - ctx->mouseHandler(cursorPos, &ev); - e->setAccepted(ev.isAccepted()); - return true; - } - } -#else - Q_UNUSED(e); Q_UNUSED(eventType); Q_UNUSED(button); Q_UNUSED(pos); Q_UNUSED(modifiers); Q_UNUSED(buttons); Q_UNUSED(globalPos); +#if !defined(QT_NO_IM) + Q_Q(QWidgetTextControl); + + if (contextWidget && isPreediting()) { + QTextLayout *layout = cursor.block().layout(); + int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position(); + + if (cursorPos < 0 || cursorPos > layout->preeditAreaText().length()) + cursorPos = -1; + + if (cursorPos >= 0) { + if (e->type() == QEvent::MouseButtonRelease) + qApp->inputPanel()->invokeAction(QInputPanel::Click, cursorPos); + + e->setAccepted(true); + return true; + } + } +#else + Q_UNUSED(e); #endif return false; }