Use QInputMethod instead of deprecated QInputPanel
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>
Fri, 3 Feb 2012 08:07:51 +0000 (10:07 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 10 Feb 2012 08:54:58 +0000 (09:54 +0100)
Similarly deprecate Qt.application.inputPanel and
introduce replacement Qt.inputMethod.

Change-Id: Ie4fd467f93f75023c86b0a2d038d858fe5001146
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Sami Kananoja <sami.kananoja@nokia.com>

19 files changed:
doc/src/declarative/righttoleft.qdoc
src/declarative/qml/qdeclarativeapplication.cpp
src/declarative/qml/qdeclarativeapplication_p.h
src/declarative/qml/qdeclarativeengine.cpp
src/declarative/qml/v8/qv8engine.cpp
src/declarative/qml/v8/qv8engine_p.h
src/quick/items/qquickcanvas.cpp
src/quick/items/qquickitem.cpp
src/quick/items/qquicktext.cpp
src/quick/items/qquicktextcontrol.cpp
src/quick/items/qquicktextedit.cpp
src/quick/items/qquicktextinput.cpp
src/quick/items/qquicktextinput_p_p.h
src/quick/util/qdeclarativeutilmodule.cpp
tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp
tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp
tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp
tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp
tests/auto/shared/platforminputcontext.h

index 7d11ae7..43a7457 100644 (file)
@@ -58,7 +58,7 @@ When the horizontal alignment of a text item is not explicitly set, the text ele
 automatically aligned to the natural reading direction of the text. By default left-to-right text
 like English is aligned to the left side of the text area, and right-to-left text like Arabic is
 aligned to the right side of the text area. The alignment of a text element with empty text takes
-its alignment cue from \l QInputPanel::inputDirection(), which is based on the active
+its alignment cue from \l QInputMethod::inputDirection(), which is based on the active
 system locale.
 
 This default locale-based alignment can be overriden by setting the \c horizontalAlignment
index d0cd524..6964c8f 100644 (file)
@@ -42,7 +42,8 @@
 #include "qdeclarativeapplication_p.h"
 #include <private/qobject_p.h>
 #include <QtGui/QGuiApplication>
-#include <QtGui/QInputPanel>
+#include <QtGui/QInputMethod>
+#include <QtCore/QDebug>
 
 QT_BEGIN_NAMESPACE
 
@@ -85,7 +86,8 @@ Qt::LayoutDirection QDeclarativeApplication::layoutDirection() const
 
 QObject *QDeclarativeApplication::inputPanel() const
 {
-    return qApp ? qApp->inputPanel() : 0;
+    qWarning() << "Qt.application.inputPanel is deprecated, use Qt.inputMethod instead";
+    return qApp ? qApp->inputMethod() : 0;
 }
 
 bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event)
index c9139ad..4a0ff52 100644 (file)
@@ -64,7 +64,7 @@ public:
     virtual ~QDeclarativeApplication();
     bool active() const;
     Qt::LayoutDirection layoutDirection() const;
-    QObject *inputPanel() const;
+    QT_DEPRECATED QObject *inputPanel() const;
 
 protected:
     bool eventFilter(QObject *obj, QEvent *event);
index 9118ef4..73385fe 100644 (file)
@@ -297,7 +297,7 @@ of their use.
     \o
     This read-only property allows access to application's QInputPanel object
     and all its properties and slots. See the QInputPanel documentation for
-    further details.
+    further details. Deprecated in favor of Qt.InputMethod
     \endtable
 
     The following example uses the \c application object to indicate
@@ -305,6 +305,12 @@ of their use.
 
     \snippet doc/src/snippets/declarative/application.qml document
 
+    \qmlproperty object Qt::inputMethod
+    \since QtQuick 2.0
+
+    The \c inputMethod object allows access to application's QInputMethod object
+    and all its properties and slots. See the QInputMethod documentation for
+    further details.
 */
 
 
index 405e406..9013733 100644 (file)
@@ -41,6 +41,8 @@
 
 #include "qv8engine_p.h"
 
+#include <QtGui/QGuiApplication>
+
 #include "qv8contextwrapper_p.h"
 #include "qv8valuetypewrapper_p.h"
 #include "qv8sequencewrapper_p.h"
@@ -575,6 +577,7 @@ void QV8Engine::initializeGlobal(v8::Handle<v8::Object> global)
 
     if (m_engine) {
         qt->Set(v8::String::New("application"), newQObject(new QDeclarativeApplication(m_engine)));
+        qt->Set(v8::String::New("inputMethod"), newQObject(qGuiApp->inputMethod(), CppOwnership));
         qt->Set(v8::String::New("lighter"), V8FUNCTION(lighter, this));
         qt->Set(v8::String::New("darker"), V8FUNCTION(darker, this));
         qt->Set(v8::String::New("tint"), V8FUNCTION(tint, this));
index 7dcbba2..ca70109 100644 (file)
@@ -253,7 +253,6 @@ public:
     QV8Engine(QJSEngine* qq,QJSEngine::ContextOwnership ownership = QJSEngine::CreateNewContext);
     virtual ~QV8Engine();
 
-    // ### TODO get rid of it, do we really need CppOwnership?
     // This enum should be in sync with QDeclarativeEngine::ObjectOwnership
     enum ObjectOwnership { CppOwnership, JavaScriptOwnership };
 
index c9371b5..6c5b223 100644 (file)
@@ -54,7 +54,7 @@
 #include <private/qquickwindowmanager_p.h>
 
 #include <private/qguiapplication_p.h>
-#include <QtGui/QInputPanel>
+#include <QtGui/QInputMethod>
 
 #include <private/qabstractanimation_p.h>
 
@@ -77,7 +77,7 @@ void QQuickCanvasPrivate::updateFocusItemTransform()
     Q_Q(QQuickCanvas);
     QQuickItem *focus = q->activeFocusItem();
     if (focus && qApp->focusObject() == focus)
-        qApp->inputPanel()->setInputItemTransform(QQuickItemPrivate::get(focus)->itemToCanvasTransform());
+        qApp->inputMethod()->setInputItemTransform(QQuickItemPrivate::get(focus)->itemToCanvasTransform());
 }
 
 class QQuickCanvasIncubationController : public QObject, public QDeclarativeIncubationController
@@ -498,7 +498,7 @@ void QQuickCanvasPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *item, F
 
         if (oldActiveFocusItem) {
 #ifndef QT_NO_IM
-            qApp->inputPanel()->reset();
+            qApp->inputMethod()->reset();
 #endif
 
             activeFocusItem = 0;
@@ -605,7 +605,7 @@ void QQuickCanvasPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item,
         Q_ASSERT(oldActiveFocusItem);
 
 #ifndef QT_NO_IM
-        qApp->inputPanel()->reset();
+        qApp->inputMethod()->reset();
 #endif
 
         activeFocusItem = 0;
index f443b1a..67da4c8 100644 (file)
@@ -54,7 +54,7 @@
 #include <QtGui/qpen.h>
 #include <QtGui/qcursor.h>
 #include <QtGui/qguiapplication.h>
-#include <QtGui/qinputpanel.h>
+#include <QtGui/qinputmethod.h>
 #include <QtCore/qdebug.h>
 #include <QtCore/qcoreevent.h>
 #include <QtCore/qnumeric.h>
@@ -3128,7 +3128,7 @@ void QQuickItem::setInputMethodHints(Qt::InputMethodHints hints)
         return;
 
     if (qApp->focusObject() == this)
-        qApp->inputPanel()->update(Qt::ImHints);
+        qApp->inputMethod()->update(Qt::ImHints);
 }
 
 QVariant QQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const
@@ -3671,7 +3671,7 @@ void QQuickItem::itemChange(ItemChange change, const ItemChangeData &value)
 void QQuickItem::updateInputMethod(Qt::InputMethodQueries queries)
 {
     if (hasActiveFocus())
-        qApp->inputPanel()->update(queries);
+        qApp->inputMethod()->update(queries);
 }
 
 /*! \internal */
index c671320..52365a8 100644 (file)
@@ -56,7 +56,7 @@
 #include <QtGui/qtextobject.h>
 #include <QtGui/qtextcursor.h>
 #include <QtGui/qguiapplication.h>
-#include <QtGui/qinputpanel.h>
+#include <QtGui/qinputmethod.h>
 
 #include <private/qtextengine_p.h>
 #include <private/qdeclarativestyledtext_p.h>
@@ -1470,7 +1470,7 @@ bool QQuickTextPrivate::setHAlign(QQuickText::HAlignment alignment, bool forceAl
 bool QQuickTextPrivate::determineHorizontalAlignment()
 {
     if (hAlignImplicit) {
-        bool alignToRight = text.isEmpty() ? qApp->inputPanel()->inputDirection() == Qt::RightToLeft : rightToLeftText;
+        bool alignToRight = text.isEmpty() ? qApp->inputMethod()->inputDirection() == Qt::RightToLeft : rightToLeftText;
         return setHAlign(alignToRight ? QQuickText::AlignRight : QQuickText::AlignLeft);
     }
     return false;
index 06ab5c3..a763626 100644 (file)
@@ -51,7 +51,7 @@
 #include <qdrag.h>
 #include <qclipboard.h>
 #include <qtimer.h>
-#include <qinputpanel.h>
+#include <qinputmethod.h>
 #include "private/qtextdocumentlayout_p.h"
 #include "private/qabstracttextdocumentlayout_p.h"
 #include "qtextdocument.h"
@@ -1310,7 +1310,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou
                 emit q->cursorPositionChanged();
             _q_updateCurrentCharFormatAndSelection();
             if (qGuiApp)
-                qGuiApp->inputPanel()->update(Qt::ImQueryInput);
+                qGuiApp->inputMethod()->update(Qt::ImQueryInput);
         } else if (cursor.position() != oldCursorPos) {
             emit q->cursorPositionChanged();
         }
@@ -1424,7 +1424,7 @@ bool QQuickTextControlPrivate::sendMouseEventToInputContext(QMouseEvent *e, cons
 
         if (cursorPos >= 0 && cursorPos <= layout->preeditAreaText().length()) {
             if (e->type() == QEvent::MouseButtonRelease) {
-                qApp->inputPanel()->invokeAction(QInputPanel::Click, cursorPos);
+                qApp->inputMethod()->invokeAction(QInputMethod::Click, cursorPos);
             }
 
             return true;
@@ -1859,7 +1859,7 @@ void QQuickTextControlPrivate::commitPreedit()
         return;
 
     cursor.beginEditBlock();
-    qApp->inputPanel()->reset();
+    qApp->inputMethod()->reset();
 
     if (!tentativeCommit.isEmpty()) {
         cursor.insertText(tentativeCommit);
index 85480cf..5343715 100644 (file)
@@ -560,7 +560,7 @@ bool QQuickTextEditPrivate::determineHorizontalAlignment()
         if (document->isEmpty()) {
             const QString preeditText = control->textCursor().block().layout()->preeditAreaText();
             alignToRight = preeditText.isEmpty()
-                    ? qApp->inputPanel()->inputDirection() == Qt::RightToLeft
+                    ? qApp->inputMethod()->inputDirection() == Qt::RightToLeft
                     : preeditText.isRightToLeft();
         } else {
             alignToRight = rightToLeftText;
@@ -1545,10 +1545,10 @@ void QQuickTextEdit::itemChange(ItemChange change, const ItemChangeData &value)
 
         if (value.boolValue) {
             q_updateAlignment();
-            connect(qApp->inputPanel(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
+            connect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
                     this, SLOT(q_updateAlignment()));
         } else {
-            disconnect(qApp->inputPanel(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
+            disconnect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
                        this, SLOT(q_updateAlignment()));
         }
     }
@@ -2099,7 +2099,7 @@ void QQuickTextEditPrivate::updateDefaultTextOption()
 void QQuickTextEdit::openSoftwareInputPanel()
 {
     if (qGuiApp)
-        qGuiApp->inputPanel()->show();
+        qGuiApp->inputMethod()->show();
 }
 
 /*!
@@ -2142,7 +2142,7 @@ void QQuickTextEdit::openSoftwareInputPanel()
 void QQuickTextEdit::closeSoftwareInputPanel()
 {
     if (qGuiApp)
-        qGuiApp->inputPanel()->hide();
+        qGuiApp->inputMethod()->hide();
 }
 
 void QQuickTextEdit::focusInEvent(QFocusEvent *event)
index d4f73f7..830b875 100644 (file)
@@ -52,7 +52,7 @@
 #include <QtQuick/qsgsimplerectnode.h>
 
 #include <QtGui/qstylehints.h>
-#include <QtGui/qinputpanel.h>
+#include <QtGui/qinputmethod.h>
 
 #ifndef QT_NO_ACCESSIBILITY
 #include "qaccessible.h"
@@ -131,7 +131,7 @@ void QQuickTextInput::setText(const QString &s)
     if (s == text())
         return;
     if (d->composeMode())
-        qApp->inputPanel()->reset();
+        qApp->inputMethod()->reset();
     d->m_tentativeCommit.clear();
     d->internalSetText(s, -1, false);
 }
@@ -482,7 +482,7 @@ bool QQuickTextInputPrivate::determineHorizontalAlignment()
         QString text = q_func()->text();
         if (text.isEmpty())
             text = m_textLayout.preeditAreaText();
-        bool isRightToLeft = text.isEmpty() ? qApp->inputPanel()->inputDirection() == Qt::RightToLeft
+        bool isRightToLeft = text.isEmpty() ? qApp->inputMethod()->inputDirection() == Qt::RightToLeft
                                             : text.isRightToLeft();
         return setHAlign(isRightToLeft ? QQuickTextInput::AlignRight : QQuickTextInput::AlignLeft);
     }
@@ -1529,7 +1529,7 @@ bool QQuickTextInputPrivate::sendMouseEventToInputContext(QMouseEvent *event)
         int mousePos = tmp_cursor - m_cursor;
         if (mousePos >= 0 && mousePos <= m_textLayout.preeditAreaText().length()) {
             if (event->type() == QEvent::MouseButtonRelease) {
-                qApp->inputPanel()->invokeAction(QInputPanel::Click, mousePos);
+                qApp->inputMethod()->invokeAction(QInputMethod::Click, mousePos);
             }
             return true;
         }
@@ -2417,7 +2417,7 @@ void QQuickTextInput::moveCursorSelection(int pos, SelectionMode mode)
 void QQuickTextInput::openSoftwareInputPanel()
 {
     if (qGuiApp)
-        qGuiApp->inputPanel()->show();
+        qGuiApp->inputMethod()->show();
 }
 
 /*!
@@ -2460,7 +2460,7 @@ void QQuickTextInput::openSoftwareInputPanel()
 void QQuickTextInput::closeSoftwareInputPanel()
 {
     if (qGuiApp)
-        qGuiApp->inputPanel()->hide();
+        qGuiApp->inputMethod()->hide();
 }
 
 void QQuickTextInput::focusInEvent(QFocusEvent *event)
@@ -2490,11 +2490,11 @@ void QQuickTextInput::itemChange(ItemChange change, const ItemChangeData &value)
             d->commitPreedit();
             if (!d->persistentSelection)
                 d->deselect();
-            disconnect(qApp->inputPanel(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
+            disconnect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
                        this, SLOT(q_updateAlignment()));
         } else {
             q_updateAlignment();
-            connect(qApp->inputPanel(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
+            connect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
                     this, SLOT(q_updateAlignment()));
         }
     }
@@ -2790,7 +2790,7 @@ void QQuickTextInputPrivate::commitPreedit()
     if (!composeMode())
         return;
 
-    qApp->inputPanel()->reset();
+    qApp->inputMethod()->reset();
 
     if (!m_tentativeCommit.isEmpty()) {
         internalInsert(m_tentativeCommit);
index a124dbb..07d73be 100644 (file)
@@ -395,7 +395,7 @@ public:
     Qt::LayoutDirection layoutDirection() const {
         if (m_layoutDirection == Qt::LayoutDirectionAuto) {
             if (m_text.isEmpty())
-                return qApp->inputPanel()->inputDirection();
+                return qApp->inputMethod()->inputDirection();
             return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
         }
         return m_layoutDirection;
index 1841a8c..02e4e9c 100644 (file)
 #include <private/qdeclarativetypenotavailable_p.h>
 #include <private/qdeclarativeanimationcontroller_p.h>
 #include <QtCore/qcoreapplication.h>
-#include <QtGui/QInputPanel>
+#include <QtGui/QInputMethod>
 
 void QDeclarativeUtilModule::defineModule()
 {
-    qmlRegisterUncreatableType<QInputPanel>("QtQuick",2,0,"InputPanel", QInputPanel::tr("InputPanel is an abstract class"));
+    qmlRegisterUncreatableType<QInputMethod>("QtQuick",2,0,"InputPanel",
+                                             QInputMethod::tr("InputPanel is an abstract class")); // deprecated
+    qmlRegisterUncreatableType<QInputMethod>("QtQuick",2,0,"InputMethod",
+                                             QInputMethod::tr("InputMethod is an abstract class"));
     qmlRegisterUncreatableType<QDeclarativeAbstractAnimation>("QtQuick",2,0,"Animation",QDeclarativeAbstractAnimation::tr("Animation is an abstract class"));
 
     qmlRegisterType<QDeclarativeBehavior>("QtQuick",2,0,"Behavior");
index fa19338..6b921a7 100644 (file)
@@ -44,7 +44,7 @@
 #include <QtDeclarative/qdeclarativeengine.h>
 #include <QtQuick/qquickitem.h>
 #include <QtQuick/qquickview.h>
-#include <QtGui/qinputpanel.h>
+#include <QtGui/qinputmethod.h>
 
 class tst_qdeclarativeapplication : public QObject
 {
@@ -56,6 +56,7 @@ private slots:
     void active();
     void layoutDirection();
     void inputPanel();
+    void inputMethod();
 
 private:
     QDeclarativeEngine engine;
@@ -135,9 +136,24 @@ void tst_qdeclarativeapplication::inputPanel()
     item->setParentItem(view.rootObject());
 
     // check that the inputPanel property maches with application's input panel
-    QCOMPARE(qvariant_cast<QObject*>(item->property("inputPanel")), qApp->inputPanel());
+    QCOMPARE(qvariant_cast<QObject*>(item->property("inputPanel")), qApp->inputMethod());
 }
 
+void tst_qdeclarativeapplication::inputMethod()
+{
+    // technically not in QDeclarativeApplication, but testing anyway here
+    QDeclarativeComponent component(&engine);
+    component.setData("import QtQuick 2.0; Item { property variant inputMethod: Qt.inputMethod }", QUrl::fromLocalFile(""));
+    QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+    QVERIFY(item);
+    QQuickView view;
+    item->setParentItem(view.rootObject());
+
+    // check that the inputMethod property maches with application's input method
+    QCOMPARE(qvariant_cast<QObject*>(item->property("inputMethod")), qApp->inputMethod());
+}
+
+
 QTEST_MAIN(tst_qdeclarativeapplication)
 
 #include "tst_qdeclarativeapplication.moc"
index 5a00863..4f1225e 100644 (file)
@@ -727,9 +727,9 @@ void tst_qquicktext::horizontalAlignment_RightToLeft()
     QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
 
     // empty text with implicit alignment follows the system locale-based
-    // keyboard input direction from QInputPanel::inputDirection()
+    // keyboard input direction from QInputMethod::inputDirection()
     text->setText("");
-    QCOMPARE(text->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ?
+    QCOMPARE(text->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
                                   QQuickText::AlignLeft : QQuickText::AlignRight);
     text->setHAlign(QQuickText::AlignRight);
     QCOMPARE(text->hAlign(), QQuickText::AlignRight);
@@ -741,7 +741,7 @@ void tst_qquicktext::horizontalAlignment_RightToLeft()
     QDeclarativeComponent textComponent(&engine);
     textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
     QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-    QCOMPARE(textObject->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ?
+    QCOMPARE(textObject->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
                                   QQuickText::AlignLeft : QQuickText::AlignRight);
     delete textObject;
 }
index a16f622..77d17d9 100644 (file)
 #include <QtQuick/QQuickView>
 #include <QDir>
 #include <QStyle>
-#include <QInputPanel>
+#include <QInputMethod>
 #include <QClipboard>
 #include <QMimeData>
 #include <private/qquicktextcontrol_p.h>
 #include "../../shared/util.h"
 #include "../../shared/platforminputcontext.h"
-#include <private/qinputpanel_p.h>
+#include <private/qinputmethod_p.h>
 
 #ifdef Q_OS_MAC
 #include <Carbon/Carbon.h>
@@ -144,7 +144,7 @@ private slots:
     void canPaste();
     void canPasteEmpty();
     void textInput();
-    void inputPanelUpdate();
+    void inputMethodUpdate();
     void openInputPanel();
     void geometrySignals();
     void pastingRichText_QTBUG_14003();
@@ -305,8 +305,8 @@ tst_qquicktextedit::tst_qquicktextedit()
 void tst_qquicktextedit::cleanup()
 {
     // ensure not even skipped tests with custom input context leave it dangling
-    QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
-    inputPanelPrivate->testContext = 0;
+    QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+    inputMethodPrivate->testContext = 0;
 }
 
 void tst_qquicktextedit::text()
@@ -630,8 +630,8 @@ void tst_qquicktextedit::hAlign()
 void tst_qquicktextedit::hAlign_RightToLeft()
 {
     PlatformInputContext platformInputContext;
-    QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
-    inputPanelPrivate->testContext = &platformInputContext;
+    QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+    inputMethodPrivate->testContext = &platformInputContext;
 
     QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
     QQuickTextEdit *textEdit = canvas.rootObject()->findChild<QQuickTextEdit*>("text");
@@ -731,10 +731,10 @@ void tst_qquicktextedit::hAlign_RightToLeft()
     { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
 
     // empty text with implicit alignment follows the system locale-based
-    // keyboard input direction from qApp->inputPanel()->inputDirection
+    // keyboard input direction from qApp->inputMethod()->inputDirection
     textEdit->setText("");
     platformInputContext.setInputDirection(Qt::LeftToRight);
-    QVERIFY(qApp->inputPanel()->inputDirection() == Qt::LeftToRight);
+    QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
     QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
     QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
 
@@ -742,7 +742,7 @@ void tst_qquicktextedit::hAlign_RightToLeft()
 
     platformInputContext.setInputDirection(Qt::RightToLeft);
     QCOMPARE(cursorRectangleSpy.count(), 1);
-    QVERIFY(qApp->inputPanel()->inputDirection() == Qt::RightToLeft);
+    QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
     QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
     QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
 
@@ -2190,11 +2190,11 @@ void tst_qquicktextedit::textInput()
     QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), false);
 }
 
-void tst_qquicktextedit::inputPanelUpdate()
+void tst_qquicktextedit::inputMethodUpdate()
 {
     PlatformInputContext platformInputContext;
-    QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
-    inputPanelPrivate->testContext = &platformInputContext;
+    QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+    inputMethodPrivate->testContext = &platformInputContext;
 
     QQuickView view(testFileUrl("inputMethodEvent.qml"));
     view.show();
@@ -2279,8 +2279,8 @@ void tst_qquicktextedit::inputPanelUpdate()
 void tst_qquicktextedit::openInputPanel()
 {
     PlatformInputContext platformInputContext;
-    QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
-    inputPanelPrivate->testContext = &platformInputContext;
+    QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+    inputMethodPrivate->testContext = &platformInputContext;
 
     QQuickView view(testFileUrl("openInputPanel.qml"));
     view.show();
@@ -2297,7 +2297,7 @@ void tst_qquicktextedit::openInputPanel()
     qDebug() << &edit << qApp->focusObject();
     QVERIFY(qApp->focusObject() != edit);
 
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
 
     // input panel should open on focus
     QPoint centerPoint(view.width()/2, view.height()/2);
@@ -2306,24 +2306,24 @@ void tst_qquicktextedit::openInputPanel()
     QGuiApplication::processEvents();
     QVERIFY(edit->hasActiveFocus());
     QCOMPARE(qApp->focusObject(), edit);
-    QCOMPARE(qApp->inputPanel()->visible(), true);
+    QCOMPARE(qApp->inputMethod()->visible(), true);
     QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
 
     // input panel should be re-opened when pressing already focused TextEdit
-    qApp->inputPanel()->hide();
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    qApp->inputMethod()->hide();
+    QCOMPARE(qApp->inputMethod()->visible(), false);
     QVERIFY(edit->hasActiveFocus());
     QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
     QGuiApplication::processEvents();
-    QCOMPARE(qApp->inputPanel()->visible(), true);
+    QCOMPARE(qApp->inputMethod()->visible(), true);
     QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
 
     // input panel should stay visible if focus is lost to another text editor
-    QSignalSpy inputPanelVisibilitySpy(qApp->inputPanel(), SIGNAL(visibleChanged()));
+    QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
     QQuickTextEdit anotherEdit;
     anotherEdit.setParentItem(view.rootObject());
     anotherEdit.setFocus(true);
-    QCOMPARE(qApp->inputPanel()->visible(), true);
+    QCOMPARE(qApp->inputMethod()->visible(), true);
     QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherEdit));
     QCOMPARE(inputPanelVisibilitySpy.count(), 0);
 
@@ -2332,35 +2332,35 @@ void tst_qquicktextedit::openInputPanel()
     QCOMPARE(view.activeFocusItem(), view.rootItem());
     anotherEdit.setFocus(true);
 
-    qApp->inputPanel()->hide();
+    qApp->inputMethod()->hide();
 
     // input panel should not be opened if TextEdit is read only
     edit->setReadOnly(true);
     edit->setFocus(true);
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
     QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
     QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
     QGuiApplication::processEvents();
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
 
     // input panel should not be opened if focusOnPress is set to false
     edit->setFocusOnPress(false);
     edit->setFocus(false);
     edit->setFocus(true);
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
     QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
     QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
 
     // input panel should open when openSoftwareInputPanel is called
     edit->openSoftwareInputPanel();
-    QCOMPARE(qApp->inputPanel()->visible(), true);
+    QCOMPARE(qApp->inputMethod()->visible(), true);
 
     // input panel should close when closeSoftwareInputPanel is called
     edit->closeSoftwareInputPanel();
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
 
-    inputPanelPrivate->testContext = 0;
+    inputMethodPrivate->testContext = 0;
 }
 
 void tst_qquicktextedit::geometrySignals()
@@ -2463,7 +2463,7 @@ void tst_qquicktextedit::preeditCursorRectangle()
     QVERIFY(edit);
 
     QSignalSpy editSpy(edit, SIGNAL(cursorRectangleChanged()));
-    QSignalSpy panelSpy(qGuiApp->inputPanel(), SIGNAL(cursorRectangleChanged()));
+    QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
 
     QRect currentRect;
 
@@ -2578,11 +2578,11 @@ void tst_qquicktextedit::cursorRectangleSize()
     QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect());
 
     // item-canvas transform and input item transform match
-    QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputPanel()->inputItemTransform());
+    QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
 
     // input panel cursorRectangle property and tranformed item cursor rectangle match
     QRectF sceneCursorRect = QQuickItemPrivate::get(textEdit)->itemToCanvasTransform().mapRect(cursorRectFromItem);
-    QCOMPARE(sceneCursorRect, qApp->inputPanel()->cursorRectangle());
+    QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
 
     delete canvas;
 }
index 38aad48..dd86d03 100644 (file)
 #include <qtest.h>
 #include <QtTest/QSignalSpy>
 #include "../../shared/util.h"
-#include <private/qinputpanel_p.h>
+#include <private/qinputmethod_p.h>
 #include <QtDeclarative/qdeclarativeengine.h>
 #include <QtDeclarative/qdeclarativeexpression.h>
 #include <QFile>
 #include <QtQuick/qquickview.h>
 #include <QtGui/qguiapplication.h>
 #include <QtGui/qstylehints.h>
-#include <QInputPanel>
+#include <QInputMethod>
 #include <private/qquicktextinput_p.h>
 #include <private/qquicktextinput_p_p.h>
 #include <QDebug>
@@ -162,7 +162,7 @@ private slots:
     void preeditCursorRectangle();
     void inputContextMouseHandler();
     void inputMethodComposing();
-    void inputPanelUpdate();
+    void inputMethodUpdate();
     void cursorRectangleSize();
 
     void getText_data();
@@ -256,8 +256,8 @@ QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
 void tst_qquicktextinput::cleanup()
 {
     // ensure not even skipped tests with custom input context leave it dangling
-    QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
-    inputPanelPrivate->testContext = 0;
+    QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+    inputMethodPrivate->testContext = 0;
 }
 
 tst_qquicktextinput::tst_qquicktextinput()
@@ -1264,8 +1264,8 @@ void tst_qquicktextinput::horizontalAlignment()
 void tst_qquicktextinput::horizontalAlignment_RightToLeft()
 {
     PlatformInputContext platformInputContext;
-    QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
-    inputPanelPrivate->testContext = &platformInputContext;
+    QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+    inputMethodPrivate->testContext = &platformInputContext;
 
     QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
     QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
@@ -1360,16 +1360,16 @@ void tst_qquicktextinput::horizontalAlignment_RightToLeft()
     { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
 
     // empty text with implicit alignment follows the system locale-based
-    // keyboard input direction from QInputPanel::inputDirection()
+    // keyboard input direction from QInputMethod::inputDirection()
     textInput->setText("");
     platformInputContext.setInputDirection(Qt::LeftToRight);
-    QVERIFY(qApp->inputPanel()->inputDirection() == Qt::LeftToRight);
+    QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
     QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
     QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
 
     QSignalSpy cursorRectangleSpy(textInput, SIGNAL(cursorRectangleChanged()));
     platformInputContext.setInputDirection(Qt::RightToLeft);
-    QVERIFY(qApp->inputPanel()->inputDirection() == Qt::RightToLeft);
+    QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
     QCOMPARE(cursorRectangleSpy.count(), 1);
     QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
     QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
@@ -2698,8 +2698,8 @@ void tst_qquicktextinput::simulateKey(QQuickView *view, int key)
 void tst_qquicktextinput::openInputPanel()
 {
     PlatformInputContext platformInputContext;
-    QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
-    inputPanelPrivate->testContext = &platformInputContext;
+    QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+    inputMethodPrivate->testContext = &platformInputContext;
 
     QQuickView view(testFileUrl("openInputPanel.qml"));
     view.show();
@@ -2714,7 +2714,7 @@ void tst_qquicktextinput::openInputPanel()
     QVERIFY(input->focusOnPress());
     QVERIFY(!input->hasActiveFocus());
     QVERIFY(qApp->focusObject() != input);
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
 
     // input panel should open on focus
     QPoint centerPoint(view.width()/2, view.height()/2);
@@ -2723,25 +2723,25 @@ void tst_qquicktextinput::openInputPanel()
     QGuiApplication::processEvents();
     QVERIFY(input->hasActiveFocus());
     QCOMPARE(qApp->focusObject(), input);
-    QCOMPARE(qApp->inputPanel()->visible(), true);
+    QCOMPARE(qApp->inputMethod()->visible(), true);
     QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
 
     // input panel should be re-opened when pressing already focused TextInput
-    qApp->inputPanel()->hide();
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    qApp->inputMethod()->hide();
+    QCOMPARE(qApp->inputMethod()->visible(), false);
     QVERIFY(input->hasActiveFocus());
     QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
     QGuiApplication::processEvents();
-    QCOMPARE(qApp->inputPanel()->visible(), true);
+    QCOMPARE(qApp->inputMethod()->visible(), true);
     QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
 
     // input panel should stay visible if focus is lost to another text inputor
-    QSignalSpy inputPanelVisibilitySpy(qApp->inputPanel(), SIGNAL(visibleChanged()));
+    QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
     QQuickTextInput anotherInput;
     anotherInput.componentComplete();
     anotherInput.setParentItem(view.rootObject());
     anotherInput.setFocus(true);
-    QCOMPARE(qApp->inputPanel()->visible(), true);
+    QCOMPARE(qApp->inputMethod()->visible(), true);
     QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherInput));
     QCOMPARE(inputPanelVisibilitySpy.count(), 0);
 
@@ -2750,33 +2750,33 @@ void tst_qquicktextinput::openInputPanel()
     QCOMPARE(view.activeFocusItem(), view.rootItem());
     anotherInput.setFocus(true);
 
-    qApp->inputPanel()->hide();
+    qApp->inputMethod()->hide();
 
     // input panel should not be opened if TextInput is read only
     input->setReadOnly(true);
     input->setFocus(true);
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
     QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
     QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
     QGuiApplication::processEvents();
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
 
     // input panel should not be opened if focusOnPress is set to false
     input->setFocusOnPress(false);
     input->setFocus(false);
     input->setFocus(true);
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
     QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
     QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
 
     // input panel should open when openSoftwareInputPanel is called
     input->openSoftwareInputPanel();
-    QCOMPARE(qApp->inputPanel()->visible(), true);
+    QCOMPARE(qApp->inputMethod()->visible(), true);
 
     // input panel should close when closeSoftwareInputPanel is called
     input->closeSoftwareInputPanel();
-    QCOMPARE(qApp->inputPanel()->visible(), false);
+    QCOMPARE(qApp->inputMethod()->visible(), false);
 }
 
 class MyTextInput : public QQuickTextInput
@@ -2993,7 +2993,7 @@ void tst_qquicktextinput::preeditCursorRectangle()
     QCOMPARE(currentRect, previousRect);
 
     QSignalSpy inputSpy(input, SIGNAL(cursorRectangleChanged()));
-    QSignalSpy panelSpy(qGuiApp->inputPanel(), SIGNAL(cursorRectangleChanged()));
+    QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
 
     // Verify that the micro focus rect moves to the left as the cursor position
     // is incremented.
@@ -3022,8 +3022,8 @@ void tst_qquicktextinput::preeditCursorRectangle()
 void tst_qquicktextinput::inputContextMouseHandler()
 {
     PlatformInputContext platformInputContext;
-    QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
-    inputPanelPrivate->testContext = &platformInputContext;
+    QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+    inputMethodPrivate->testContext = &platformInputContext;
 
     QString text = "supercalifragisiticexpialidocious!";
     QQuickView view(testFileUrl("inputContext.qml"));
@@ -3060,7 +3060,7 @@ void tst_qquicktextinput::inputContextMouseHandler()
     QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, position);
     QGuiApplication::processEvents();
 
-    QCOMPARE(platformInputContext.m_action, QInputPanel::Click);
+    QCOMPARE(platformInputContext.m_action, QInputMethod::Click);
     QCOMPARE(platformInputContext.m_invokeActionCallCount, 1);
     QCOMPARE(platformInputContext.m_cursorPosition, 2);
 }
@@ -3100,11 +3100,11 @@ void tst_qquicktextinput::inputMethodComposing()
     QCOMPARE(spy.count(), 2);
 }
 
-void tst_qquicktextinput::inputPanelUpdate()
+void tst_qquicktextinput::inputMethodUpdate()
 {
     PlatformInputContext platformInputContext;
-    QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
-    inputPanelPrivate->testContext = &platformInputContext;
+    QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+    inputMethodPrivate->testContext = &platformInputContext;
 
     QQuickView view(testFileUrl("inputContext.qml"));
     view.show();
@@ -3216,11 +3216,11 @@ void tst_qquicktextinput::cursorRectangleSize()
     QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect());
 
     // item-canvas transform and input item transform match
-    QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputPanel()->inputItemTransform());
+    QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
 
     // input panel cursorRectangle property and tranformed item cursor rectangle match
     QRectF sceneCursorRect = QQuickItemPrivate::get(textInput)->itemToCanvasTransform().mapRect(cursorRectFromItem);
-    QCOMPARE(sceneCursorRect, qApp->inputPanel()->cursorRectangle());
+    QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
 
     delete canvas;
 }
index 4c73544..e77cbf3 100644 (file)
 ****************************************************************************/
 
 #include <qplatforminputcontext_qpa.h>
-#include <QtGui/QInputPanel>
+#include <QtGui/QInputMethod>
 
 class PlatformInputContext : public QPlatformInputContext
 {
 public:
     PlatformInputContext()
-        : m_visible(false), m_action(QInputPanel::Click), m_cursorPosition(0),
+        : m_visible(false), m_action(QInputMethod::Click), m_cursorPosition(0),
           m_invokeActionCallCount(0), m_showInputPanelCallCount(0), m_hideInputPanelCallCount(0),
           m_updateCallCount(0), m_direction(Qt::LeftToRight)
     {
@@ -66,7 +66,7 @@ public:
     {
         return m_visible;
     }
-    virtual void invokeAction(QInputPanel::Action action, int cursorPosition)
+    virtual void invokeAction(QInputMethod::Action action, int cursorPosition)
     {
         m_invokeActionCallCount++;
         m_action = action;
@@ -106,7 +106,7 @@ public:
     }
 
     bool m_visible;
-    QInputPanel::Action m_action;
+    QInputMethod::Action m_action;
     int m_cursorPosition;
     int m_invokeActionCallCount;
     int m_showInputPanelCallCount;