Fix rounding error in QInputMethod::cursorRectangle().
Use QRectF consistently to avoid the rounding done in the conversion to QRect. Task-number: QTBUG-24463 Change-Id: If9ea858ebabf8c449ea058b9d379d4a57cb6c82d Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
This commit is contained in:
parent
1501f1ddd4
commit
ef9a86db56
@ -154,9 +154,9 @@ QRectF QInputMethod::cursorRectangle() const
|
||||
|
||||
QInputMethodQueryEvent query(Qt::ImCursorRectangle);
|
||||
QGuiApplication::sendEvent(d->inputItem.data(), &query);
|
||||
QRect r = query.value(Qt::ImCursorRectangle).toRect();
|
||||
QRectF r = query.value(Qt::ImCursorRectangle).toRectF();
|
||||
if (!r.isValid())
|
||||
return QRect();
|
||||
return QRectF();
|
||||
|
||||
return d->inputItemTransform.mapRect(r);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class InputItem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
InputItem() : m_enabled(true) {}
|
||||
InputItem() : cursorRectangle(1, 2, 3, 4), m_enabled(true) {}
|
||||
|
||||
bool event(QEvent *event)
|
||||
{
|
||||
@ -59,7 +59,7 @@ public:
|
||||
if (query->queries() & Qt::ImEnabled)
|
||||
query->setValue(Qt::ImEnabled, m_enabled);
|
||||
if (query->queries() & Qt::ImCursorRectangle)
|
||||
query->setValue(Qt::ImCursorRectangle, QRectF(1, 2, 3, 4));
|
||||
query->setValue(Qt::ImCursorRectangle, cursorRectangle);
|
||||
if (query->queries() & Qt::ImPreferredLanguage)
|
||||
query->setValue(Qt::ImPreferredLanguage, QString("English"));
|
||||
m_lastQueries = query->queries();
|
||||
@ -76,6 +76,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
QRectF cursorRectangle;
|
||||
Qt::InputMethodQueries m_lastQueries;
|
||||
bool m_enabled;
|
||||
};
|
||||
@ -226,7 +227,11 @@ void tst_qinputmethod::cursorRectangle()
|
||||
|
||||
QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4)));
|
||||
|
||||
m_inputItem.cursorRectangle = QRectF(1.5, 2, 1, 8);
|
||||
QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1.5, 2, 1, 8)));
|
||||
|
||||
// reset
|
||||
m_inputItem.cursorRectangle = QRectF(1, 2, 3, 4);
|
||||
qApp->inputMethod()->setInputItemTransform(QTransform());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user