diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-08-22 01:31:22 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2011-08-23 01:57:46 (GMT) |
commit | 2c198b3ace2fb09ed0eaa45aec6ce2c96a45aafb (patch) | |
tree | f506f57915d6c3813a20f4215f626de9a02dd9e4 /src/declarative | |
parent | b98e9e69dd8ba33d5f01b9518d95b63b86c4b443 (diff) | |
download | Qt-2c198b3ace2fb09ed0eaa45aec6ce2c96a45aafb.zip Qt-2c198b3ace2fb09ed0eaa45aec6ce2c96a45aafb.tar.gz Qt-2c198b3ace2fb09ed0eaa45aec6ce2c96a45aafb.tar.bz2 |
Fix left alignment of native RTL pre-edit text.
If there is no committed text in a TextInput or TextEdit determine
if the pre-edit text is right to left before falling back to the
global keyboard settings.
Change-Id: I7e5568e936341602b8faf7be120f9a770c115f48
Task-number: QMLNG-72
Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextedit.cpp | 11 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextinput.cpp | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 42c520c..cc5279a 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -547,7 +547,15 @@ bool QDeclarativeTextEditPrivate::determineHorizontalAlignment() { Q_Q(QDeclarativeTextEdit); if (hAlignImplicit && q->isComponentComplete()) { - bool alignToRight = text.isEmpty() ? QApplication::keyboardInputDirection() == Qt::RightToLeft : rightToLeftText; + bool alignToRight; + if (text.isEmpty()) { + const QString preeditText = control->textCursor().block().layout()->preeditAreaText(); + alignToRight = preeditText.isEmpty() + ? QApplication::keyboardInputDirection() == Qt::RightToLeft + : preeditText.isRightToLeft(); + } else { + alignToRight = rightToLeftText; + } return setHAlign(alignToRight ? QDeclarativeTextEdit::AlignRight : QDeclarativeTextEdit::AlignLeft); } return false; @@ -1582,6 +1590,7 @@ void QDeclarativeTextEdit::q_textChanged() void QDeclarativeTextEdit::moveCursorDelegate() { Q_D(QDeclarativeTextEdit); + d->determineHorizontalAlignment(); updateMicroFocus(); emit cursorRectangleChanged(); if(!d->cursor) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index f68f1c6..c5c9f5e 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -407,7 +407,11 @@ bool QDeclarativeTextInputPrivate::determineHorizontalAlignment() if (hAlignImplicit) { // if no explicit alignment has been set, follow the natural layout direction of the text QString text = control->text(); - bool isRightToLeft = text.isEmpty() ? QApplication::keyboardInputDirection() == Qt::RightToLeft : text.isRightToLeft(); + if (text.isEmpty()) + text = control->preeditAreaText(); + bool isRightToLeft = text.isEmpty() + ? QApplication::keyboardInputDirection() == Qt::RightToLeft + : text.isRightToLeft(); return setHAlign(isRightToLeft ? QDeclarativeTextInput::AlignRight : QDeclarativeTextInput::AlignLeft); } return false; @@ -1909,6 +1913,7 @@ void QDeclarativeTextInput::cursorPosChanged() void QDeclarativeTextInput::updateCursorRectangle() { Q_D(QDeclarativeTextInput); + d->determineHorizontalAlignment(); d->updateHorizontalScroll(); updateRect();//TODO: Only update rect between pos's updateMicroFocus(); |