Remove deprecated inputItem and inputWindow from QInputMethod
Interfaces introduced and deprecated during Qt5 development. Change-Id: I804a02df8c4a03ed6558f4a86375f97d09513d5c Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
c3523bdde7
commit
e06999bd62
@ -53,8 +53,6 @@ QT_BEGIN_NAMESPACE
|
||||
QInputMethod::QInputMethod()
|
||||
: QObject(*new QInputMethodPrivate)
|
||||
{
|
||||
// might be instantiated before QGuiApplication is fully done, need to connect later
|
||||
QTimer::singleShot(0, this, SLOT(_q_connectFocusObject()));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -77,40 +75,6 @@ QInputMethod::~QInputMethod()
|
||||
as \c Qt.inputMethod property.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QInputMethod::inputItem
|
||||
\brief Focused item that accepts text input
|
||||
\obsolete
|
||||
|
||||
Input item is set and unset by the focused window. In QML Scene Graph this is done by
|
||||
QQuickCanvas and the input item is either TextInput or TextEdit element. Any QObject can
|
||||
behave as an input item as long as it responds to QInputMethodQueryEvent and QInputMethodEvent
|
||||
events sent by the input methods.
|
||||
|
||||
\sa inputItemTransform, inputWindow, QInputMethodQueryEvent, QInputMethodEvent
|
||||
*/
|
||||
QObject *QInputMethod::inputItem() const
|
||||
{
|
||||
Q_D(const QInputMethod);
|
||||
return d->inputItem.data();
|
||||
}
|
||||
|
||||
void QInputMethod::setInputItem(QObject *inputItem)
|
||||
{
|
||||
Q_D(QInputMethod);
|
||||
d->setInputItem(inputItem);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the currently focused window containing the input item.
|
||||
|
||||
\obsolete
|
||||
*/
|
||||
QWindow *QInputMethod::inputWindow() const
|
||||
{
|
||||
return qApp->focusWindow();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the transformation from input item coordinates to the window coordinates.
|
||||
*/
|
||||
@ -146,11 +110,12 @@ QRectF QInputMethod::cursorRectangle() const
|
||||
{
|
||||
Q_D(const QInputMethod);
|
||||
|
||||
if (!d->inputItem)
|
||||
QObject *focusObject = qGuiApp->focusObject();
|
||||
if (!focusObject)
|
||||
return QRectF();
|
||||
|
||||
QInputMethodQueryEvent query(Qt::ImCursorRectangle);
|
||||
QGuiApplication::sendEvent(d->inputItem.data(), &query);
|
||||
QGuiApplication::sendEvent(focusObject, &query);
|
||||
QRectF r = query.value(Qt::ImCursorRectangle).toRectF();
|
||||
if (!r.isValid())
|
||||
return QRectF();
|
||||
@ -303,7 +268,6 @@ void QInputMethod::update(Qt::InputMethodQueries queries)
|
||||
if (queries & Qt::ImEnabled) {
|
||||
QObject *focus = qApp->focusObject();
|
||||
bool enabled = d->objectAcceptsInputMethod(focus);
|
||||
d->setInputItem(enabled ? focus : 0);
|
||||
QPlatformInputContextPrivate::setInputMethodAccepted(enabled);
|
||||
}
|
||||
|
||||
@ -369,21 +333,6 @@ void QInputMethod::invokeAction(Action a, int cursorPosition)
|
||||
ic->invokeAction(a, cursorPosition);
|
||||
}
|
||||
|
||||
// temporary handlers for updating focus item based on application focus
|
||||
void QInputMethodPrivate::_q_connectFocusObject()
|
||||
{
|
||||
Q_Q(QInputMethod);
|
||||
QObject::connect(qApp, SIGNAL(focusObjectChanged(QObject*)),
|
||||
q, SLOT(_q_checkFocusObject(QObject*)));
|
||||
_q_checkFocusObject(qApp->focusObject());
|
||||
}
|
||||
|
||||
void QInputMethodPrivate::_q_checkFocusObject(QObject *object)
|
||||
{
|
||||
bool enabled = objectAcceptsInputMethod(object);
|
||||
setInputItem(enabled ? object : 0);
|
||||
}
|
||||
|
||||
bool QInputMethodPrivate::objectAcceptsInputMethod(QObject *object)
|
||||
{
|
||||
bool enabled = false;
|
||||
|
@ -59,7 +59,6 @@ class Q_GUI_EXPORT QInputMethod : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QInputMethod)
|
||||
Q_PROPERTY(QObject *inputItem READ inputItem WRITE setInputItem NOTIFY inputItemChanged)
|
||||
Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
|
||||
Q_PROPERTY(QRectF keyboardRectangle READ keyboardRectangle NOTIFY keyboardRectangleChanged)
|
||||
Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
|
||||
@ -69,14 +68,6 @@ class Q_GUI_EXPORT QInputMethod : public QObject
|
||||
|
||||
Q_ENUMS(Action)
|
||||
public:
|
||||
#ifdef QT_DEPRECATED
|
||||
QT_DEPRECATED QObject *inputItem() const;
|
||||
QT_DEPRECATED void setInputItem(QObject *inputItemChanged);
|
||||
|
||||
// the window containing the editor
|
||||
QT_DEPRECATED QWindow *inputWindow() const;
|
||||
#endif
|
||||
|
||||
QTransform inputItemTransform() const;
|
||||
void setInputItemTransform(const QTransform &transform);
|
||||
|
||||
@ -114,7 +105,6 @@ public Q_SLOTS:
|
||||
void invokeAction(Action a, int cursorPosition);
|
||||
|
||||
Q_SIGNALS:
|
||||
void inputItemChanged();
|
||||
void cursorRectangleChanged();
|
||||
void keyboardRectangleChanged();
|
||||
void visibleChanged();
|
||||
@ -128,10 +118,6 @@ private:
|
||||
friend class QPlatformInputContext;
|
||||
QInputMethod();
|
||||
~QInputMethod();
|
||||
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_connectFocusObject())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_checkFocusObject(QObject* object))
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -69,23 +69,12 @@ public:
|
||||
{
|
||||
return inputMethod->d_func();
|
||||
}
|
||||
inline void setInputItem(QObject *item)
|
||||
{
|
||||
Q_Q(QInputMethod);
|
||||
|
||||
if (inputItem.data() == item)
|
||||
return;
|
||||
|
||||
inputItem = item;
|
||||
emit q->inputItemChanged();
|
||||
}
|
||||
|
||||
void _q_connectFocusObject();
|
||||
void _q_checkFocusObject(QObject *object);
|
||||
bool objectAcceptsInputMethod(QObject *object);
|
||||
|
||||
QTransform inputItemTransform;
|
||||
QPointer<QObject> inputItem;
|
||||
QPlatformInputContext *testContext;
|
||||
};
|
||||
|
||||
|
@ -113,7 +113,6 @@ private slots:
|
||||
void isVisible();
|
||||
void animating();
|
||||
void keyboarRectangle();
|
||||
void inputItem();
|
||||
void inputItemTransform();
|
||||
void cursorRectangle();
|
||||
void invokeAction();
|
||||
@ -178,20 +177,6 @@ void tst_qinputmethod::keyboarRectangle()
|
||||
QCOMPARE(spy.count(), 1);
|
||||
}
|
||||
|
||||
void tst_qinputmethod::inputItem()
|
||||
{
|
||||
QVERIFY(!qApp->inputMethod()->inputItem());
|
||||
QSignalSpy spy(qApp->inputMethod(), SIGNAL(inputItemChanged()));
|
||||
|
||||
qApp->inputMethod()->setInputItem(&m_inputItem);
|
||||
|
||||
QCOMPARE(qApp->inputMethod()->inputItem(), &m_inputItem);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
// reset
|
||||
qApp->inputMethod()->setInputItem(0);
|
||||
}
|
||||
|
||||
void tst_qinputmethod::inputItemTransform()
|
||||
{
|
||||
QCOMPARE(qApp->inputMethod()->inputItemTransform(), QTransform());
|
||||
@ -214,13 +199,18 @@ void tst_qinputmethod::cursorRectangle()
|
||||
{
|
||||
QCOMPARE(qApp->inputMethod()->cursorRectangle(), QRectF());
|
||||
|
||||
DummyWindow window;
|
||||
window.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&window));
|
||||
window.requestActivateWindow();
|
||||
QTRY_COMPARE(qApp->focusWindow(), &window);
|
||||
window.setFocusObject(&m_inputItem);
|
||||
|
||||
QTransform transform;
|
||||
transform.translate(10, 10);
|
||||
transform.scale(2, 2);
|
||||
transform.shear(2, 2);
|
||||
qApp->inputMethod()->setInputItemTransform(transform);
|
||||
qApp->inputMethod()->setInputItem(&m_inputItem);
|
||||
|
||||
QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4)));
|
||||
|
||||
m_inputItem.cursorRectangle = QRectF(1.5, 2, 1, 8);
|
||||
@ -228,7 +218,6 @@ void tst_qinputmethod::cursorRectangle()
|
||||
|
||||
// reset
|
||||
m_inputItem.cursorRectangle = QRectF(1, 2, 3, 4);
|
||||
qApp->inputMethod()->setInputItem(0);
|
||||
qApp->inputMethod()->setInputItemTransform(QTransform());
|
||||
}
|
||||
|
||||
@ -278,9 +267,6 @@ void tst_qinputmethod::update()
|
||||
QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImQueryAll));
|
||||
|
||||
QCOMPARE(qApp->inputMethod()->keyboardRectangle(), QRectF(10, 20, 30, 40));
|
||||
|
||||
// reset
|
||||
qApp->inputMethod()->setInputItem(0);
|
||||
}
|
||||
|
||||
void tst_qinputmethod::query()
|
||||
|
@ -352,7 +352,6 @@ private slots:
|
||||
void initialPosForDontShowOnScreenWidgets();
|
||||
void updateOnDestroyedSignal();
|
||||
void toplevelLineEditFocus();
|
||||
void inputFocus_task257832();
|
||||
|
||||
void focusWidget_task254563();
|
||||
#ifndef Q_OS_WINCE_WM
|
||||
@ -8869,18 +8868,6 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
|
||||
}
|
||||
#endif
|
||||
|
||||
void tst_QWidget::inputFocus_task257832()
|
||||
{
|
||||
QScopedPointer<QLineEdit> widget(new QLineEdit);
|
||||
widget->setFocus();
|
||||
widget->winId(); // make sure, widget has been created
|
||||
widget->show();
|
||||
QTRY_VERIFY(widget->hasFocus());
|
||||
QCOMPARE(qApp->inputMethod()->inputItem(), widget.data());
|
||||
widget->setReadOnly(true);
|
||||
QVERIFY(!qApp->inputMethod()->inputItem());
|
||||
}
|
||||
|
||||
void tst_QWidget::setGraphicsEffect()
|
||||
{
|
||||
// Check that we don't have any effect by default.
|
||||
@ -9004,19 +8991,7 @@ void tst_QWidget::focusProxyAndInputMethods()
|
||||
QVERIFY(QTest::qWaitForWindowActive(toplevel.data()));
|
||||
QVERIFY(toplevel->hasFocus());
|
||||
QVERIFY(child->hasFocus());
|
||||
|
||||
// verify that toggling input methods on the child widget
|
||||
// correctly propagate to the focus proxy's input method
|
||||
// and that the input method gets the focus proxy passed
|
||||
// as the focus widget instead of the child widget.
|
||||
// otherwise input method queries go to the wrong widget
|
||||
QCOMPARE(qApp->inputMethod()->inputItem(), toplevel.data());
|
||||
|
||||
toplevel->setAttribute(Qt::WA_InputMethodEnabled, false);
|
||||
QVERIFY(!qApp->inputMethod()->inputItem());
|
||||
|
||||
toplevel->setAttribute(Qt::WA_InputMethodEnabled, true);
|
||||
QCOMPARE(qApp->inputMethod()->inputItem(), toplevel.data());
|
||||
QCOMPARE(qApp->focusObject(), toplevel.data());
|
||||
}
|
||||
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
|
Loading…
Reference in New Issue
Block a user