aboutsummaryrefslogtreecommitdiffstats
path: root/src/qtquick1
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-05-20 14:22:39 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-07 05:56:53 +0200
commit17330e9cd94a64afb000a63a40b2e9646520a847 (patch)
tree57ed25504fbbdab2114bf2d95c8b87f33c5f0b11 /src/qtquick1
parent8282beb53de059237a4240ad9615d77f676c20fb (diff)
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 Reviewed-on: http://codereview.qt.nokia.com/4176 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qtquick1')
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativetextedit.cpp11
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativetextinput.cpp7
2 files changed, 16 insertions, 2 deletions
diff --git a/src/qtquick1/graphicsitems/qdeclarativetextedit.cpp b/src/qtquick1/graphicsitems/qdeclarativetextedit.cpp
index 36105158f3..d97d8d6de3 100644
--- a/src/qtquick1/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/qtquick1/graphicsitems/qdeclarativetextedit.cpp
@@ -552,7 +552,15 @@ bool QDeclarative1TextEditPrivate::determineHorizontalAlignment()
{
Q_Q(QDeclarative1TextEdit);
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 ? QDeclarative1TextEdit::AlignRight : QDeclarative1TextEdit::AlignLeft);
}
return false;
@@ -1588,6 +1596,7 @@ void QDeclarative1TextEdit::q_textChanged()
void QDeclarative1TextEdit::moveCursorDelegate()
{
Q_D(QDeclarative1TextEdit);
+ d->determineHorizontalAlignment();
updateMicroFocus();
emit cursorRectangleChanged();
if(!d->cursor)
diff --git a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp
index c61a3ff089..85f564e99d 100644
--- a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp
@@ -413,7 +413,11 @@ bool QDeclarative1TextInputPrivate::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 ? QDeclarative1TextInput::AlignRight : QDeclarative1TextInput::AlignLeft);
}
return false;
@@ -1918,6 +1922,7 @@ void QDeclarative1TextInput::cursorPosChanged()
void QDeclarative1TextInput::updateCursorRectangle()
{
Q_D(QDeclarative1TextInput);
+ d->determineHorizontalAlignment();
d->updateHorizontalScroll();
updateRect();//TODO: Only update rect between pos's
updateMicroFocus();