aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-09-07 19:58:14 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-09-08 10:33:31 +0200
commit70cc5c9b7b420ecaf099d5d08fb1b4e8ad81a920 (patch)
tree104c52e5e150b4720a3759f0377366016cf1d03b /src/declarative/items
parent27fc1e1335a1b19f205fd5e08a1bd29dfebb2dee (diff)
Adapt to the input method changes in qtbase
Start using the QInputPanel instead of the QPlatformInputContext. Make sure we do something with both QInputMethodEvent and QInputMethodQueryEvent. This gets input methods partially working on TextInput fields. Change-Id: I4655f5599673325ffb75207573635afccd069a65 Reviewed-on: http://codereview.qt-project.org/4404 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Vesa Rantanen <vesa.rantanen@nokia.com> Reviewed-by: Andy Nichols Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/declarative/items')
-rw-r--r--src/declarative/items/qsgcanvas.cpp19
-rw-r--r--src/declarative/items/qsgitem.cpp52
-rw-r--r--src/declarative/items/qsgtextinput.cpp11
3 files changed, 48 insertions, 34 deletions
diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp
index 4707ad2cff..979fc161bc 100644
--- a/src/declarative/items/qsgcanvas.cpp
+++ b/src/declarative/items/qsgcanvas.cpp
@@ -51,7 +51,7 @@
#include <private/qsgflashnode_p.h>
#include <private/qguiapplication_p.h>
-#include <QtGui/QPlatformInputContext>
+#include <QtGui/QInputPanel>
#include <private/qabstractanimation_p.h>
@@ -335,9 +335,8 @@ bool QSGCanvas::vsyncAnimations() const
*/
void QSGCanvasPrivate::updateInputContext()
{
- QPlatformInputContext *ic = QGuiApplicationPrivate::platformIntegration()->inputContext();
- if (ic)
- ic->update();
+ // ### finer grained updates would be good
+ qApp->inputPanel()->update(Qt::ImQueryAll);
}
/*!
This function is an attempt to localize all uses of QInputContext::reset in
@@ -345,9 +344,7 @@ void QSGCanvasPrivate::updateInputContext()
*/
void QSGCanvasPrivate::resetInputContext()
{
- QPlatformInputContext *ic = QGuiApplicationPrivate::platformIntegration()->inputContext();
- if (ic)
- ic->reset();
+ qApp->inputPanel()->reset();
}
@@ -731,12 +728,8 @@ void QSGCanvasPrivate::notifyFocusChangesRecur(QSGItem **items, int remaining)
void QSGCanvasPrivate::updateInputMethodData()
{
- // Q_Q(QSGCanvas);
- // ### refactor: port..
-// bool enabled = activeFocusItem
-// && (QSGItemPrivate::get(activeFocusItem)->flags & QSGItem::ItemAcceptsInputMethod);
-// q->setAttribute(Qt::WA_InputMethodEnabled, enabled);
-// q->setInputMethodHints(enabled ? activeFocusItem->inputMethodHints() : Qt::ImhNone);
+ qApp->inputPanel()->setInputItem(activeFocusItem);
+ qApp->inputPanel()->setInputItemTranform(QSGItemPrivate::get(activeFocusItem)->itemToCanvasTransform());
}
QVariant QSGCanvas::inputMethodQuery(Qt::InputMethodQuery query) const
diff --git a/src/declarative/items/qsgitem.cpp b/src/declarative/items/qsgitem.cpp
index 765fe349ca..2a5486b859 100644
--- a/src/declarative/items/qsgitem.cpp
+++ b/src/declarative/items/qsgitem.cpp
@@ -53,6 +53,8 @@
#include <QtDeclarative/qdeclarativeinfo.h>
#include <QtGui/qpen.h>
#include <QtGui/qcursor.h>
+#include <QtGui/qguiapplication.h>
+#include <QtGui/qinputpanel.h>
#include <QtCore/qdebug.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qnumeric.h>
@@ -2926,20 +2928,16 @@ void QSGItem::setInputMethodHints(Qt::InputMethodHints hints)
if (!d->canvas || d->canvas->activeFocusItem() != this)
return;
- QSGCanvasPrivate *cd = QSGCanvasPrivate::get(d->canvas);
- cd->updateInputMethodData();
-#ifndef QT_NO_IM
- cd->updateInputContext();
-#endif
+ QInputPanel *p = qApp->inputPanel();
+ if (p->inputItem() == this)
+ qApp->inputPanel()->update(Qt::ImHints);
}
void QSGItem::updateMicroFocus()
{
-#ifndef QT_NO_IM
- Q_D(QSGItem);
- if (d->canvas)
- QSGCanvasPrivate::get(d->canvas)->updateInputContext();
-#endif
+ QInputPanel *p = qApp->inputPanel();
+ if (p->inputItem() == this)
+ qApp->inputPanel()->update(Qt::ImMicroFocus);
}
QVariant QSGItem::inputMethodQuery(Qt::InputMethodQuery query) const
@@ -2947,8 +2945,26 @@ QVariant QSGItem::inputMethodQuery(Qt::InputMethodQuery query) const
Q_D(const QSGItem);
QVariant v;
- if (d->keyHandler)
- v = d->keyHandler->inputMethodQuery(query);
+ switch (query) {
+ case Qt::ImEnabled:
+ v = (bool)(flags() & ItemAcceptsInputMethod);
+ break;
+ case Qt::ImHints:
+ v = (int)inputMethodHints();
+ break;
+ case Qt::ImMicroFocus:
+ case Qt::ImFont:
+ case Qt::ImCursorPosition:
+ case Qt::ImSurroundingText:
+ case Qt::ImCurrentSelection:
+ case Qt::ImMaximumTextLength:
+ case Qt::ImAnchorPosition:
+ case Qt::ImPreferredLanguage:
+ if (d->keyHandler)
+ v = d->keyHandler->inputMethodQuery(query);
+ default:
+ break;
+ }
return v;
}
@@ -4876,8 +4892,6 @@ QRectF QSGItem::mapRectFromScene(const QRectF &rect) const
bool QSGItem::event(QEvent *ev)
{
- return QObject::event(ev);
-
#if 0
if (ev->type() == QEvent::PolishRequest) {
Q_D(QSGItem);
@@ -4888,6 +4902,16 @@ bool QSGItem::event(QEvent *ev)
return QObject::event(ev);
}
#endif
+ if (ev->type() == QEvent::InputMethodQuery) {
+ QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(ev);
+ query->setValue(inputMethodQuery(query->query()));
+ ev->accept();
+ return true;
+ } else if (ev->type() == QEvent::InputMethod) {
+ inputMethodEvent(static_cast<QInputMethodEvent *>(ev));
+ return true;
+ }
+ return QObject::event(ev);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/declarative/items/qsgtextinput.cpp b/src/declarative/items/qsgtextinput.cpp
index 22ee3c805d..9974094e5b 100644
--- a/src/declarative/items/qsgtextinput.cpp
+++ b/src/declarative/items/qsgtextinput.cpp
@@ -52,9 +52,8 @@
#include <qsgtextnode_p.h>
#include <qsgsimplerectnode.h>
-#include <QtGui/qplatforminputcontext_qpa.h>
-#include <private/qguiapplication_p.h>
#include <QtGui/qstylehints.h>
+#include <QtGui/qinputpanel.h>
QT_BEGIN_NAMESPACE
@@ -1164,7 +1163,7 @@ void QSGTextInput::mouseReleaseEvent(QMouseEvent *event)
bool QSGTextInputPrivate::sendMouseEventToInputContext(QMouseEvent *event)
{
#if !defined QT_NO_IM
- if (control->composeMode()) {
+ if (control->composeMode() && event->type() == QEvent::KeyRelease) {
int tmp_cursor = xToPos(event->localPos().x());
int mousePos = tmp_cursor - control->cursor();
if (mousePos < 0 || mousePos > control->preeditAreaText().length()) {
@@ -1174,10 +1173,8 @@ bool QSGTextInputPrivate::sendMouseEventToInputContext(QMouseEvent *event)
return true;
}
- QPlatformInputContext *ic = QGuiApplicationPrivate::platformIntegration()->inputContext();
- if (ic)
- // may be causing reset() in some input methods
- ic->mouseHandler(mousePos, event);
+ // may be causing reset() in some input methods
+ qApp->inputPanel()->invokeAction(QInputPanel::Click, mousePos);
if (!control->preeditAreaText().isEmpty())
return true;
}