summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@digia.com>2013-03-22 10:53:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-22 19:52:26 +0100
commit0c645f1345d88b7c2bc2bdc77ef599b60ba3be7a (patch)
treec2a9c778ead0d32aa319a3d643c487098f20cf35 /src/plugins/platforms/android
parent1f180e9690a0a5f6cc849c1988ccda13de1b1e20 (diff)
Inform android input method when cursor is moved
Google Japanese Input Beta keeps track of the cursor position, and bails out if the cursor is not where it thinks it should be. We have to tell the IM every time we move the cursor, not only when we are composing. Change-Id: I9cdb28f81c76e76d3b0125d08bf0595616ca443f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/plugins/platforms/android')
-rw-r--r--src/plugins/platforms/android/src/qandroidinputcontext.cpp9
-rw-r--r--src/plugins/platforms/android/src/qandroidinputcontext.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/platforms/android/src/qandroidinputcontext.cpp b/src/plugins/platforms/android/src/qandroidinputcontext.cpp
index 37fb605ea8..2180560b04 100644
--- a/src/plugins/platforms/android/src/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/src/qandroidinputcontext.cpp
@@ -337,7 +337,10 @@ void QAndroidInputContext::reset()
void QAndroidInputContext::commit()
{
finishComposingText();
+}
+void QAndroidInputContext::updateCursorPosition()
+{
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery();
if (!query.isNull()) {
const int cursorPos = query->value(Qt::ImCursorPosition).toInt();
@@ -378,6 +381,12 @@ void QAndroidInputContext::showInputPanel()
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery();
if (query.isNull())
return;
+
+ disconnect(m_updateCursorPosConnection);
+ if (qGuiApp->focusObject()->metaObject()->indexOfSignal("cursorPositionChanged(int,int)") >= 0) // QLineEdit breaks the pattern
+ m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(updateCursorPosition()));
+ else
+ m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
QRectF itemRect = qGuiApp->inputMethod()->inputItemRectangle();
QRect rect = qGuiApp->inputMethod()->inputItemTransform().mapRect(itemRect).toRect();
QWindow *window = qGuiApp->focusWindow();
diff --git a/src/plugins/platforms/android/src/qandroidinputcontext.h b/src/plugins/platforms/android/src/qandroidinputcontext.h
index e2b8107044..482aeffa50 100644
--- a/src/plugins/platforms/android/src/qandroidinputcontext.h
+++ b/src/plugins/platforms/android/src/qandroidinputcontext.h
@@ -119,10 +119,12 @@ private:
private slots:
virtual void sendEvent(QObject *receiver, QInputMethodEvent *event);
virtual void sendEvent(QObject *receiver, QInputMethodQueryEvent *event);
+ void updateCursorPosition();
private:
ExtractedText m_extractedText;
QString m_composingText;
+ QMetaObject::Connection m_updateCursorPosConnection;
};
QT_END_NAMESPACE