From bf0cfe31094cd965abb73dab0611c9d3646c2bfb Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 14 Jul 2009 16:32:38 +1000 Subject: Add Timer to elements reference --- doc/src/declarative/elements.qdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index eda9079..32bf40e 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -53,6 +53,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \l Script \o \l Connection \o \l Component +\o \l Timer \endlist \endtable -- cgit v0.12 From 8ea9cf839ed2bc5cd8a152fc6f10400e24242924 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 14 Jul 2009 16:33:07 +1000 Subject: Remove unnecessary semicolons --- src/declarative/extra/qfxflowview.cpp | 4 ++-- src/declarative/extra/qfxflowview.h | 6 +++--- src/declarative/extra/qmlbehaviour.cpp | 4 ++-- src/declarative/fx/qfxgridview.cpp | 6 +++--- src/declarative/fx/qfxlistview.cpp | 10 +++++----- src/declarative/fx/qfxvisualitemmodel.cpp | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp index 412cbc8..1676512 100644 --- a/src/declarative/extra/qfxflowview.cpp +++ b/src/declarative/extra/qfxflowview.cpp @@ -49,8 +49,8 @@ QT_BEGIN_NAMESPACE class QFxFlowViewAttached : public QObject { Q_OBJECT -Q_PROPERTY(int row READ row NOTIFY posChanged); -Q_PROPERTY(int column READ column NOTIFY posChanged); +Q_PROPERTY(int row READ row NOTIFY posChanged) +Q_PROPERTY(int column READ column NOTIFY posChanged) public: QFxFlowViewAttached(QObject *parent); diff --git a/src/declarative/extra/qfxflowview.h b/src/declarative/extra/qfxflowview.h index 126f567..c2b30a3 100644 --- a/src/declarative/extra/qfxflowview.h +++ b/src/declarative/extra/qfxflowview.h @@ -58,8 +58,8 @@ class Q_DECLARATIVE_EXPORT QFxFlowView : public QFxItem { Q_OBJECT Q_PROPERTY(QFxVisualItemModel *model READ model WRITE setModel) - Q_PROPERTY(int column READ columns WRITE setColumns); - Q_PROPERTY(bool vertical READ vertical WRITE setVertical); + Q_PROPERTY(int column READ columns WRITE setColumns) + Q_PROPERTY(bool vertical READ vertical WRITE setVertical) public: QFxFlowView(); @@ -101,7 +101,7 @@ private: QT_END_NAMESPACE -QML_DECLARE_TYPE(QFxFlowView); +QML_DECLARE_TYPE(QFxFlowView) QT_END_HEADER diff --git a/src/declarative/extra/qmlbehaviour.cpp b/src/declarative/extra/qmlbehaviour.cpp index 4165d56..f2d5e9a 100644 --- a/src/declarative/extra/qmlbehaviour.cpp +++ b/src/declarative/extra/qmlbehaviour.cpp @@ -57,8 +57,8 @@ public: QmlBehaviourData(QObject *parent) : QObject(parent) {} - Q_PROPERTY(QVariant endValue READ endValue NOTIFY valuesChanged); - Q_PROPERTY(QVariant startValue READ startValue NOTIFY valuesChanged); + Q_PROPERTY(QVariant endValue READ endValue NOTIFY valuesChanged) + Q_PROPERTY(QVariant startValue READ startValue NOTIFY valuesChanged) QVariant endValue() const { return e; } QVariant startValue() const { return s; } diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 11b630a..a43e84c 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -57,10 +57,10 @@ public: attachedProperties.remove(parent()); } - Q_PROPERTY(QFxGridView *view READ view); + Q_PROPERTY(QFxGridView *view READ view) QFxGridView *view() { return m_view; } - Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged); + Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) bool isCurrentItem() const { return m_isCurrent; } void setIsCurrentItem(bool c) { if (m_isCurrent != c) { @@ -69,7 +69,7 @@ public: } } - Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged); + Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) bool delayRemove() const { return m_delayRemove; } void setDelayRemove(bool delay) { if (m_delayRemove != delay) { diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 889cfdd..8b39773 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -58,10 +58,10 @@ public: attachedProperties.remove(parent()); } - Q_PROPERTY(QFxListView *view READ view); + Q_PROPERTY(QFxListView *view READ view) QFxListView *view() { return m_view; } - Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged); + Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) bool isCurrentItem() const { return m_isCurrent; } void setIsCurrentItem(bool c) { if (m_isCurrent != c) { @@ -70,7 +70,7 @@ public: } } - Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged); + Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged) QString prevSection() const { return m_prevSection; } void setPrevSection(const QString §) { if (m_prevSection != sect) { @@ -79,7 +79,7 @@ public: } } - Q_PROPERTY(QString section READ section NOTIFY sectionChanged); + Q_PROPERTY(QString section READ section NOTIFY sectionChanged) QString section() const { return m_section; } void setSection(const QString §) { if (m_section != sect) { @@ -88,7 +88,7 @@ public: } } - Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged); + Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) bool delayRemove() const { return m_delayRemove; } void setDelayRemove(bool delay) { if (m_delayRemove != delay) { diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index d3ab4cc..0682294 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -159,7 +159,7 @@ Q_OBJECT public: QFxVisualItemModelData(int index, QFxVisualItemModelPrivate *model); - Q_PROPERTY(int index READ index NOTIFY indexChanged); + Q_PROPERTY(int index READ index NOTIFY indexChanged) int index() const; void setIndex(int index); -- cgit v0.12 From 700f70761782fc30eb550f0036712123232af2dd Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 16 Jul 2009 14:32:34 +1000 Subject: Fix a bug in QmlFollow Using a follow by turning it on and off at times was not working right. --- src/declarative/util/qmlfollow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index b8e6685..1e4468c 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -188,6 +188,7 @@ void QmlFollowPrivate::start() property.write(currentValue); } else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) { lastTime = 0; + currentValue = property.read().toDouble(); clock.start(); // infinity?? } } -- cgit v0.12 From a484b83cbc968a8088e6fd1b0bb39570ba157c93 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 16 Jul 2009 14:37:15 +1000 Subject: Updates to the SameGame demo Tiles now fall down from the top, instead of the corner, and a bit of clean up. --- demos/declarative/samegame/TODO | 6 ++---- demos/declarative/samegame/content/BoomBlock.qml | 6 +++--- demos/declarative/samegame/content/FastBlock.qml | 4 ++-- demos/declarative/samegame/content/samegame.js | 3 ++- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/demos/declarative/samegame/TODO b/demos/declarative/samegame/TODO index b02ce54..bbe881f 100644 --- a/demos/declarative/samegame/TODO +++ b/demos/declarative/samegame/TODO @@ -1,5 +1,3 @@ Still to do before initial release --Garbage collect on click --Particles with count 0->50 should work properly --Particles are too slow to start --Everything is too slow, we should have four times the number of tiles there +-Garbage collect after click +-Second *good* theme diff --git a/demos/declarative/samegame/content/BoomBlock.qml b/demos/declarative/samegame/content/BoomBlock.qml index 0d05772..5e5cf18 100644 --- a/demos/declarative/samegame/content/BoomBlock.qml +++ b/demos/declarative/samegame/content/BoomBlock.qml @@ -1,11 +1,11 @@ Item { id:block property bool dying: false - property bool spawning: false + property bool spawned: false property int type: 0 property int targetX: 0 property int targetY: 0 - x: Follow { source: targetX; spring: 1.2; damping: 0.1 } + x: Follow { enabled: spawned; source: targetX; spring: 1.2; damping: 0.1 } y: Follow { source: targetY; spring: 1.2; damping: 0.1 } Image { id: img @@ -38,7 +38,7 @@ Item { id:block } states: [ - State{ name: "AliveState"; when: spawning == true && dying == false + State{ name: "AliveState"; when: spawned == true && dying == false SetProperties { target: img; opacity: 1 } }, State{ name: "DeathState"; when: dying == true diff --git a/demos/declarative/samegame/content/FastBlock.qml b/demos/declarative/samegame/content/FastBlock.qml index 04eb59b..c3e8829 100644 --- a/demos/declarative/samegame/content/FastBlock.qml +++ b/demos/declarative/samegame/content/FastBlock.qml @@ -1,7 +1,7 @@ Rect { id:block //Note: These properties are the interface used to control the blocks property bool dying: false - property bool spawning: false + property bool spawned: false property int type: 0 property int targetY: 0 property int targetX: 0 @@ -17,7 +17,7 @@ Rect { id:block states: [ - State{ name: "SpawnState"; when: spawning == true && dying == false + State{ name: "AliveState"; when: spawned == true && dying == false SetProperties { target: block; opacity: 1 } }, State{ name: "DeathState"; when: dying == true diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index fe5ac87..1163bae 100644 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -177,11 +177,12 @@ function finishCreatingBlock(xIdx,yIdx){ } dynamicObject.type = Math.floor(Math.random() * 3); dynamicObject.parent = gameCanvas; + dynamicObject.x = xIdx*tileSize; dynamicObject.targetX = xIdx*tileSize; dynamicObject.targetY = yIdx*tileSize; dynamicObject.width = tileSize; dynamicObject.height = tileSize; - dynamicObject.spawning = true; + dynamicObject.spawned = true; board[index(xIdx,yIdx)] = dynamicObject; return true; }else if(component.isError()){ -- cgit v0.12 From 319eba26b183c5d67f1950255bf3758b8fd64011 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 16 Jul 2009 15:00:59 +1000 Subject: SameGame notifies player of game over As requested by Aaron. --- demos/declarative/samegame/SameGame.qml | 6 +++--- demos/declarative/samegame/content/SameDialog.qml | 4 ++-- demos/declarative/samegame/content/samegame.js | 26 +++++++++++++++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index c929c91..9ae87bd 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -29,13 +29,13 @@ Rect { anchors.topMargin: 10 anchors.horizontalCenter: parent.horizontalCenter MediaButton { id: btnA; text: "New Game"; onClicked: {initBoard();} } - MediaButton { id: btnB; text: "Swap Theme"; onClicked: {swapTileSrc(); dialog.opacity = 1;} - } + MediaButton { id: btnB; text: "Swap Theme"; onClicked: {swapTileSrc(); dialog.opacity = 1; + dialog.text="Takes effect next game.";} } Text{ text: "Score: " + gameCanvas.score; width:100 } } SameDialog { id: dialog anchors.centeredIn: parent - text: "Takes effect next game." + text: "Hello World" } } diff --git a/demos/declarative/samegame/content/SameDialog.qml b/demos/declarative/samegame/content/SameDialog.qml index eed52f0..a0718f2 100644 --- a/demos/declarative/samegame/content/SameDialog.qml +++ b/demos/declarative/samegame/content/SameDialog.qml @@ -5,8 +5,8 @@ Rect { opacity: 0 opacity: Behavior { SequentialAnimation { - NumberAnimation {property: "opacity"; duration: 1000 } - NumberAnimation {property: "opacity"; to: 0; duration: 1000 } + NumberAnimation {property: "opacity"; duration: 1500 } + NumberAnimation {property: "opacity"; to: 0; duration: 1500 } } } color: "white" diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 1163bae..d2a3cbc 100644 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -145,13 +145,35 @@ function shuffleDown() function victoryCheck() { - //Only awards bonuses at the moment + //awards bonuses deservesBonus = true; for(xIdx=maxX-1; xIdx>=0; xIdx--) if(board[index(xIdx, maxY - 1)] != null) deservesBonus = false; if(deservesBonus) - gameCanvas.score += 250; + gameCanvas.score += 500; + //Checks for game over + if(deservesBonus || noMoreMoves()){ + dialog.text = "Game Over. Your score is " + gameCanvas.score; + dialog.opacity = 1; + } +} + +function noMoreMoves() +{ + return !floodMoveCheck(0, maxY-1, -1); +} + +function floodMoveCheck(xIdx, yIdx, type) +{ + if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) + return false; + if(board[index(xIdx, yIdx)] == null) + return false; + myType = board[index(xIdx, yIdx)].type; + if(type == myType) + return true; + return floodMoveCheck(xIdx + 1, yIdx, myType) || floodMoveCheck(xIdx, yIdx - 1, myType); } //Need a simpler method of doing this? -- cgit v0.12 From dff083ccb6971fa28d838493353857783297b4a9 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 17 Jul 2009 16:48:36 +1000 Subject: Remove debuggery --- src/declarative/qml/qmlcompositetypemanager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 9af5c3c..3037051 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -251,7 +251,6 @@ void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit, error.setUrl(url); error.setDescription(tr("Import %1 unavailable").arg(imp.uri)); unit->errors << error; -qDebug() << "ERR"; ok = false; } } -- cgit v0.12 From 3b4ef95d18631845d34e63186fdf76124443ac79 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 20 Jul 2009 11:00:52 +1000 Subject: Add missing docs. --- src/declarative/extra/qmlxmllistmodel.cpp | 4 ++++ src/declarative/fx/qfximage.cpp | 6 ++++++ src/declarative/util/qmllistmodel.cpp | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 7f0029d..91ad538 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -432,6 +432,10 @@ QHash QmlXmlListModel::data(int index, const QList &roles) co return rv; } +/*! + \qmlproperty int XmlListModel::count + The number of data entries in the model. +*/ int QmlXmlListModel::count() const { Q_D(const QmlXmlListModel); diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 027b22a..69030d2 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -464,6 +464,12 @@ QUrl QFxImage::source() const return d->url; } +/*! + \qmlproperty bool Image::preserveAspect + + Whether the image's aspect ratio should be preserved when resizing. By default this + is false. +*/ bool QFxImage::preserveAspect() const { Q_D(const QFxImage); diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 61d32f4..8edd871 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -331,6 +331,10 @@ QHash QmlListModel::data(int index, const QList &roles) const return rv; } +/*! + \qmlproperty int ListModel::count + The number of data entries in the model. +*/ int QmlListModel::count() const { if (!_root) return 0; -- cgit v0.12 From 7c0a59857cf7a74eb16ba4186b10514f159b7aab Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Jul 2009 11:03:14 +1000 Subject: Fixup minehunt example with the new style particle explosions Note that there seems to be a bug still with when the RunScriptAction is called. --- examples/declarative/minehunt/Explosion.qml | 15 ++++++++++++--- examples/declarative/minehunt/minehunt.qml | 7 ++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/declarative/minehunt/Explosion.qml b/examples/declarative/minehunt/Explosion.qml index 2886559..84e93d4 100644 --- a/examples/declarative/minehunt/Explosion.qml +++ b/examples/declarative/minehunt/Explosion.qml @@ -2,17 +2,26 @@ Item { property bool explode : false Particles { + id: particles width: 38 height: 21 - lifeSpan: 3600000 + lifeSpan: 1000 lifeSpanDeviation: 0 source: "pics/star.png" - count: 200 + count: 0 angle: 270 angleDeviation: 360 velocity: 100 velocityDeviation: 20 z: 100 - emitting: explode + opacity: 0 + streamIn: false } + states: [ State { name: "exploding"; when: explode == true + SetProperties { target: particles; count: 200 } + SetProperties { target: particles; opacity: 1 } + SetProperties { target: particles; emitting: false } // i.e. emit only once + } + ] + } diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index 286e485..3dc1da4 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -55,9 +55,10 @@ Item { opacity: modelData.hasMine } Explosion { + id: expl anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - explode: modelData.hasMine && modelData.flipped + //explode: modelData.hasMine && modelData.flipped//Doesn't wait for the pause } } states: [ @@ -89,6 +90,10 @@ Item { easing: "easeInOutQuad" properties: "rotation" } + RunScriptAction{ + script: if(modelData.hasMine && modelData.flipped) + {expl.explode = true;} + } } } ] -- cgit v0.12 From 0eaa2231ed4e3acc0c1411492c13d9057d1caa00 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 20 Jul 2009 11:54:56 +1000 Subject: Compile fix. --- src/corelib/kernel/qmetaobjectbuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index e6817fe..d655e3f 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qmetaobjectbuilder_p.h" -#include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From 2193f4d417d94530e7d2f1948de03372b02dcdcf Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 20 Jul 2009 12:04:21 +1000 Subject: Fix warning. --- src/declarative/qml/qmlcompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 138be29..477e6a5 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -940,7 +940,7 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, COMPILE_EXCEPTION(obj, "Invalid component id specification"); if (idProp) { - QString idVal = idProp->values.first()->primitive().toUtf8(); + QString idVal = idProp->values.first()->primitive(); if (compileState.ids.contains(idVal)) COMPILE_EXCEPTION(obj, "id is not unique"); -- cgit v0.12 From 341f47a31d6d98e402547c77ccbe358465f8b1a9 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 20 Jul 2009 12:08:39 +1000 Subject: Update in light of new Image.preserveAspect property --- examples/declarative/aspectratio/face_fit.qml | 4 ---- examples/declarative/aspectratio/face_fit_animated.qml | 4 ---- examples/declarative/aspectratio/scale_and_crop.qml | 4 ---- examples/declarative/aspectratio/scale_and_sidecrop.qml | 4 ---- examples/declarative/aspectratio/scale_to_fit.qml | 7 ++----- examples/declarative/aspectratio/scale_to_fit_simple.qml | 8 ++++++++ 6 files changed, 10 insertions(+), 21 deletions(-) create mode 100644 examples/declarative/aspectratio/scale_to_fit_simple.qml diff --git a/examples/declarative/aspectratio/face_fit.qml b/examples/declarative/aspectratio/face_fit.qml index 35c63ce..3005d1b 100644 --- a/examples/declarative/aspectratio/face_fit.qml +++ b/examples/declarative/aspectratio/face_fit.qml @@ -1,7 +1,3 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// // Here, we implement a hybrid of the "scale to fit" and "scale and crop" // behaviours which will crop up to 25% from *one* dimension if necessary // to fully scale the other. This is a realistic algorithm, for example diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml index 366d27b..9036eeb 100644 --- a/examples/declarative/aspectratio/face_fit_animated.qml +++ b/examples/declarative/aspectratio/face_fit_animated.qml @@ -1,7 +1,3 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// // Here, we extend the "face_fit" example with animation to show how truly // diverse and usage-specific behaviours are made possible by NOT putting a // hard-coded aspect ratio feature into the Image primitive. diff --git a/examples/declarative/aspectratio/scale_and_crop.qml b/examples/declarative/aspectratio/scale_and_crop.qml index a5409f9..2f35fb5 100644 --- a/examples/declarative/aspectratio/scale_and_crop.qml +++ b/examples/declarative/aspectratio/scale_and_crop.qml @@ -1,7 +1,3 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// // Here, we implement "Scale and Crop" behaviour. // Rect { diff --git a/examples/declarative/aspectratio/scale_and_sidecrop.qml b/examples/declarative/aspectratio/scale_and_sidecrop.qml index e076735..4b1eb63 100644 --- a/examples/declarative/aspectratio/scale_and_sidecrop.qml +++ b/examples/declarative/aspectratio/scale_and_sidecrop.qml @@ -1,7 +1,3 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// // Here, we implement a variant of "Scale and Crop" behaviour, where we // crop the sides if necessary to fully fit vertically, but not the reverse. // diff --git a/examples/declarative/aspectratio/scale_to_fit.qml b/examples/declarative/aspectratio/scale_to_fit.qml index 61a4082..867eb37 100644 --- a/examples/declarative/aspectratio/scale_to_fit.qml +++ b/examples/declarative/aspectratio/scale_to_fit.qml @@ -1,8 +1,5 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// -// Here, we implement "Scale to Fit" behaviour. +// Here, we implement "Scale to Fit" behaviour "manually", rather +// than using the preserveAspect property. // Rect { // default size: whole image, unscaled diff --git a/examples/declarative/aspectratio/scale_to_fit_simple.qml b/examples/declarative/aspectratio/scale_to_fit_simple.qml new file mode 100644 index 0000000..ae2be83 --- /dev/null +++ b/examples/declarative/aspectratio/scale_to_fit_simple.qml @@ -0,0 +1,8 @@ +// Here, we implement "Scale to Fit" behaviour, using the +// preserveAspect property. +// +Image { + id: Image + source: "pics/face.png" + preserveAspect: true +} -- cgit v0.12 From aff973dfb0d43c32c0686017498ea2ab03d585ae Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 20 Jul 2009 12:11:42 +1000 Subject: Make identical to non-simple example. --- .../declarative/aspectratio/scale_to_fit_simple.qml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/declarative/aspectratio/scale_to_fit_simple.qml b/examples/declarative/aspectratio/scale_to_fit_simple.qml index ae2be83..4f89586 100644 --- a/examples/declarative/aspectratio/scale_to_fit_simple.qml +++ b/examples/declarative/aspectratio/scale_to_fit_simple.qml @@ -1,8 +1,17 @@ // Here, we implement "Scale to Fit" behaviour, using the // preserveAspect property. // -Image { - id: Image - source: "pics/face.png" - preserveAspect: true +Rect { + // default size: whole image, unscaled + width: Image.width + height: Image.height + color: "gray" + clip: true + + Image { + id: Image + source: "pics/face.png" + preserveAspect: true + anchors.fill: parent + } } -- cgit v0.12 From 5f03a1502bee93523033e8769b8fc235d36d58db Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 20 Jul 2009 12:47:44 +1000 Subject: Compile fix. --- src/corelib/kernel/qmetaobjectbuilder.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index d655e3f..dd831a8 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -40,7 +40,9 @@ ****************************************************************************/ #include "qmetaobjectbuilder_p.h" +#ifndef Q_OS_WIN #include +#endif QT_BEGIN_NAMESPACE -- cgit v0.12 From 139b29f6ac99380a4f6fb47d0eca650c67757005 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Jul 2009 13:15:34 +1000 Subject: Add selection control to QFxLineEdit Should behave the same as in QFxTextEdit --- src/declarative/fx/qfxlineedit.cpp | 164 ++++++++++++++++++------------------- src/declarative/fx/qfxlineedit.h | 39 +++------ src/declarative/fx/qfxlineedit_p.h | 3 +- 3 files changed, 93 insertions(+), 113 deletions(-) diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index 24cf3fc..a95cad6 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -103,32 +103,6 @@ void QFxLineEdit::setColor(const QColor &c) d->color = c; } -/* -QFxText::TextStyle QFxLineEdit::style() const -{ - Q_D(const QFxLineEdit); - return d->style; -} - -void QFxLineEdit::setStyle(QFxText::TextStyle style) -{ - Q_D(QFxLineEdit); - d->style = style; -} - -QColor QFxLineEdit::styleColor() const -{ - Q_D(const QFxLineEdit); - return d->styleColor; -} - -void QFxLineEdit::setStyleColor(const QColor &c) -{ - Q_D(QFxLineEdit); - d->styleColor = c; -} -*/ - QFxText::HAlignment QFxLineEdit::hAlign() const { Q_D(const QFxLineEdit); @@ -141,19 +115,6 @@ void QFxLineEdit::setHAlign(QFxText::HAlignment align) d->hAlign = align; } -QFxText::VAlignment QFxLineEdit::vAlign() const -{ - Q_D(const QFxLineEdit); - return d->vAlign; -} - -void QFxLineEdit::setVAlign(QFxText::VAlignment align) -{ - Q_D(QFxLineEdit); - d->vAlign = align; -} - -//### Should this also toggle cursor visibility? bool QFxLineEdit::isReadOnly() const { Q_D(const QFxLineEdit); @@ -189,16 +150,60 @@ void QFxLineEdit::setCursorPosition(int cp) d->control->moveCursor(cp); } -int QFxLineEdit::selectionLength() const +/*! + \qmlproperty int LineEdit::selectionStart + + The cursor position before the first character in the current selection. + Setting this and selectionEnd allows you to specify a selection in the + text edit. + + Note that if selectionStart == selectionEnd then there is no current + selection. If you attempt to set selectionStart to a value outside of + the current text, selectionStart will not be changed. + + \sa selectionEnd, cursorPosition, selectedText +*/ +int QFxLineEdit::selectionStart() const +{ + Q_D(const QFxLineEdit); + return d->lastSelectionStart; +} + +void QFxLineEdit::setSelectionStart(int s) +{ + Q_D(QFxLineEdit); + if(d->lastSelectionStart == s || s < 0 || s > text().length()) + return; + d->lastSelectionStart = s; + d->control->setSelection(s, d->lastSelectionEnd - s); +} + +/*! + \qmlproperty int LineEdit::selectionEnd + + The cursor position after the last character in the current selection. + Setting this and selectionStart allows you to specify a selection in the + text edit. + + Note that if selectionStart == selectionEnd then there is no current + selection. If you attempt to set selectionEnd to a value outside of + the current text, selectionEnd will not be changed. + + \sa selectionStart, cursorPosition, selectedText +*/ +int QFxLineEdit::selectionEnd() const { Q_D(const QFxLineEdit); - return d->control->selectionEnd() - d->control->selectionStart(); + return d->lastSelectionEnd; } -void QFxLineEdit::setSelectionLength(int len) +void QFxLineEdit::setSelectionEnd(int s) { Q_D(QFxLineEdit); - d->control->setSelection(d->control->cursor(), len); + if(d->lastSelectionEnd == s || s < 0 || s > text().length()) + return; + d->lastSelectionEnd = s; + d->control->setSelection(d->lastSelectionStart, s - d->lastSelectionStart); } QString QFxLineEdit::selectedText() const @@ -403,41 +408,8 @@ void QFxLineEdit::drawContents(QPainter *p, const QRect &r) if (d->control->hasSelectedText()) flags |= QLineControl::DrawSelections; - //TODO: Clean up this cut'n'pasted section from QLineEdit - QRect lineRect(r); - - int cix = qRound(d->control->cursorToX()); - - // horizontal scrolling. d->hscroll is the left indent from the beginning - // of the text line to the left edge of lineRect. we update this value - // depending on the delta from the last paint event; in effect this means - // the below code handles all scrolling based on the textline (widthUsed, - // minLB, minRB), the line edit rect (lineRect) and the cursor position - // (cix). - QFontMetrics fm = QApplication::fontMetrics(); - int minLB = qMax(0, -fm.minLeftBearing()); - int minRB = qMax(0, -fm.minRightBearing()); - int widthUsed = d->control->width() + minRB; - if ((minLB + widthUsed) <= lineRect.width()) { - // text fits in lineRect; use hscroll for alignment - d->hscroll = 0; - d->hscroll -= minLB; - } else if (cix - d->hscroll >= lineRect.width()) { - // text doesn't fit, cursor is to the right of lineRect (scroll right) - d->hscroll = cix - lineRect.width() + 1; - } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) { - // text doesn't fit, cursor is to the left of lineRect (scroll left) - d->hscroll = cix; - } - // the y offset is there to keep the baseline constant in case we have script changes in the text. - QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent()); + d->control->draw(p, QPoint(0,0), r, flags); - if(d->hscroll != d->oldScroll) - moveCursor(); - - d->control->draw(p, topLeft, r, flags); - - d->oldScroll = d->hscroll; p->restore(); } @@ -447,13 +419,12 @@ void QFxLineEditPrivate::init() control->setCursorWidth(1); control->setPasswordCharacter(QLatin1Char('*')); control->setLayoutDirection(Qt::LeftToRight); - control->setSelection(0,0); q->setSmooth(true); q->setAcceptedMouseButtons(Qt::LeftButton); q->setOptions(QFxLineEdit::AcceptsInputMethods | QFxLineEdit::SimpleItem | QFxLineEdit::HasContents | QFxLineEdit::MouseEvents); q->connect(control, SIGNAL(cursorPositionChanged(int,int)), - q, SIGNAL(cursorPositionChanged())); + q, SLOT(cursorPosChanged())); q->connect(control, SIGNAL(selectionChanged()), q, SLOT(selectionChanged())); q->connect(control, SIGNAL(textChanged(const QString &)), @@ -471,16 +442,43 @@ void QFxLineEditPrivate::init() font = new QmlFont(); q->updateSize(); oldValidity = control->hasAcceptableInput(); - oldSelectLength = q->selectionLength(); + lastSelectionStart = 0; + lastSelectionEnd = 0; +} + +void QFxLineEdit::cursorPosChanged() +{ + Q_D(QFxLineEdit); + emit cursorPositionChanged(); + + if(!d->control->hasSelectedText()){ + if(d->lastSelectionStart != d->control->cursor()){ + d->lastSelectionStart = d->control->cursor(); + emit selectionStartChanged(); + } + if(d->lastSelectionEnd != d->control->cursor()){ + d->lastSelectionEnd = d->control->cursor(); + emit selectionEndChanged(); + } + } } void QFxLineEdit::selectionChanged() { Q_D(QFxLineEdit); emit selectedTextChanged(); - if(selectionLength() != d->oldSelectLength){ - d->oldSelectLength = selectionLength(); - emit selectionLengthChanged(); + + if(d->lastSelectionStart != d->control->selectionStart()){ + d->lastSelectionStart = d->control->selectionStart(); + if(d->lastSelectionStart == -1) + d->lastSelectionStart = d->control->cursor(); + emit selectionStartChanged(); + } + if(d->lastSelectionEnd != d->control->selectionEnd()){ + d->lastSelectionEnd = d->control->selectionEnd(); + if(d->lastSelectionEnd == -1) + d->lastSelectionEnd = d->control->cursor(); + emit selectionEndChanged(); } } diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h index e053c54..2c22d4b 100644 --- a/src/declarative/fx/qfxlineedit.h +++ b/src/declarative/fx/qfxlineedit.h @@ -62,17 +62,13 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QmlFont *font READ font) Q_PROPERTY(QColor color READ color WRITE setColor) - /* - Q_PROPERTY(QFxText::TextStyle style READ style WRITE setStyle) - Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor) Q_PROPERTY(QFxText::HAlignment hAlign READ hAlign WRITE setHAlign) - Q_PROPERTY(QFxText::VAlignment vAlign READ vAlign WRITE setVAlign) - */ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly); Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength); Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged); - Q_PROPERTY(int selectionLength READ selectionLength WRITE setSelectionLength NOTIFY selectionLengthChanged); + Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged) + Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged); Q_PROPERTY(QObject* validator READ validator WRITE setValidator); @@ -81,10 +77,6 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem Q_PROPERTY(uint echoMode READ echoMode WRITE setEchoMode); Q_PROPERTY(QmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate); - /* - Q_PROPERTY(int scrollDuration READ scrollDuration SET setScrollDuration NOTIFY scrollDurationChanged); - */ - public: QFxLineEdit(QFxItem* parent=0); ~QFxLineEdit(); @@ -100,20 +92,9 @@ public: //### Should we have this function or x variants of properties? Q_INVOKABLE int xToPos(int x); - /* - QFxText::TextStyle style() const; - void setStyle(QFxText::TextStyle style); - - QColor styleColor() const; - void setStyleColor(const QColor &c); - */ - QFxText::HAlignment hAlign() const; void setHAlign(QFxText::HAlignment align); - QFxText::VAlignment vAlign() const; - void setVAlign(QFxText::VAlignment align); - bool isReadOnly() const; void setReadOnly(bool); @@ -123,8 +104,11 @@ public: int cursorPosition() const; void setCursorPosition(int cp); - int selectionLength() const; - void setSelectionLength(int len); + int selectionStart() const; + void setSelectionStart(int); + + int selectionEnd() const; + void setSelectionEnd(int); QString selectedText() const; @@ -140,18 +124,14 @@ public: QmlComponent* cursorDelegate() const; void setCursorDelegate(QmlComponent*); - /* - int scrollDuration() const; - void setScrollDuration(int); - */ - bool hasAcceptableInput() const; void drawContents(QPainter *p,const QRect &r); Q_SIGNALS: void textChanged(); void cursorPositionChanged(); - void selectionLengthChanged(); + void selectionStartChanged(); + void selectionEndChanged(); void selectedTextChanged(); void accepted(); void acceptableInputChanged(); @@ -174,6 +154,7 @@ private slots: void updateAll(); void createCursor(); void moveCursor(); + void cursorPosChanged(); private: Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxLineEdit); diff --git a/src/declarative/fx/qfxlineedit_p.h b/src/declarative/fx/qfxlineedit_p.h index a0ab19c..a18dea7 100644 --- a/src/declarative/fx/qfxlineedit_p.h +++ b/src/declarative/fx/qfxlineedit_p.h @@ -89,7 +89,8 @@ public: QPointer cursorComponent; QPointer cursorItem; - int oldSelectLength; + int lastSelectionStart; + int lastSelectionEnd; int oldHeight; int oldWidth; bool oldValidity; -- cgit v0.12 From ecc71bebda5cdc842932f29757d869c8a1288962 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 20 Jul 2009 13:16:07 +1000 Subject: Make network cache size settable. --- tools/qmlviewer/main.cpp | 10 +++++----- tools/qmlviewer/qmlviewer.cpp | 19 ++++++++++++------- tools/qmlviewer/qmlviewer.h | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index ae9c356..e786edb 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -36,7 +36,7 @@ void usage() qWarning(" -record arg .............................. add a recording process argument"); qWarning(" -autorecord [from-] ...... set recording to start and stop"); qWarning(" -devicekeys .............................. use numeric keys (see F1)"); - qWarning(" -cache ................................... disk cache remote content"); + qWarning(" -netcache ......................... set disk cache to size bytes"); qWarning(" -recordtest .................. record an autotest"); qWarning(" -runtest ..................... run a previously recorded test"); qWarning(" -translation ........... set the language to run in"); @@ -74,7 +74,7 @@ int main(int argc, char ** argv) QStringList libraries; QString skin; bool devkeys = false; - bool cache = false; + int cache = 0; QString translationFile; for (int i = 1; i < argc; ++i) { @@ -83,8 +83,8 @@ int main(int argc, char ** argv) frameless = true; } else if (arg == "-skin") { skin = QString(argv[++i]); - } else if (arg == "-cache") { - cache = true; + } else if (arg == "-netcache") { + cache = QString(argv[++i]).toInt(); } else if (arg == "-recordperiod") { period = QString(argv[++i]).toInt(); } else if (arg == "-recordfile") { @@ -127,7 +127,7 @@ int main(int argc, char ** argv) QmlViewer viewer(0, frameless ? Qt::FramelessWindowHint : Qt::Widget); foreach (QString lib, libraries) viewer.addLibraryPath(lib); - viewer.setCacheEnabled(cache); + viewer.setNetworkCacheSize(cache); viewer.setRecordFile(recordfile); if (period>0) viewer.setRecordPeriod(period); diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index c9d70e8..8f99206 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -699,17 +699,22 @@ void QmlViewer::setupProxy() nam->setProxyFactory(new SystemProxyFactory); } -void QmlViewer::setCacheEnabled(bool on) +void QmlViewer::setNetworkCacheSize(int size) { QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); - if (on == !!nam->cache()) - return; - if (on) { - // Setup a caching network manager - QNetworkDiskCache *cache = new QNetworkDiskCache; + QNetworkDiskCache *cache = qobject_cast(nam->cache()); + if (!cache) { + if (size==0) + return; + cache = new QNetworkDiskCache; cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache")); - cache->setMaximumCacheSize(8000000); nam->setCache(cache); + } + if (size == cache->maximumCacheSize()) + return; + if (size>0) { + // Setup a caching network manager + cache->setMaximumCacheSize(size); } else { nam->setCache(0); } diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 4714bdc..62ee908 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -42,7 +42,7 @@ public: bool isRecording() const { return recordTimer.isActive(); } void setAutoRecord(int from, int to); void setDeviceKeys(bool); - void setCacheEnabled(bool); + void setNetworkCacheSize(int size); void addLibraryPath(const QString& lib); QMenuBar *menuBar() const; -- cgit v0.12 From 7b1484e05a28c20a993efe0c2ec42ae25cbff13f Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Jul 2009 13:20:27 +1000 Subject: Emit selectionChange when setSelection is called --- src/gui/widgets/qlinecontrol.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 97f4a45..eec890b 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -244,14 +244,19 @@ void QLineControl::setSelection(int start, int length) } if (length > 0) { + if (start == m_selstart && start + length == m_selend) + return; m_selstart = start; m_selend = qMin(start + length, (int)m_text.length()); m_cursor = m_selend; } else { + if (start == m_selend && start + length == m_selstart) + return; m_selstart = qMax(start + length, 0); m_selend = start; m_cursor = m_selstart; } + emit selectionChanged(); } void QLineControl::_q_clipboardChanged() -- cgit v0.12 From 2d0e618db203d47bfe5bda50e9cf258a19e9745c Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 20 Jul 2009 13:56:48 +1000 Subject: Add an inSync property that holds whether the target has "caught up" Useful for determining when the target has finished animating. --- examples/declarative/follow/follow.qml | 17 +++++++++++++++-- examples/declarative/snow/snow.qml | 9 +++++---- src/declarative/util/qmlfollow.cpp | 29 ++++++++++++++++++++++++----- src/declarative/util/qmlfollow.h | 3 +++ 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/examples/declarative/follow/follow.qml b/examples/declarative/follow/follow.qml index 21a0309..37a953c 100644 --- a/examples/declarative/follow/follow.qml +++ b/examples/declarative/follow/follow.qml @@ -40,11 +40,24 @@ Rect { id: Mouse anchors.fill: parent Rect { + id: "Ball" width: 20; height: 20 radius: 10 color: "#0000ff" - x: Follow { source: Mouse.mouseX-10; spring: 1.0; damping: 0.05 } - y: Follow { source: Mouse.mouseY-10; spring: 1.0; damping: 0.05 } + x: Follow { id: "F1"; source: Mouse.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } + y: Follow { id: "F2"; source: Mouse.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } + states: [ + State { + name: "following" + when: !F1.inSync || !F2.inSync + SetProperties { target: Ball; color: "#ff0000" } + } + ] + transitions: [ + Transition { + ColorAnimation { duration: 200 } + } + ] } } } diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml index 2b413bb..f65e0ac 100644 --- a/examples/declarative/snow/snow.qml +++ b/examples/declarative/snow/snow.qml @@ -27,11 +27,12 @@ Rect { property real targetDeform: 0 property bool slowDeform: true - property real deform - deform: Follow { source: MyLayout.targetDeform; velocity: MyLayout.slowDeform?0.1:2 } + property real deform: 0 + deform: Follow { + id: "DeformFollow"; source: MyLayout.targetDeform; velocity: MyLayout.slowDeform?0.1:2 + onSyncChanged: if(inSync) { MyLayout.slowDeform = true; MyLayout.targetDeform = 0; } + } - onDeformChanged: if(deform == targetDeform) { slowDeform = true; targetDeform = 0; } - ImageBatch { offset: 0; ref: ImagePanel } x: Follow { source: MyLayout.targetX; velocity: 1000 } diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index b8e6685..851d4c2 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -56,7 +56,7 @@ class QmlFollowPrivate : public QObjectPrivate public: QmlFollowPrivate() : sourceValue(0), maxVelocity(0), lastTime(0) - , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.005), modulus(0.0), enabled(true), mode(Track), clock(this) {} + , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01), modulus(0.0), enabled(true), mode(Track), clock(this) {} QmlMetaProperty property; qreal currentValue; @@ -164,8 +164,10 @@ void QmlFollowPrivate::tick(int time) } lastTime = time; } - emit q->valueChanged(currentValue); property.write(currentValue); + emit q->valueChanged(currentValue); + if (clock.state() != QAbstractAnimation::Running) + emit q->syncChanged(); } void QmlFollowPrivate::updateMode() @@ -183,12 +185,14 @@ void QmlFollowPrivate::start() if (!enabled) return; + Q_Q(QmlFollow); if (mode == QmlFollowPrivate::Track) { currentValue = sourceValue; property.write(currentValue); } else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) { lastTime = 0; clock.start(); // infinity?? + emit q->syncChanged(); } } @@ -261,8 +265,10 @@ qreal QmlFollow::sourceValue() const void QmlFollow::setSourceValue(qreal value) { Q_D(QmlFollow); - d->sourceValue = value; - d->start(); + if (d->sourceValue != value) { + d->sourceValue = value; + d->start(); + } } /*! @@ -338,7 +344,7 @@ void QmlFollow::setDamping(qreal damping) to 0 to be considered equal to zero. This will depend on the usage of the value. For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice. - The default is 0.005. Small performance improvements can result in tuning this + The default is 0.01. Small performance improvements can result in tuning this value. */ qreal QmlFollow::epsilon() const @@ -397,6 +403,19 @@ void QmlFollow::setEnabled(bool enabled) d->stop(); } +/*! + \qmlproperty bool Follow::inSync + This property is true when target is equal to the source; otherwise + false. If inSync is true the target is not being animated. + + If \l enabled is false then inSync will also be false. +*/ +bool QmlFollow::inSync() const +{ + Q_D(const QmlFollow); + return d->enabled && d->clock.state() != QAbstractAnimation::Running; +} + qreal QmlFollow::value() const { Q_D(const QmlFollow); diff --git a/src/declarative/util/qmlfollow.h b/src/declarative/util/qmlfollow.h index 07e15e9..e0a588b 100644 --- a/src/declarative/util/qmlfollow.h +++ b/src/declarative/util/qmlfollow.h @@ -68,6 +68,7 @@ class Q_DECLARATIVE_EXPORT QmlFollow : public QmlPropertyValueSource, Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) Q_PROPERTY(qreal followValue READ value NOTIFY valueChanged) Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged) + Q_PROPERTY(bool inSync READ inSync NOTIFY syncChanged) public: QmlFollow(QObject *parent=0); @@ -89,11 +90,13 @@ public: void setModulus(qreal modulus); bool enabled() const; void setEnabled(bool enabled); + bool inSync() const; qreal value() const; Q_SIGNALS: void valueChanged(qreal); + void syncChanged(); }; QT_END_NAMESPACE -- cgit v0.12 From c8b42c5851377c075c2c4147a625f23f2f6f6173 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Jul 2009 14:34:26 +1000 Subject: Use the images from Same Gnome as our second theme. Also stopped switching background as part of the theme, partly because SameGnome doesn't have a background image and partly because it wasn't working right anyway. --- demos/declarative/samegame/README | 2 ++ demos/declarative/samegame/TODO | 5 ++- demos/declarative/samegame/content/FastBlock.qml | 4 +-- demos/declarative/samegame/content/SpinBlock.qml | 34 +++++++++++++++++++++ .../samegame/content/pics/gnome/blueStone.gif | Bin 0 -> 19122 bytes .../samegame/content/pics/gnome/greenStone.gif | Bin 0 -> 20545 bytes .../samegame/content/pics/gnome/redStone.gif | Bin 0 -> 18455 bytes demos/declarative/samegame/content/samegame.js | 9 ++---- 8 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 demos/declarative/samegame/content/SpinBlock.qml create mode 100644 demos/declarative/samegame/content/pics/gnome/blueStone.gif create mode 100644 demos/declarative/samegame/content/pics/gnome/greenStone.gif create mode 100644 demos/declarative/samegame/content/pics/gnome/redStone.gif diff --git a/demos/declarative/samegame/README b/demos/declarative/samegame/README index 244b205..2f2a728 100644 --- a/demos/declarative/samegame/README +++ b/demos/declarative/samegame/README @@ -8,3 +8,5 @@ greenStone.png yellowStone.png and are presumably under the same GPL2 license as the rest of kdegames + +The images in the pics/gnome folder are from the gnome games project, and are also GPL2 licensed. diff --git a/demos/declarative/samegame/TODO b/demos/declarative/samegame/TODO index bbe881f..3be2a3a 100644 --- a/demos/declarative/samegame/TODO +++ b/demos/declarative/samegame/TODO @@ -1,3 +1,2 @@ -Still to do before initial release --Garbage collect after click --Second *good* theme +Still to do: + diff --git a/demos/declarative/samegame/content/FastBlock.qml b/demos/declarative/samegame/content/FastBlock.qml index c3e8829..6e02ced 100644 --- a/demos/declarative/samegame/content/FastBlock.qml +++ b/demos/declarative/samegame/content/FastBlock.qml @@ -12,8 +12,8 @@ Rect { id:block opacity: 0 y: targetY x: targetX - y: Behavior { NumberAnimation { properties:"y"; duration: 200 } } - opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } + //y: Behavior { NumberAnimation { properties:"y"; duration: 200 } } + //opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } states: [ diff --git a/demos/declarative/samegame/content/SpinBlock.qml b/demos/declarative/samegame/content/SpinBlock.qml new file mode 100644 index 0000000..6737196 --- /dev/null +++ b/demos/declarative/samegame/content/SpinBlock.qml @@ -0,0 +1,34 @@ +Item { id:block + //Note: These properties are the interface used to control the blocks + property bool dying: false + property bool spawned: false + property int type: 0 + property int targetY: 0 + property int targetX: 0 + + AnimatedImage { + source: if(type == 0) { + "pics/gnome/redStone.gif"; + } else if (type == 1) { + "pics/gnome/blueStone.gif"; + } else { + "pics/gnome/greenStone.gif"; + } + } + opacity: 0 + y: targetY + x: targetX + y: Behavior { NumberAnimation { properties:"y"; duration: 200 } } + x: Behavior { NumberAnimation { properties:"x"; duration: 200 } } + opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } + + states: [ + + State{ name: "AliveState"; when: spawned == true && dying == false + SetProperties { target: block; opacity: 1 } + }, + State{ name: "DeathState"; when: dying == true + SetProperties { target: block; opacity: 0 } + } + ] +} diff --git a/demos/declarative/samegame/content/pics/gnome/blueStone.gif b/demos/declarative/samegame/content/pics/gnome/blueStone.gif new file mode 100644 index 0000000..4e6bd35 Binary files /dev/null and b/demos/declarative/samegame/content/pics/gnome/blueStone.gif differ diff --git a/demos/declarative/samegame/content/pics/gnome/greenStone.gif b/demos/declarative/samegame/content/pics/gnome/greenStone.gif new file mode 100644 index 0000000..c572e80 Binary files /dev/null and b/demos/declarative/samegame/content/pics/gnome/greenStone.gif differ diff --git a/demos/declarative/samegame/content/pics/gnome/redStone.gif b/demos/declarative/samegame/content/pics/gnome/redStone.gif new file mode 100644 index 0000000..c6c10c5 Binary files /dev/null and b/demos/declarative/samegame/content/pics/gnome/redStone.gif differ diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index d2a3cbc..925a5b8 100644 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -6,7 +6,6 @@ var tileSize = 40; var maxIndex = maxX*maxY; var board = new Array(maxIndex); var tileSrc = "content/BoomBlock.qml"; -var backSrc = "content/pics/background.png"; var swapped = false; var compSrc; @@ -15,12 +14,10 @@ var component; function swapTileSrc(){ if(swapped) return; - if(tileSrc == "content/FastBlock.qml"){ + if(tileSrc == "content/SpinBlock.qml"){ tileSrc = "content/BoomBlock.qml"; - backSrc = "content/pics/background.png"; }else{ - backSrc = "content/pics/qtlogo.png"; - tileSrc = "content/FastBlock.qml"; + tileSrc = "content/SpinBlock.qml"; } swapped = true; } @@ -37,8 +34,6 @@ function initBoard() board[i].destroy(); } - background.source = backSrc; - swapped = false; maxX = Math.floor(gameCanvas.width/tileSize); maxY = Math.floor(gameCanvas.height/tileSize); maxIndex = maxX*maxY; -- cgit v0.12 From 2e4684e1004c3e5be16fb4ef21d8b2400063b241 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Jul 2009 15:01:32 +1000 Subject: Bug fixes for SameGame demo pngs are now 40x40, swapping between themes works again. --- demos/declarative/samegame/content/pics/blueStone.png | Bin 4823 -> 2691 bytes .../declarative/samegame/content/pics/greenStone.png | Bin 4724 -> 2662 bytes demos/declarative/samegame/content/pics/redStone.png | Bin 4585 -> 2604 bytes .../declarative/samegame/content/pics/yellowStone.png | Bin 4818 -> 2667 bytes demos/declarative/samegame/content/samegame.js | 3 --- 5 files changed, 3 deletions(-) diff --git a/demos/declarative/samegame/content/pics/blueStone.png b/demos/declarative/samegame/content/pics/blueStone.png index 673f1ce..bf342e0 100644 Binary files a/demos/declarative/samegame/content/pics/blueStone.png and b/demos/declarative/samegame/content/pics/blueStone.png differ diff --git a/demos/declarative/samegame/content/pics/greenStone.png b/demos/declarative/samegame/content/pics/greenStone.png index 0c087d0..5ac14a5 100644 Binary files a/demos/declarative/samegame/content/pics/greenStone.png and b/demos/declarative/samegame/content/pics/greenStone.png differ diff --git a/demos/declarative/samegame/content/pics/redStone.png b/demos/declarative/samegame/content/pics/redStone.png index 80c2e2e..b099f60 100644 Binary files a/demos/declarative/samegame/content/pics/redStone.png and b/demos/declarative/samegame/content/pics/redStone.png differ diff --git a/demos/declarative/samegame/content/pics/yellowStone.png b/demos/declarative/samegame/content/pics/yellowStone.png index 5349eff..c56124a 100644 Binary files a/demos/declarative/samegame/content/pics/yellowStone.png and b/demos/declarative/samegame/content/pics/yellowStone.png differ diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 925a5b8..1f76b9f 100644 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -12,14 +12,11 @@ var compSrc; var component; function swapTileSrc(){ - if(swapped) - return; if(tileSrc == "content/SpinBlock.qml"){ tileSrc = "content/BoomBlock.qml"; }else{ tileSrc = "content/SpinBlock.qml"; } - swapped = true; } function index(xIdx,yIdx){ -- cgit v0.12 From c0493bf1dab7bd5675e9c6a7429f595bed6f9558 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Jul 2009 16:08:05 +1000 Subject: Fix bug in AnimatedImage where it wouldn't show until played --- src/declarative/extra/qfxanimatedimageitem.cpp | 12 +++++++++--- src/declarative/extra/qfxanimatedimageitem_p.h | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp index d22959a..7e44abf 100644 --- a/src/declarative/extra/qfxanimatedimageitem.cpp +++ b/src/declarative/extra/qfxanimatedimageitem.cpp @@ -112,6 +112,9 @@ bool QFxAnimatedImageItem::isPlaying() const void QFxAnimatedImageItem::setPlaying(bool play) { Q_D(QFxAnimatedImageItem); + if(play == d->playing) + return; + d->playing = play; if (!d->_movie) return; if (play) @@ -166,7 +169,7 @@ void QFxAnimatedImageItem::setSource(const QUrl &url) d->reply = 0; } - d->url = url; + d->url = qmlContext(this)->resolvedUrl(url); if (url.isEmpty()) { delete d->_movie; @@ -188,7 +191,7 @@ void QFxAnimatedImageItem::movieRequestFinished() Q_D(QFxAnimatedImageItem); d->_movie = new QMovie(d->reply); if (!d->_movie->isValid()){ - qWarning() << "Error Reading File " << d->url; + qWarning() << "Error Reading Animated Image File " << d->url; delete d->_movie; d->_movie = 0; return; @@ -198,7 +201,10 @@ void QFxAnimatedImageItem::movieRequestFinished() connect(d->_movie, SIGNAL(frameChanged(int)), this, SLOT(movieUpdate())); d->_movie->setCacheMode(QMovie::CacheAll); - d->_movie->start(); + if(d->playing) + d->_movie->start(); + else + d->_movie->jumpToFrame(0); setPixmap(d->_movie->currentPixmap()); } diff --git a/src/declarative/extra/qfxanimatedimageitem_p.h b/src/declarative/extra/qfxanimatedimageitem_p.h index e7d8fb8..d743ba4 100644 --- a/src/declarative/extra/qfxanimatedimageitem_p.h +++ b/src/declarative/extra/qfxanimatedimageitem_p.h @@ -65,10 +65,11 @@ class QFxAnimatedImageItemPrivate : public QFxImagePrivate public: QFxAnimatedImageItemPrivate() - : _movie(0) + : playing(true), _movie(0) { } + bool playing; QMovie *_movie; }; -- cgit v0.12 From 91178b5826c40ad7ecdd70692d0c6128a1743dc9 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Jul 2009 16:14:29 +1000 Subject: Pause instead of stop when playing == false. --- src/declarative/extra/qfxanimatedimageitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp index 7e44abf..5516a00 100644 --- a/src/declarative/extra/qfxanimatedimageitem.cpp +++ b/src/declarative/extra/qfxanimatedimageitem.cpp @@ -120,7 +120,7 @@ void QFxAnimatedImageItem::setPlaying(bool play) if (play) d->_movie->start(); else - d->_movie->stop(); + d->_movie->setPaused(true); } /*! -- cgit v0.12 From ebcec1a247c4cb67537131c0d801780f4987a810 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Jul 2009 16:25:53 +1000 Subject: Update Gnome theme to only spin on mouse over, like same-gnome Note that currently we can only get mouse move signals if a button is pressed. --- demos/declarative/samegame/SameGame.qml | 1 + demos/declarative/samegame/content/BoomBlock.qml | 1 + demos/declarative/samegame/content/FastBlock.qml | 1 + demos/declarative/samegame/content/SpinBlock.qml | 2 + .../samegame/content/pics/gnome/blueStone.gif | Bin 19122 -> 19122 bytes .../samegame/content/pics/gnome/greenStone.gif | Bin 20545 -> 20545 bytes .../samegame/content/pics/gnome/redStone.gif | Bin 18455 -> 18455 bytes demos/declarative/samegame/content/samegame.js | 75 ++++++++++++++------- 8 files changed, 56 insertions(+), 24 deletions(-) diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index fd3ca88..5e998e8 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -22,6 +22,7 @@ Rect { MouseRegion { id: gameMR; anchors.fill: parent; onClicked: handleClick(mouseX, mouseY); + onPositionChanged: handleHover(mouseX, mouseY); } } HorizontalLayout { diff --git a/demos/declarative/samegame/content/BoomBlock.qml b/demos/declarative/samegame/content/BoomBlock.qml index 542e7bc..9148e60 100644 --- a/demos/declarative/samegame/content/BoomBlock.qml +++ b/demos/declarative/samegame/content/BoomBlock.qml @@ -1,6 +1,7 @@ Item { id:block property bool dying: false property bool spawned: false + property bool selected: false property int type: 0 property int targetX: 0 property int targetY: 0 diff --git a/demos/declarative/samegame/content/FastBlock.qml b/demos/declarative/samegame/content/FastBlock.qml index 6e02ced..5149911 100644 --- a/demos/declarative/samegame/content/FastBlock.qml +++ b/demos/declarative/samegame/content/FastBlock.qml @@ -2,6 +2,7 @@ Rect { id:block //Note: These properties are the interface used to control the blocks property bool dying: false property bool spawned: false + property bool selected: false property int type: 0 property int targetY: 0 property int targetX: 0 diff --git a/demos/declarative/samegame/content/SpinBlock.qml b/demos/declarative/samegame/content/SpinBlock.qml index 6737196..42276d0 100644 --- a/demos/declarative/samegame/content/SpinBlock.qml +++ b/demos/declarative/samegame/content/SpinBlock.qml @@ -2,6 +2,7 @@ Item { id:block //Note: These properties are the interface used to control the blocks property bool dying: false property bool spawned: false + property bool selected: false property int type: 0 property int targetY: 0 property int targetX: 0 @@ -14,6 +15,7 @@ Item { id:block } else { "pics/gnome/greenStone.gif"; } + playing: selected } opacity: 0 y: targetY diff --git a/demos/declarative/samegame/content/pics/gnome/blueStone.gif b/demos/declarative/samegame/content/pics/gnome/blueStone.gif index 4e6bd35..333efbe 100644 Binary files a/demos/declarative/samegame/content/pics/gnome/blueStone.gif and b/demos/declarative/samegame/content/pics/gnome/blueStone.gif differ diff --git a/demos/declarative/samegame/content/pics/gnome/greenStone.gif b/demos/declarative/samegame/content/pics/gnome/greenStone.gif index c572e80..1bc5bf4 100644 Binary files a/demos/declarative/samegame/content/pics/gnome/greenStone.gif and b/demos/declarative/samegame/content/pics/gnome/greenStone.gif differ diff --git a/demos/declarative/samegame/content/pics/gnome/redStone.gif b/demos/declarative/samegame/content/pics/gnome/redStone.gif index c6c10c5..b80f901 100644 Binary files a/demos/declarative/samegame/content/pics/gnome/redStone.gif and b/demos/declarative/samegame/content/pics/gnome/redStone.gif differ diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 1f76b9f..1814031 100644 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -46,55 +46,82 @@ function initBoard() //TODO: a flag that handleMouse uses to ignore clicks when we're loading } -var removed; +var fillFound; var floodBoard; + +var lastHoveredIdx = -1 +function handleHover(x,y, btn) +{ + xIdx = Math.floor(x/tileSize); + yIdx = Math.floor(y/tileSize); + if(index(xIdx, yIdx) == lastHoveredIdx) + return; + lastHoveredIdx = index(xIdx, yIdx); + //if(btn != 0) + // return; + floodFill(xIdx, yIdx, -1, "hover"); + for(i=0; i= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) return; if(board[index(xIdx, yIdx)] == null) return; - removed = 0; - floodBoard = new Array(maxIndex); - floodKill(xIdx,yIdx, -1); - if(removed <= 0) + floodFill(xIdx,yIdx, -1, "kill"); + if(fillFound <= 0) return; - gameCanvas.score += (removed - 1) * (removed - 1); + gameCanvas.score += (fillFound - 1) * (fillFound - 1); shuffleDown(); victoryCheck(); } -function floodKill(xIdx,yIdx,type) +//cmd = "kill" is the removal case, cmd = "hover" is the mouse overed case +function floodFill(xIdx,yIdx,type, cmd) { - if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) - return; - if(floodBoard[index(xIdx, yIdx)] == 1) - return; if(board[index(xIdx, yIdx)] == null) return; var first = false; if(type == -1){ - type = board[index(xIdx,yIdx)].type; first = true; - }else{ - if(type != board[index(xIdx,yIdx)].type) - return; + type = board[index(xIdx,yIdx)].type; + + //Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); } + if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) + return; + if(floodBoard[index(xIdx, yIdx)] == 1) + return; + if(!first && type != board[index(xIdx,yIdx)].type) + return; floodBoard[index(xIdx, yIdx)] = 1; - floodKill(xIdx+1,yIdx,type); - floodKill(xIdx-1,yIdx,type); - floodKill(xIdx,yIdx+1,type); - floodKill(xIdx,yIdx-1,type); - if(first==true && removed == 0){ + floodFill(xIdx+1,yIdx,type,cmd); + floodFill(xIdx-1,yIdx,type,cmd); + floodFill(xIdx,yIdx+1,type,cmd); + floodFill(xIdx,yIdx-1,type,cmd); + if(first==true && fillFound == 0){ //TODO: Provide a way to inform the delegate return;//Can't remove single tiles } - board[index(xIdx,yIdx)].dying = true; - board[index(xIdx,yIdx)] = null;//They'll have to destroy themselves(can we do that?) - removed += 1; + if(cmd == "kill"){ + board[index(xIdx,yIdx)].dying = true; + board[index(xIdx,yIdx)] = null;//They'll have to destroy themselves(can we do that?) + }else if(cmd == "hover"){ + board[index(xIdx,yIdx)].selected = true; + }else{ + print ("Flood Error"); + } + fillFound += 1; } function shuffleDown() -- cgit v0.12