Skip to content

Commit 4159518

Browse files
author
Qt Continuous Integration System
committed
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Move the TextInput cursor delegate when the preedit position changes.
2 parents 7783b04 + 1083021 commit 4159518

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/declarative/graphicsitems/qdeclarativetextinput.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,8 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c)
949949
//note that the components are owned by something else
950950
disconnect(d->control, SIGNAL(cursorPositionChanged(int,int)),
951951
this, SLOT(moveCursor()));
952+
disconnect(d->control, SIGNAL(updateMicroFocus()),
953+
this, SLOT(moveCursor()));
952954
delete d->cursorItem;
953955
}else{
954956
d->startCreatingCursor();
@@ -961,7 +963,9 @@ void QDeclarativeTextInputPrivate::startCreatingCursor()
961963
{
962964
Q_Q(QDeclarativeTextInput);
963965
q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
964-
q, SLOT(moveCursor()));
966+
q, SLOT(moveCursor()), Qt::UniqueConnection);
967+
q->connect(control, SIGNAL(updateMicroFocus()),
968+
q, SLOT(moveCursor()), Qt::UniqueConnection);
965969
if(cursorComponent->isReady()){
966970
q->createCursor();
967971
}else if(cursorComponent->isLoading()){

tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,15 @@ void tst_qdeclarativetextedit::cursorDelegate()
15461546
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
15471547
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
15481548
}
1549+
const QString preedit = "preedit";
1550+
for (int i = 0; i <= preedit.length(); i++) {
1551+
QInputMethodEvent event(preedit, QList<QInputMethodEvent::Attribute>()
1552+
<< QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant()));
1553+
QApplication::sendEvent(view, &event);
1554+
1555+
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
1556+
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
1557+
}
15491558
textEditObject->setCursorPosition(0);
15501559
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
15511560
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));

tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,15 @@ void tst_qdeclarativetextinput::cursorDelegate()
16431643
QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
16441644
QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
16451645
}
1646+
const QString preedit = "preedit";
1647+
for (int i = 0; i <= preedit.length(); i++) {
1648+
QInputMethodEvent event(preedit, QList<QInputMethodEvent::Attribute>()
1649+
<< QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant()));
1650+
QApplication::sendEvent(view, &event);
1651+
1652+
QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
1653+
QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
1654+
}
16461655
textInputObject->setCursorPosition(0);
16471656
QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
16481657
QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));

0 commit comments

Comments
 (0)