From 9d9ac32f7be34c9ac30b23cf55b3f383d6c70568 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 15 Apr 2010 10:10:49 +1000 Subject: Fix localFont path in fonts example. --- examples/declarative/fonts/fonts.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index 97dd645..ae31b03 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -7,7 +7,7 @@ Rectangle { color: "steelblue" FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: localFont; source: "fonts/tarzenau-ocr-a.ttf" } + FontLoader { id: localFont; source: "fonts/tarzeau_ocr_a.ttf" } FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } Column { @@ -19,7 +19,7 @@ Rectangle { color: "lightsteelblue" width: parent.width elide: Text.ElideRight - font.family: "Times"; font.pointSize: 42 + font.family: "Times"; font.pointSize: 42 } Text { text: myText -- cgit v0.12 From 0ddd9958b483e4dbbd5d4b69f3a8425855bdc53b Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 15 Apr 2010 11:56:39 +1000 Subject: Output script errors in ScriptAction and StateChangeScript Task-number: QTBUG-9897 --- src/declarative/util/qdeclarativeanimation.cpp | 7 +++++++ src/declarative/util/qdeclarativestateoperations.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 33ddb46..fac38d7 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -44,6 +44,7 @@ #include "private/qdeclarativebehavior_p.h" #include "private/qdeclarativestateoperations_p.h" +#include "private/qdeclarativecontext_p.h" #include #include @@ -767,6 +768,7 @@ void QDeclarativeScriptAction::setStateChangeScriptName(const QString &name) void QDeclarativeScriptActionPrivate::execute() { + Q_Q(QDeclarativeScriptAction); if (hasRunScriptScript && reversing) return; @@ -775,7 +777,12 @@ void QDeclarativeScriptActionPrivate::execute() const QString &str = scriptStr.script(); if (!str.isEmpty()) { QDeclarativeExpression expr(scriptStr.context(), str, scriptStr.scopeObject()); + QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); + if (expr.hasError()) + qWarning() << expr.error(); } } diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 410a269..0521d27 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -49,6 +49,7 @@ #include #include #include +#include "private/qdeclarativecontext_p.h" #include #include @@ -571,7 +572,12 @@ void QDeclarativeStateChangeScript::execute() const QString &script = d->script.script(); if (!script.isEmpty()) { QDeclarativeExpression expr(d->script.context(), script, d->script.scopeObject()); + QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(this); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); + if (expr.hasError()) + qWarning() << expr.error(); } } -- cgit v0.12 From 5645cd7d7a97edb248a67d094993900f1dba4be8 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 15 Apr 2010 12:41:36 +1000 Subject: Make sure richtext wraps correctly with a fixed height set. --- src/declarative/graphicsitems/qdeclarativetext.cpp | 2 +- .../qdeclarativetext/tst_qdeclarativetext.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index b65212b..3a35dd5 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -677,7 +677,7 @@ void QDeclarativeTextPrivate::updateSize() QTextOption option((Qt::Alignment)int(hAlign | vAlign)); option.setWrapMode(QTextOption::WrapMode(wrapMode)); doc->setDefaultTextOption(option); - if (wrapMode != QDeclarativeText::NoWrap && !q->heightValid() && q->widthValid()) + if (wrapMode != QDeclarativeText::NoWrap && q->widthValid()) doc->setTextWidth(q->width()); else doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 2d10756..6637415 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -286,8 +286,28 @@ void tst_qdeclarativetext::wrap() QVERIFY(textObject != 0); QCOMPARE(textObject->width(), 30.); QVERIFY(textObject->height() > textHeight); + + qreal oldHeight = textObject->height(); + textObject->setWidth(100); + QVERIFY(textObject->height() < oldHeight); } + // richtext again with a fixed height + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import Qt 4.7\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }"; + QDeclarativeComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->width(), 30.); + QVERIFY(textObject->implicitHeight() > textHeight); + + qreal oldHeight = textObject->implicitHeight(); + textObject->setWidth(100); + QVERIFY(textObject->implicitHeight() < oldHeight); + } } void tst_qdeclarativetext::elide() -- cgit v0.12