diff options
17 files changed, 154 insertions, 511 deletions
diff --git a/demos/declarative/flickr/common/ImageDetails.qml b/demos/declarative/flickr/common/ImageDetails.qml deleted file mode 100644 index 862eeb1..0000000 --- a/demos/declarative/flickr/common/ImageDetails.qml +++ /dev/null @@ -1,160 +0,0 @@ -import Qt 4.6 -import org.webkit 1.0 - -Flipable { - id: container - - property var frontContainer: containerFront - property string photoTitle: "" - property string photoDescription: "" - property string photoTags: "" - property int photoWidth - property int photoHeight - property string photoType - property string photoAuthor - property string photoDate - property string photoUrl - property int rating: 2 - property var prevScale: 1.0 - - signal closed - - transform: Rotation { - id: detailsRotation - origin.y: container.height / 2; - origin.x: container.width / 2; - axis.y: 1; axis.z: 0 - } - - front: Item { - id: containerFront; anchors.fill: container - - Rectangle { - anchors.fill: parent - color: "black"; opacity: 0.4 - border.color: "white"; border.width: 2 - } - - MediaButton { - id: backButton; x: 630; y: 370; text: "Back" - onClicked: { container.closed() } - } - - MediaButton { - id: moreButton; x: 530; y: 370; text: "View..." - onClicked: { container.state='Back' } - } - - Text { id: titleText; style: Text.Raised; styleColor: "black"; color: "white"; elide: Text.ElideRight - x: 220; y: 30; width: parent.width - 240; text: container.photoTitle; font.pointSize: 22 } - - LikeOMeter { x: 40; y: 250; rating: container.rating } - - Flickable { id: flickable; x: 220; width: 480; height: 210; y: 130; clip: true - contentWidth: 480; contentHeight: descriptionText.height - - WebView { id: descriptionText; width: parent.width - html: "<style TYPE=\"text/css\">body {color: white;} a:link {color: cyan; text-decoration: underline; }</style>" + container.photoDescription } - } - - Text { id: size; color: "white"; width: 300; x: 40; y: 300 - text: "<b>Size:</b> " + container.photoWidth + 'x' + container.photoHeight } - Text { id: type; color: "white"; width: 300; x: 40; anchors.top: size.bottom - text: "<b>Type:</b> " + container.photoType } - - Text { id: author; color: "white"; width: 300; x: 220; y: 80 - text: "<b>Author:</b> " + container.photoAuthor } - Text { id: date; color: "white"; width: 300; x: 220; anchors.top: author.bottom - text: "<b>Published:</b> " + container.photoDate } - Text { id: tagsLabel; color: "white"; x: 220; anchors.top: date.bottom; - text: container.photoTags == "" ? "" : "<b>Tags:</b> " } - Text { id: tags; color: "white"; width: parent.width-x-20; - anchors.left: tagsLabel.right; anchors.top: date.bottom; - elide: Text.ElideRight; text: container.photoTags } - - ScrollBar { id: scrollBar; x: 720; y: flickable.y; width: 7; height: flickable.height; opacity: 0; - flickableArea: flickable; clip: true } - } - - back: Item { - anchors.fill: container - - Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4; border.color: "white"; border.width: 2 } - - Progress { anchors.centerIn: parent; width: 200; height: 18; progress: bigImage.progress; visible: bigImage.status!=1 } - Flickable { - id: flick; width: container.width - 10; height: container.height - 10 - x: 5; y: 5; clip: true; - contentWidth: imageContainer.width; contentHeight: imageContainer.height - - Item { - id: imageContainer - width: Math.max(bigImage.width * bigImage.scale, flick.width); - height: Math.max(bigImage.height * bigImage.scale, flick.height); - - Image { - id: bigImage; source: container.photoUrl; scale: slider.value - anchors.centerIn: parent; - smooth: !flick.moving - onStatusChanged : { - // Default scale shows the entire image. - if (status == 1 && width != 0) { - slider.minimum = Math.min(flick.width / width, flick.height / height); - prevScale = Math.min(slider.minimum, 1); - slider.value = prevScale; - } - } - } - } - } - - MediaButton { - id: backButton2; x: 630; y: 370; text: "Back"; onClicked: { container.state = '' } - } - Text { - text: "Image Unavailable" - visible: bigImage.status == 'Error' - anchors.centerIn: parent; color: "white"; font.bold: true - } - - Slider { - id: slider; x: 25; y: 374; visible: { bigImage.status == 1 && maximum > minimum } - onValueChanged: { - if (bigImage.width * value > flick.width) { - var xoff = (flick.width/2 + flick.contentX) * value / prevScale; - flick.contentX = xoff - flick.width/2; - } - if (bigImage.height * value > flick.height) { - var yoff = (flick.height/2 + flick.contentY) * value / prevScale; - flick.contentY = yoff - flick.height/2; - } - prevScale = value; - } - } - } - - states: [ - State { - name: "Back" - PropertyChanges { target: detailsRotation; angle: 180 } - } - ] - - transitions: [ - Transition { - SequentialAnimation { - PropertyAction { - target: bigImage - property: "smooth" - value: false - } - NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 500 } - PropertyAction { - target: bigImage - property: "smooth" - value: !flick.moving - } - } - } - ] -} diff --git a/demos/declarative/flickr/common/MediaButton.qml b/demos/declarative/flickr/common/MediaButton.qml deleted file mode 100644 index 86ac948..0000000 --- a/demos/declarative/flickr/common/MediaButton.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.6 - -Item { - id: container - - signal clicked - - property string text - - Image { - id: buttonImage - source: "pics/button.png" - } - Image { - id: pressed - source: "pics/button-pressed.png" - opacity: 0 - } - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.clicked(); } - } - Text { - font.bold: true - color: "white" - anchors.centerIn: buttonImage - text: container.text - } - width: buttonImage.width - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { - target: pressed - opacity: 1 - } - } - ] -} diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml deleted file mode 100644 index 9559f6a..0000000 --- a/demos/declarative/flickr/common/MediaLineEdit.qml +++ /dev/null @@ -1,104 +0,0 @@ -import Qt 4.6 - -Item { - id: container - - property string label - property string text - - width: Math.max(94,labeltext.width + editor.width + 20) - height: buttonImage.height - - states: [ - State { - name: "Edit" - PropertyChanges { - target: labeltext - text: container.label + ": " - } - PropertyChanges { - target: labeltext - x: 10 - } - PropertyChanges { - target: editor - cursorVisible: true - width: 100 - } - PropertyChanges { - target: container - focus: true - } - StateChangeScript { - script:editor.selectAll() - } - }, - State { - // When returning to default state, typed text is propagated - StateChangeScript { - script: container.text = editor.text - } - } - ] - transitions: [ - Transition { - NumberAnimation { properties: "x,width"; duration: 500; easing.type: "InOutQuad" } - } - ] - - - BorderImage { - id: buttonImage - source: "pics/button.sci" - anchors.left: container.left - anchors.right: container.right - } - - BorderImage { - id: pressed - source: "pics/button-pressed.sci" - opacity: 0 - anchors.left: container.left - anchors.right: container.right - } - - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.state = container.state=="Edit" ? "" : "Edit" } - states: [ - State { - when: mouseRegion.pressed == true - PropertyChanges { - target: pressed - opacity: 1 - } - } - ] - } - - Text { - id: labeltext - font.bold: true - color: "white" - anchors.verticalCenter: container.verticalCenter - x: (container.width - width)/2 - text: container.label + "..." - } - - TextInput { - id: editor - font.bold: true - color: "white" - selectionColor: "green" - width: 0 - clip: true - anchors.left: labeltext.right - anchors.verticalCenter: container.verticalCenter - } - Keys.forwardTo: [(returnKey), (editor)] - Item { - id: returnKey - Keys.onReturnPressed: "container.state = ''" - } -} diff --git a/demos/declarative/flickr/flickr-mobile-90.qml b/demos/declarative/flickr/flickr-90.qml index 9fec242..1d1ac40 100644 --- a/demos/declarative/flickr/flickr-mobile-90.qml +++ b/demos/declarative/flickr/flickr-90.qml @@ -6,6 +6,6 @@ Item { Loader { y: 320; rotation: -90 transformOrigin: Item.TopLeft - source: "flickr-mobile.qml" + source: "flickr.qml" } } diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml deleted file mode 100644 index 63b6ea2..0000000 --- a/demos/declarative/flickr/flickr-desktop.qml +++ /dev/null @@ -1,194 +0,0 @@ -import Qt 4.6 - -import "common" - -Item { - id: mainWindow; width: 800; height: 450 - - property bool showPathView : false - - resources: [ - Component { - id: photoDelegate - Item { - id: wrapper; width: 85; height: 85 - scale: wrapper.PathView.scale ? wrapper.PathView.scale : 1 - z: wrapper.PathView.z ? wrapper.PathView.z : 0 - - transform: Rotation { - id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 - axis.y: 1; axis.z: 0 - angle: wrapper.PathView.angle ? wrapper.PathView.angle : 0 - } - - Connections { - target: imageDetails - onClosed: { - if (wrapper.state == 'Details') { - wrapper.state = ''; - imageDetails.photoUrl = ""; - } - } - } - - function photoClicked() { - imageDetails.photoTitle = title; - imageDetails.photoDescription = description; - imageDetails.photoTags = tags; - imageDetails.photoWidth = photoWidth; - imageDetails.photoHeight = photoHeight; - imageDetails.photoType = photoType; - imageDetails.photoAuthor = photoAuthor; - imageDetails.photoDate = photoDate; - imageDetails.photoUrl = url; - imageDetails.rating = 0; - wrapper.state = "Details"; - } - - Rectangle { - id: whiteRect; anchors.fill: parent; color: "white"; radius: 5 - - Loading { x: 26; y: 26; visible: thumb.status!=1 } - Image { id: thumb; source: imagePath; x: 5; y: 5 } - - Item { - id: shadows - Image { source: "common/pics/shadow-right.png"; x: whiteRect.width; height: whiteRect.height } - Image { source: "common/pics/shadow-bottom.png"; y: whiteRect.height; width: whiteRect.width } - Image { id: corner; source: "common/pics/shadow-corner.png"; x: whiteRect.width; y: whiteRect.height } - } - } - - MouseArea { anchors.fill: wrapper; onClicked: { photoClicked() } } - - states: [ - State { - name: "Details" - PropertyChanges { target: imageDetails; z: 2 } - ParentChange { target: wrapper; parent: imageDetails.frontContainer } - PropertyChanges { target: wrapper; x: 45; y: 35; scale: 1; z: 1000 } - PropertyChanges { target: itemRotation; angle: 0 } - PropertyChanges { target: shadows; opacity: 0 } - PropertyChanges { target: imageDetails; y: 20 } - PropertyChanges { target: photoGridView; y: -480 } - PropertyChanges { target: photoPathView; y: -480 } - PropertyChanges { target: viewModeButton; opacity: 0 } - PropertyChanges { target: tagsEdit; opacity: 0 } - PropertyChanges { target: fetchButton; opacity: 0 } - PropertyChanges { target: categoryText; y: "-50" } - } - ] - - transitions: [ - Transition { - from: "*"; to: "Details" - SequentialAnimation { - ParentAnimation { - NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" } - } - } - }, - Transition { - from: "Details"; to: "*" - SequentialAnimation { - ParentAnimation { - NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" } - } - PropertyAction { targets: wrapper; properties: "z" } - } - } - ] - - } - } - ] - - Item { - id: background - - anchors.fill: parent - - Image { source: "common/pics/background.png"; anchors.fill: parent } - RssModel { id: rssModel; tags : tagsEdit.text } - Loading { anchors.centerIn: parent; visible: rssModel.status == 2 } - - GridView { - id: photoGridView; model: rssModel; delegate: photoDelegate; cacheBuffer: 100 - cellWidth: 105; cellHeight: 105; x:32; y: 80; width: 800; height: 330; z: 1 - } - - PathView { - id: photoPathView; model: rssModel; delegate: photoDelegate - y: -380; width: 800; height: 330; pathItemCount: 10; z: 1 - path: Path { - startX: -50; startY: 40; - - PathAttribute { name: "scale"; value: 1 } - PathAttribute { name: "angle"; value: -45 } - - PathCubic { - x: 400; y: 220 - control1X: 140; control1Y: 40 - control2X: 210; control2Y: 220 - } - - PathAttribute { name: "scale"; value: 1.2 } - PathAttribute { name: "z"; value: 1 } - PathAttribute { name: "angle"; value: 0 } - - PathCubic { - x: 850; y: 40 - control2X: 660; control2Y: 40 - control1X: 590; control1Y: 220 - } - - PathAttribute { name: "scale"; value: 1 } - PathAttribute { name: "angle"; value: 45 } - } - - } - - ImageDetails { id: imageDetails; width: 750; x: 25; y: 500; height: 410 } - - MediaButton { - id: viewModeButton; x: 680; y: 410; text: "View Mode" - onClicked: { if (mainWindow.showPathView == true) mainWindow.showPathView = false; else mainWindow.showPathView = true } - } - - MediaButton { - id: fetchButton - text: "Update" - anchors.right: viewModeButton.left; anchors.rightMargin: 5 - anchors.top: viewModeButton.top - onClicked: { rssModel.reload(); } - } - - MediaLineEdit { - id: tagsEdit; - label: "Tags" - anchors.right: fetchButton.left; anchors.rightMargin: 5 - anchors.top: viewModeButton.top - } - - states: State { - name: "PathView" - when: mainWindow.showPathView == true - PropertyChanges { target: photoPathView; y: 80 } - PropertyChanges { target: photoGridView; y: -380 } - } - - transitions: [ - Transition { - from: "*"; to: "*" - NumberAnimation { properties: "y"; duration: 1000; easing.type: "OutBounce"; easing.amplitude: 0.5 } - } - ] - } - - Text { - id: categoryText; anchors.horizontalCenter: parent.horizontalCenter; y: 15; - text: "Flickr - " + - (rssModel.tags=="" ? "Uploads from everyone" : "Recent Uploads tagged " + rssModel.tags) - font.pointSize: 20; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - } -} diff --git a/demos/declarative/flickr/flickr-mobile.qml b/demos/declarative/flickr/flickr.qml index 21e4c49..21e4c49 100644 --- a/demos/declarative/flickr/flickr-mobile.qml +++ b/demos/declarative/flickr/flickr.qml diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index c95bd29..a6cc75e 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -651,7 +651,7 @@ bool QDeclarativeMouseArea::setPressed(bool p) emit positionChanged(&me); } else { emit released(&me); - if (isclick) + if (isclick && !d->longPress) emit clicked(&me); } diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index 839e0dd..49e7b79 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -619,7 +619,7 @@ void QDeclarativeEasingValueType::setPeriod(qreal period) } QDeclarativeFontValueType::QDeclarativeFontValueType(QObject *parent) -: QDeclarativeValueType(parent), hasPixelSize(false) +: QDeclarativeValueType(parent), pixelSizeSet(false), pointSizeSet(false) { } @@ -627,6 +627,8 @@ void QDeclarativeFontValueType::read(QObject *obj, int idx) { void *a[] = { &font, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a); + pixelSizeSet = false; + pointSizeSet = false; } void QDeclarativeFontValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags) @@ -724,13 +726,17 @@ qreal QDeclarativeFontValueType::pointSize() const void QDeclarativeFontValueType::setPointSize(qreal size) { - if (hasPixelSize) { + if (pixelSizeSet) { qWarning() << "Both point size and pixel size set. Using pixel size."; return; } - if (size >= 0.0) + if (size >= 0.0) { + pointSizeSet = true; font.setPointSizeF(size); + } else { + pointSizeSet = false; + } } int QDeclarativeFontValueType::pixelSize() const @@ -741,10 +747,12 @@ int QDeclarativeFontValueType::pixelSize() const void QDeclarativeFontValueType::setPixelSize(int size) { if (size >=0) { + if (pointSizeSet) + qWarning() << "Both point size and pixel size set. Using pixel size."; font.setPixelSize(size); - hasPixelSize = true; + pixelSizeSet = true; } else { - hasPixelSize = false; + pixelSizeSet = false; } } diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h index 1fe8bd2..763177d 100644 --- a/src/declarative/qml/qdeclarativevaluetype_p.h +++ b/src/declarative/qml/qdeclarativevaluetype_p.h @@ -399,7 +399,8 @@ public: private: QFont font; - bool hasPixelSize; + bool pixelSizeSet; + bool pointSizeSet; }; QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index 5e6c35e..e4c968e 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -121,14 +121,13 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje /*! \qmlclass State QDeclarativeState - \since 4.7 + \since 4.7 \brief The State element defines configurations of objects and properties. A state is specified as a set of batched changes from the default configuration. - Note that setting the state of an object from within another state of the same object is - inadvisible. Not only would this have the same effect as going directly to the second state - it may cause the program to crash. + \note setting the state of an object from within another state of the same object is + not allowed. \sa {qmlstates}{States}, {state-transitions}{Transitions} */ @@ -191,6 +190,17 @@ bool QDeclarativeState::isWhenKnown() const This should be set to an expression that evaluates to true when you want the state to be applied. + + If multiple states in a group have \c when clauses that evaluate to true at the same time, + the first matching state will be applied. For example, in the following snippet + \c state1 will always be selected rather than \c state2 when sharedCondition becomes + \c true. + \qml + states: [ + State { name: "state1"; when: sharedCondition }, + State { name: "state2"; when: sharedCondition } + ] + \endqml */ QDeclarativeBinding *QDeclarativeState::when() const { diff --git a/tests/auto/declarative/qdeclarativemousearea/data/clickandhold.qml b/tests/auto/declarative/qdeclarativemousearea/data/clickandhold.qml new file mode 100644 index 0000000..e800f98 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemousearea/data/clickandhold.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +Item { + id: root + property bool clicked: false + property bool held: false + + MouseArea { + width: 200; height: 200 + onClicked: { root.clicked = true } + onPressAndHold: { root.held = true } + } +} diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index dfe46e4..bdb8eca 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -53,6 +53,7 @@ private slots: void dragProperties(); void resetDrag(); void updateMouseAreaPosOnClick(); + void noOnClickedWithPressAndHold(); private: QDeclarativeView *createView(); }; @@ -202,6 +203,36 @@ void tst_QDeclarativeMouseArea::updateMouseAreaPosOnClick() delete canvas; } +void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold() +{ + QDeclarativeView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/clickandhold.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QGraphicsScene *scene = canvas->scene(); + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setScenePos(QPointF(100, 100)); + pressEvent.setButton(Qt::LeftButton); + pressEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &pressEvent); + + QVERIFY(!canvas->rootObject()->property("clicked").toBool()); + QVERIFY(!canvas->rootObject()->property("held").toBool()); + + QTest::qWait(1000); + + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMousePress); + releaseEvent.setScenePos(QPointF(100, 100)); + releaseEvent.setButton(Qt::LeftButton); + releaseEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &releaseEvent); + + QVERIFY(!canvas->rootObject()->property("clicked").toBool()); + QVERIFY(canvas->rootObject()->property("held").toBool()); +} + QTEST_MAIN(tst_QDeclarativeMouseArea) #include "tst_qdeclarativemousearea.moc" diff --git a/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml new file mode 100644 index 0000000..7369c63 --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml @@ -0,0 +1,11 @@ +import Qt 4.6 + +Rectangle { + property bool condition1: false + property bool condition2: false + + states: [ + State { name: "state1"; when: condition1 }, + State { name: "state2"; when: condition2 } + ] +} diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index e7c595a..f0b6759 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -108,6 +108,7 @@ private slots: void nonExistantProperty(); void reset(); void illegalObjectCreation(); + void whenOrdering(); }; void tst_qdeclarativestates::initTestCase() @@ -993,6 +994,28 @@ void tst_qdeclarativestates::illegalObjectCreation() QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects."); } +void tst_qdeclarativestates::whenOrdering() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->state(), QLatin1String("")); + rect->setProperty("condition2", true); + QCOMPARE(rect->state(), QLatin1String("state2")); + rect->setProperty("condition1", true); + QCOMPARE(rect->state(), QLatin1String("state1")); + rect->setProperty("condition2", false); + QCOMPARE(rect->state(), QLatin1String("state1")); + rect->setProperty("condition2", true); + QCOMPARE(rect->state(), QLatin1String("state1")); + rect->setProperty("condition1", false); + rect->setProperty("condition2", false); + QCOMPARE(rect->state(), QLatin1String("")); +} + QTEST_MAIN(tst_qdeclarativestates) #include "tst_qdeclarativestates.moc" diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml new file mode 100644 index 0000000..2ec69d7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + font.pointSize: 19 + font.pixelSize: 10 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml new file mode 100644 index 0000000..4c12f21 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml @@ -0,0 +1,14 @@ +import Qt 4.6 +import Test 1.0 + +Item { + MyTypeObject { + objectName: "object1" + font.pixelSize: 19 + } + MyTypeObject { + objectName: "object2" + font.pointSize: 14 + } +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 4e254eb..fb487f0 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -352,6 +352,30 @@ void tst_qdeclarativevaluetypes::font() delete object; } + { + QDeclarativeComponent component(&engine, TEST_FILE("font_write.4.qml")); + QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->font().pixelSize(), 10); + + delete object; + } + { + QDeclarativeComponent component(&engine, TEST_FILE("font_write.5.qml")); + QObject *object = qobject_cast<QObject *>(component.create()); + QVERIFY(object != 0); + MyTypeObject *object1 = object->findChild<MyTypeObject *>("object1"); + QVERIFY(object1 != 0); + MyTypeObject *object2 = object->findChild<MyTypeObject *>("object2"); + QVERIFY(object2 != 0); + + QCOMPARE(object1->font().pixelSize(), 19); + QCOMPARE(object2->font().pointSize(), 14); + + delete object; + } } // Test bindings can write to value types |