Commit e761f5b9 authored by Pekka Vuorela's avatar Pekka Vuorela Committed by Qt by Nokia

Use QInputMethod instead of deprecated QInputPanel

Similarly deprecate Qt.application.inputPanel and
introduce replacement Qt.inputMethod.

Change-Id: Ie4fd467f93f75023c86b0a2d038d858fe5001146
Reviewed-by: default avatarJoona Petrell <joona.t.petrell@nokia.com>
Reviewed-by: default avatarLars Knoll <lars.knoll@nokia.com>
Reviewed-by: default avatarSami Kananoja <sami.kananoja@nokia.com>
parent 9634dc44
......@@ -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
......
......@@ -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)
......
......@@ -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);
......
......@@ -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.
*/
......
......@@ -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));
......
......@@ -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 };
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
......@@ -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;
......
......@@ -61,11 +61,14 @@
#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");
......
......@@ -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"
......@@ -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;
}
......
......@@ -56,13 +56,13 @@
#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;
}
......
......@@ -40,13 +40,13 @@
****************************************************************************/
#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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment