summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2011-03-04 03:26:12 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2011-03-04 03:36:56 (GMT)
commit9f674617daf03026d78f8ce18328cbe6c31b689d (patch)
treeec41ebf4edba3bbedc6ae8e53ef8a24b7b8cc98a
parent94bf3f5acd1342687c55fc5d82077ca89d59b633 (diff)
downloadQt-9f674617daf03026d78f8ce18328cbe6c31b689d.zip
Qt-9f674617daf03026d78f8ce18328cbe6c31b689d.tar.gz
Qt-9f674617daf03026d78f8ce18328cbe6c31b689d.tar.bz2
Remove text alignment of empty QML editors following the layout direction
Task-number: QTBUG-15880 Reviewed-by: Martin Jones Removed implicit text alignment of empty text in QML editor following the application's default layout direction. Change was originally made few days ago in the commit 88253db8a7d7910e1393b1948fb3747117538c92. Aligning empty and neutral text to the right for RTL locales requires much more comprehensive changes to the Qt's internal text classes than initially thought. Change-Id: I93a26df259b87dff47d57423949270656746c9a7
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp5
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp12
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp12
6 files changed, 14 insertions, 35 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 66a2355..3988f7f 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -218,10 +218,7 @@ void QDeclarativeTextPrivate::determineHorizontalAlignment()
if (hAlignImplicit && q->isComponentComplete()) {
// if no explicit alignment has been set, follow the natural layout direction of the text
QDeclarativeText::HAlignment previousAlign = hAlign;
- if (text.isEmpty() && QApplication::layoutDirection() == Qt::RightToLeft)
- hAlign = QDeclarativeText::AlignRight;
- else
- hAlign = text.isRightToLeft() ? QDeclarativeText::AlignRight : QDeclarativeText::AlignLeft;
+ hAlign = text.isRightToLeft() ? QDeclarativeText::AlignRight : QDeclarativeText::AlignLeft;
if (previousAlign != hAlign)
emit q->horizontalAlignmentChanged(hAlign);
}
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 5e1459c..78729aa 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -1547,10 +1547,7 @@ void QDeclarativeTextEditPrivate::determineHorizontalAlignment()
if (hAlignImplicit && q->isComponentComplete()) {
// if no explicit alignment has been set, follow the natural layout direction of the text
QDeclarativeTextEdit::HAlignment previousAlign = hAlign;
- if (text.isEmpty() && QApplication::layoutDirection() == Qt::RightToLeft)
- hAlign = QDeclarativeTextEdit::AlignRight;
- else
- hAlign = rightToLeftText ? QDeclarativeTextEdit::AlignRight : QDeclarativeTextEdit::AlignLeft;
+ hAlign = rightToLeftText ? QDeclarativeTextEdit::AlignRight : QDeclarativeTextEdit::AlignLeft;
if (previousAlign != hAlign)
emit q->horizontalAlignmentChanged(hAlign);
}
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index d9d9335..670a6ea 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -1283,10 +1283,7 @@ void QDeclarativeTextInputPrivate::determineHorizontalAlignment()
QString text = control->text();
// if no explicit alignment has been set, follow the natural layout direction of the text
QDeclarativeTextInput::HAlignment previousAlign = hAlign;
- if (text.isEmpty() && QApplication::layoutDirection() == Qt::RightToLeft)
- hAlign = QDeclarativeTextInput::AlignRight;
- else
- hAlign = text.isRightToLeft() ? QDeclarativeTextInput::AlignRight : QDeclarativeTextInput::AlignLeft;
+ hAlign = text.isRightToLeft() ? QDeclarativeTextInput::AlignRight : QDeclarativeTextInput::AlignLeft;
if (previousAlign != hAlign)
emit q->horizontalAlignmentChanged(hAlign);
}
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index 6c9998e..2aeb425 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -547,15 +547,11 @@ void tst_qdeclarativetext::horizontalAlignment_RightToLeft()
QCOMPARE(text->hAlign(), QDeclarativeText::AlignLeft);
QVERIFY(textPrivate->layout.lineAt(0).x() < canvas->width()/2);
- // empty text should implicitly follow the layout direction
- QApplication::setLayoutDirection(Qt::RightToLeft);
+ // empty text is also implicitly left aligned
text->setText("");
- QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight);
- text->setHAlign(QDeclarativeText::AlignLeft);
QCOMPARE(text->hAlign(), QDeclarativeText::AlignLeft);
-
- // set layout direction back to LTR to avoid affecting other autotests
- QApplication::setLayoutDirection(Qt::LeftToRight);
+ text->setHAlign(QDeclarativeText::AlignRight);
+ QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight);
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 6d5750f..ff52167 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -474,17 +474,13 @@ void tst_qdeclarativetextedit::hAlign_RightToLeft()
QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignLeft);
QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
- // empty text should implicitly follow the layout direction
- QApplication::setLayoutDirection(Qt::RightToLeft);
+ // empty text is also implicitly left aligned
textEdit->setText("");
- QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
- textEdit->setHAlign(QDeclarativeTextEdit::AlignLeft);
QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignLeft);
QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
-
- // set layout direction back to LTR to avoid affecting other autotests
- QApplication::setLayoutDirection(Qt::LeftToRight);
+ textEdit->setHAlign(QDeclarativeTextEdit::AlignRight);
+ QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 72e8b11..666bbc8 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -1078,17 +1078,13 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft()
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
- // empty text should implicitly follow the layout direction
- QApplication::setLayoutDirection(Qt::RightToLeft);
+ // empty text is also implicitly left aligned
textInput->setText("");
- QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
- QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
- textInput->setHAlign(QDeclarativeTextInput::AlignLeft);
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
-
- // set layout direction back to LTR to avoid affecting other autotests
- QApplication::setLayoutDirection(Qt::LeftToRight);
+ textInput->setHAlign(QDeclarativeTextInput::AlignRight);
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
delete canvas;
}