From 164b2b54922d87a44a60efe6dbbe2fa3b7716820 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Tue, 20 Jul 2010 15:14:11 +1000 Subject: Rewinding AnchorChanges should not make target item's implicit width and height explicit Task-number: QTBUG-12273 Reviewed-by: Michael Brasser --- .../util/qdeclarativestateoperations.cpp | 8 +++-- .../qdeclarativestates/data/anchorRewindBug.qml | 37 ++++++++++++++++++++++ .../qdeclarativestates/tst_qdeclarativestates.cpp | 35 ++++++++++++++++++++ 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 5590449..2291c16 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -1501,8 +1501,12 @@ void QDeclarativeAnchorChanges::rewind() d->target->setX(d->rewindX); d->target->setY(d->rewindY); - d->target->setWidth(d->rewindWidth); - d->target->setHeight(d->rewindHeight); + if (targetPrivate->widthValid) { + d->target->setWidth(d->rewindWidth); + } + if (targetPrivate->heightValid) { + d->target->setHeight(d->rewindHeight); + } } void QDeclarativeAnchorChanges::saveCurrentValues() diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml new file mode 100644 index 0000000..e6b6020 --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml @@ -0,0 +1,37 @@ +import Qt 4.7 +Rectangle { + id: container + color: "red" + height: 200 + width: 200 + Column { + id: column + objectName: "column" + anchors.left: container.right + anchors.bottom: container.bottom + + Rectangle { + id: rectangle + color: "blue" + height: 100 + width: 200 + } + Rectangle { + color: "blue" + height: 100 + width: 200 + } + } + states: State { + name: "reanchored" + AnchorChanges { + target: column + anchors.left: undefined + anchors.right: container.right + } + PropertyChanges { + target: rectangle + opacity: 0 + } + } +} \ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 639b2f3..7bc4fd4 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -121,6 +121,7 @@ private slots: void anchorChanges4(); void anchorChanges5(); void anchorChangesCrash(); + void anchorRewindBug(); void script(); void restoreEntryValues(); void explicitChanges(); @@ -807,6 +808,40 @@ void tst_qdeclarativestates::anchorChangesCrash() delete rect; } +// QTBUG-12273 +void tst_qdeclarativestates::anchorRewindBug() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug.qml"); + QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarativeItem * column = rect->findChild("column"); + + QVERIFY(column != 0); + QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); + QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 200.0); + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); + + // column height and width should stay implicit + // and column's implicit resizing should still work + QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); + QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 100.0); + + QDeclarativeItemPrivate::get(rect)->setState(""); + + // column height and width should stay implicit + // and column's implicit resizing should still work + QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); + QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 200.0); + + delete rect; +} + void tst_qdeclarativestates::script() { QDeclarativeEngine engine; -- cgit v0.12 From 78a01438e5a37fd1778924f73ca8bfa55960b0d0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 21 Jul 2010 10:36:17 +1000 Subject: font.letterSpacing used percentage rather than absolute values. ... and percentage is useless. Task-number: QTBUG-12282 Reviewed-by: Warwick Allison --- src/declarative/QmlChanges.txt | 5 ++++- src/declarative/graphicsitems/qdeclarativetext.cpp | 3 +-- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 3 +-- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 3 +-- src/declarative/qml/qdeclarativevaluetype.cpp | 2 +- tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp | 8 ++++---- .../declarative/qmlvisual/qdeclarativetext/font/plaintext.qml | 4 ++-- .../auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 872f6cb..6a2537b 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,9 +1,12 @@ ============================================================================= -The changes below are pre Qt 4.7.0 tech preview +The changes below are pre Qt 4.7.0 RC1 TextInput - copy(), cut() and paste() functions added +Font.letterSpacing + - was percentage based. Now specified in pixels. +============================================================================= The changes below are pre Qt 4.7.0 beta 2 QDeclarativeView diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index ec8bfb5..a1703c1 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -303,8 +303,7 @@ QDeclarativeTextPrivate::~QDeclarativeTextPrivate() Sets the letter spacing for the font. Letter spacing changes the default spacing between individual letters in the font. - A value of 100 will keep the spacing unchanged; a value of 200 will enlarge the spacing after a character by - the width of the character itself. + A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing. */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index d13e139..0cbada4 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -213,8 +213,7 @@ QString QDeclarativeTextEdit::text() const Sets the letter spacing for the font. Letter spacing changes the default spacing between individual letters in the font. - A value of 100 will keep the spacing unchanged; a value of 200 will enlarge the spacing after a character by - the width of the character itself. + A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing. */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 2a5d73d..321b121 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -176,8 +176,7 @@ void QDeclarativeTextInput::setText(const QString &s) Sets the letter spacing for the font. Letter spacing changes the default spacing between individual letters in the font. - A value of 100 will keep the spacing unchanged; a value of 200 will enlarge the spacing after a character by - the width of the character itself. + A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing. */ /*! diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index c17ec95..61e550a 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -973,7 +973,7 @@ qreal QDeclarativeFontValueType::letterSpacing() const void QDeclarativeFontValueType::setLetterSpacing(qreal size) { - font.setLetterSpacing(QFont::PercentageSpacing, size); + font.setLetterSpacing(QFont::AbsoluteSpacing, size); } qreal QDeclarativeFontValueType::wordSpacing() const diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 53862ec..821394d 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -848,22 +848,22 @@ void tst_qdeclarativetext::letterSpacing() QCOMPARE(textObject->font().letterSpacing(), 0.0); } { - QString componentStr = "import Qt 4.7\nText { text: \"Hello world!\"; font.letterSpacing: -50 }"; + QString componentStr = "import Qt 4.7\nText { text: \"Hello world!\"; font.letterSpacing: -2 }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeText *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), -50.); + QCOMPARE(textObject->font().letterSpacing(), -2.); } { - QString componentStr = "import Qt 4.7\nText { text: \"Hello world!\"; font.letterSpacing: 200 }"; + QString componentStr = "import Qt 4.7\nText { text: \"Hello world!\"; font.letterSpacing: 3 }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeText *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), 200.); + QCOMPARE(textObject->font().letterSpacing(), 3.); } } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml index 73dd4d7..e268a60 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml @@ -34,10 +34,10 @@ Rectangle { text: s.text; font.underline: true; font.overline: true; font.strikeout: true } Text { - text: s.text; font.letterSpacing: 200 + text: s.text; font.letterSpacing: 2 } Text { - text: s.text; font.underline: true; font.letterSpacing: 200; font.capitalization: "AllUppercase"; color: "blue" + text: s.text; font.underline: true; font.letterSpacing: 2; font.capitalization: "AllUppercase"; color: "blue" } Text { text: s.text; font.overline: true; font.wordSpacing: 25; font.capitalization: "Capitalize"; color: "green" diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml index b41b93a..a883b9c 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml @@ -34,10 +34,10 @@ Rectangle { text: s.text; font.underline: true; font.overline: true; font.strikeout: true } Text { - text: s.text; font.letterSpacing: 200 + text: s.text; font.letterSpacing: 2 } Text { - text: s.text; font.underline: true; font.letterSpacing: 200; font.capitalization: "AllUppercase"; color: "blue" + text: s.text; font.underline: true; font.letterSpacing: 2; font.capitalization: "AllUppercase"; color: "blue" } Text { text: s.text; font.overline: true; font.wordSpacing: 25; font.capitalization: "Capitalize"; color: "green" -- cgit v0.12 From 6d8b3453b6b4b151c777ad541ab25ca6bacc7381 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 21 Jul 2010 10:04:11 +1000 Subject: Fix clock example: make sure hands always moves forward. Task-number: QTBUG-12292 --- examples/declarative/toys/clocks/content/Clock.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/declarative/toys/clocks/content/Clock.qml b/examples/declarative/toys/clocks/content/Clock.qml index 24a07ec..eaa14c6 100644 --- a/examples/declarative/toys/clocks/content/Clock.qml +++ b/examples/declarative/toys/clocks/content/Clock.qml @@ -77,7 +77,7 @@ Item { origin.x: 7.5; origin.y: 73; angle: (clock.hours * 30) + (clock.minutes * 0.5) Behavior on angle { - NumberAnimation{} + RotationAnimation{ direction: RotationAnimation.Clockwise } } } } @@ -91,7 +91,7 @@ Item { origin.x: 6.5; origin.y: 83; angle: clock.minutes * 6 Behavior on angle { - NumberAnimation{} + RotationAnimation{ direction: RotationAnimation.Clockwise } } } } @@ -105,7 +105,7 @@ Item { origin.x: 2.5; origin.y: 80; angle: clock.seconds * 6 Behavior on angle { - NumberAnimation{} + RotationAnimation{ direction: RotationAnimation.Clockwise } } } } -- cgit v0.12 From 64833c0a648211f3fe7547436f022edc0ceb51ac Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 21 Jul 2010 10:52:08 +1000 Subject: Only ignore the same target value for a Behavior when it is running. Otherwise a Behavior may mistakenly not be triggered. This situation can arise when the property in question has been manipulated via the property system, followed by a direct function call (which correctly bypasses the Behavior), followed by a another change via the property system. Task-number: QTBUG-12295 --- src/declarative/util/qdeclarativebehavior.cpp | 2 +- .../qdeclarativebehaviors/data/qtbug12295.qml | 17 ++++++++++++++ .../tst_qdeclarativebehaviors.cpp | 27 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index 3719085..fadb2ae 100644 --- a/src/declarative/util/qdeclarativebehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -177,7 +177,7 @@ void QDeclarativeBehavior::write(const QVariant &value) return; } - if (value == d->targetValue) + if (d->animation->isRunning() && value == d->targetValue) return; d->currentValue = d->property.read(); diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml new file mode 100644 index 0000000..804559c --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml @@ -0,0 +1,17 @@ +import Qt 4.7 + +Rectangle { + width: 200 + height: 200 + color: "blue" + + Rectangle { + id: myRect + objectName: "myRect" + width: 100 + height: 100 + Behavior on x { + NumberAnimation {} + } + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 5c2c145..bb7fc7b 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -80,6 +80,7 @@ private slots: void startup(); void groupedPropertyCrash(); void runningTrue(); + void sameValue(); }; void tst_qdeclarativebehaviors::simpleBehavior() @@ -384,6 +385,32 @@ void tst_qdeclarativebehaviors::runningTrue() QTRY_VERIFY(runningSpy.count() > 0); } +//QTBUG-12295 +void tst_qdeclarativebehaviors::sameValue() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug12295.qml")); + QDeclarativeRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeRectangle *target = rect->findChild("myRect"); + QVERIFY(target); + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + //this is the main point of the test -- the behavior needs to be triggered again + //even though we set 0 twice in a row. + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); +} + QTEST_MAIN(tst_qdeclarativebehaviors) #include "tst_qdeclarativebehaviors.moc" -- cgit v0.12