From 17330e9cd94a64afb000a63a40b2e9646520a847 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 20 May 2011 14:22:39 +1000 Subject: 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 Reviewed-by: Michael Brasser --- src/qtquick1/graphicsitems/qdeclarativetextedit.cpp | 11 ++++++++++- src/qtquick1/graphicsitems/qdeclarativetextinput.cpp | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/qtquick1') 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(); -- cgit v1.2.3