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
#include "qdeclarativeapplication_p.h"
#include <private/qobject_p.h>
#include <QtGui/QGuiApplication>
-#include <QtGui/QInputPanel>
+#include <QtGui/QInputMethod>
+#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
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)
virtual ~QDeclarativeApplication();
bool active() const;
Qt::LayoutDirection layoutDirection() const;
- QObject *inputPanel() const;
+ QT_DEPRECATED QObject *inputPanel() const;
protected:
bool eventFilter(QObject *obj, QEvent *event);
\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
\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.
*/
#include "qv8engine_p.h"
+#include <QtGui/QGuiApplication>
+
#include "qv8contextwrapper_p.h"
#include "qv8valuetypewrapper_p.h"
#include "qv8sequencewrapper_p.h"
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));
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 };
#include <private/qquickwindowmanager_p.h>
#include <private/qguiapplication_p.h>
-#include <QtGui/QInputPanel>
+#include <QtGui/QInputMethod>
#include <private/qabstractanimation_p.h>
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
if (oldActiveFocusItem) {
#ifndef QT_NO_IM
- qApp->inputPanel()->reset();
+ qApp->inputMethod()->reset();
#endif
activeFocusItem = 0;
Q_ASSERT(oldActiveFocusItem);
#ifndef QT_NO_IM
- qApp->inputPanel()->reset();
+ qApp->inputMethod()->reset();
#endif
activeFocusItem = 0;
#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>
return;
if (qApp->focusObject() == this)
- qApp->inputPanel()->update(Qt::ImHints);
+ qApp->inputMethod()->update(Qt::ImHints);
}
QVariant QQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const
void QQuickItem::updateInputMethod(Qt::InputMethodQueries queries)
{
if (hasActiveFocus())
- qApp->inputPanel()->update(queries);
+ qApp->inputMethod()->update(queries);
}
/*! \internal */
#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>
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;
#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"
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();
}
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;
return;
cursor.beginEditBlock();
- qApp->inputPanel()->reset();
+ qApp->inputMethod()->reset();
if (!tentativeCommit.isEmpty()) {
cursor.insertText(tentativeCommit);
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;
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()));
}
}
void QQuickTextEdit::openSoftwareInputPanel()
{
if (qGuiApp)
- qGuiApp->inputPanel()->show();
+ qGuiApp->inputMethod()->show();
}
/*!
void QQuickTextEdit::closeSoftwareInputPanel()
{
if (qGuiApp)
- qGuiApp->inputPanel()->hide();
+ qGuiApp->inputMethod()->hide();
}
void QQuickTextEdit::focusInEvent(QFocusEvent *event)
#include <QtQuick/qsgsimplerectnode.h>
#include <QtGui/qstylehints.h>
-#include <QtGui/qinputpanel.h>
+#include <QtGui/qinputmethod.h>
#ifndef QT_NO_ACCESSIBILITY
#include "qaccessible.h"
if (s == text())
return;
if (d->composeMode())
- qApp->inputPanel()->reset();
+ qApp->inputMethod()->reset();
d->m_tentativeCommit.clear();
d->internalSetText(s, -1, false);
}
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);
}
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;
}
void QQuickTextInput::openSoftwareInputPanel()
{
if (qGuiApp)
- qGuiApp->inputPanel()->show();
+ qGuiApp->inputMethod()->show();
}
/*!
void QQuickTextInput::closeSoftwareInputPanel()
{
if (qGuiApp)
- qGuiApp->inputPanel()->hide();
+ qGuiApp->inputMethod()->hide();
}
void QQuickTextInput::focusInEvent(QFocusEvent *event)
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()));
}
}
if (!composeMode())
return;
- qApp->inputPanel()->reset();
+ qApp->inputMethod()->reset();
if (!m_tentativeCommit.isEmpty()) {
internalInsert(m_tentativeCommit);
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;
#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");
#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
{
void active();
void layoutDirection();
void inputPanel();
+ void inputMethod();
private:
QDeclarativeEngine engine;
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"
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);
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;
}
#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>
void canPaste();
void canPasteEmpty();
void textInput();
- void inputPanelUpdate();
+ void inputMethodUpdate();
void openInputPanel();
void geometrySignals();
void pastingRichText_QTBUG_14003();
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()
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");
{ 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);
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);
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();
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();
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);
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);
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()
QVERIFY(edit);
QSignalSpy editSpy(edit, SIGNAL(cursorRectangleChanged()));
- QSignalSpy panelSpy(qGuiApp->inputPanel(), SIGNAL(cursorRectangleChanged()));
+ QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
QRect currentRect;
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;
}
#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>
void preeditCursorRectangle();
void inputContextMouseHandler();
void inputMethodComposing();
- void inputPanelUpdate();
+ void inputMethodUpdate();
void cursorRectangleSize();
void getText_data();
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()
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");
{ 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);
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();
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);
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);
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
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.
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"));
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);
}
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();
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;
}
****************************************************************************/
#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)
{
{
return m_visible;
}
- virtual void invokeAction(QInputPanel::Action action, int cursorPosition)
+ virtual void invokeAction(QInputMethod::Action action, int cursorPosition)
{
m_invokeActionCallCount++;
m_action = action;
}
bool m_visible;
- QInputPanel::Action m_action;
+ QInputMethod::Action m_action;
int m_cursorPosition;
int m_invokeActionCallCount;
int m_showInputPanelCallCount;