diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-07-06 01:11:59 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2010-07-06 01:16:14 (GMT) |
commit | 5500ffeeaee3412272f0f4af844fbc1d4d78a3bb (patch) | |
tree | 6b9c124f72272a4cc6f84c1ce1627126720d2e67 | |
parent | 8274fdc7ee8ecc03bb879ea79e9b3b3b4ca9ab37 (diff) | |
download | Qt-5500ffeeaee3412272f0f4af844fbc1d4d78a3bb.zip Qt-5500ffeeaee3412272f0f4af844fbc1d4d78a3bb.tar.gz Qt-5500ffeeaee3412272f0f4af844fbc1d4d78a3bb.tar.bz2 |
Fix TextEdit with no color property defined is drawn with wrong color
Task-number: QTBUG-11932
Reviewed-by: Martin Jones
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextedit.cpp | 9 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 18 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index c066f11..5b4d80b 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1263,6 +1263,15 @@ void QDeclarativeTextEditPrivate::init() control = new QTextControl(q); control->setIgnoreUnusedNavigationEvents(true); + // QTextControl follows the default text color + // defined by the platform, declarative text + // should be black by default + QPalette pal = control->palette(); + if (pal.color(QPalette::Text) != color) { + pal.setColor(QPalette::Text, color); + control->setPalette(pal); + } + QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF))); QObject::connect(control, SIGNAL(textChanged()), q, SLOT(q_textChanged())); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 65d45b1..2025504 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -57,6 +57,7 @@ #include <QStyle> #include <QInputContext> #include <private/qapplication_p.h> +#include <private/qtextcontrol_p.h> #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -492,6 +493,23 @@ void tst_qdeclarativetextedit::font() void tst_qdeclarativetextedit::color() { + //test initial color + { + QString componentStr = "import Qt 4.7\nTextEdit { text: \"Hello World\" }"; + QDeclarativeComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); + + QDeclarativeTextEditPrivate *textEditPrivate = static_cast<QDeclarativeTextEditPrivate*>(QDeclarativeItemPrivate::get(textEditObject)); + + QVERIFY(textEditObject); + QVERIFY(textEditPrivate); + QVERIFY(textEditPrivate->control); + + QPalette pal = textEditPrivate->control->palette(); + QCOMPARE(textEditPrivate->color, QColor("black")); + QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text)); + } //test normal for (int i = 0; i < colorStrings.size(); i++) { |