summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qinputpanel.cpp
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2012-01-20 17:57:21 +0200
committerQt by Nokia <qt-info@nokia.com>2012-01-27 13:27:54 +0100
commitdd565d2d4c7e9b766bc9f575d803ebaad71b33b7 (patch)
treeb81f8b84e26c8b433759e6f97cdcacd0c5419dd0 /src/gui/kernel/qinputpanel.cpp
parente7d0d54084aa04387ebfb8cee292248df5355021 (diff)
QGuiApplication::focusObject() to replace QInputPanel::inputItem()
* Deprecated QInputPanel::inputWindow() which is already just returning QGuiApplication::activeWindow() * Deprecated QInputPanel::inputItem() and introduced QGuiApplication::focusObject(). Input methods can check input method support by Qt::ImEnabled query. Change-Id: I70a9c1c3f79aadb75c839d0489a9428f7a221df5 Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
Diffstat (limited to 'src/gui/kernel/qinputpanel.cpp')
-rw-r--r--src/gui/kernel/qinputpanel.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/gui/kernel/qinputpanel.cpp b/src/gui/kernel/qinputpanel.cpp
index dbc12b04ba..76fc0139c7 100644
--- a/src/gui/kernel/qinputpanel.cpp
+++ b/src/gui/kernel/qinputpanel.cpp
@@ -41,6 +41,8 @@
#include <qinputpanel.h>
#include <private/qinputpanel_p.h>
+#include <qguiapplication.h>
+#include <qtimer.h>
QT_BEGIN_NAMESPACE
@@ -50,6 +52,8 @@ QT_BEGIN_NAMESPACE
QInputPanel::QInputPanel()
: QObject(*new QInputPanelPrivate)
{
+ // might be instantiated before QGuiApplication is fully done, need to connect later
+ QTimer::singleShot(0, this, SLOT(q_connectFocusObject()));
}
/*!
@@ -74,6 +78,7 @@ QInputPanel::~QInputPanel()
/*!
\property QInputPanel::inputItem
\brief Focused item that accepts text input
+ \obsolete
Input item is set and unset by the focused window. In QML Scene Graph this is done by
QQuickCanvas and the input item is either TextInput or TextEdit element. Any QObject can
@@ -101,6 +106,8 @@ void QInputPanel::setInputItem(QObject *inputItem)
/*!
Returns the currently focused window containing the input item.
+
+ \obsolete
*/
QWindow *QInputPanel::inputWindow() const
{
@@ -288,8 +295,8 @@ void QInputPanel::update(Qt::InputMethodQueries queries)
{
Q_D(QInputPanel);
- if (!d->inputItem)
- return;
+ if (queries & Qt::ImEnabled)
+ d->q_checkFocusObject(qApp->focusObject());
QPlatformInputContext *ic = d->platformInputContext();
if (ic)
@@ -342,6 +349,28 @@ void QInputPanel::invokeAction(Action a, int cursorPosition)
ic->invokeAction(a, cursorPosition);
}
+// temporary handlers for updating focus item based on application focus
+void QInputPanelPrivate::q_connectFocusObject()
+{
+ Q_Q(QInputPanel);
+ QObject::connect(qApp, SIGNAL(focusObjectChanged(QObject*)),
+ q, SLOT(q_checkFocusObject(QObject*)));
+ q_checkFocusObject(qApp->focusObject());
+}
+
+void QInputPanelPrivate::q_checkFocusObject(QObject *object)
+{
+ Q_Q(QInputPanel);
+
+ bool enabled = false;
+ if (object) {
+ QInputMethodQueryEvent query(Qt::ImEnabled);
+ QGuiApplication::sendEvent(object, &query);
+ enabled = query.value(Qt::ImEnabled).toBool();
+ }
+ q->setInputItem(enabled ? object : 0);
+}
+
QT_END_NAMESPACE
#include "moc_qinputpanel.cpp"