From bb7a6e90375f4f546d1d5dc899e972d9389c2936 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 16 Dec 2009 14:51:33 +0100 Subject: Fix bug in positioners where changes were not being watched Task-number: QT-2638 --- .../graphicsitems/qmlgraphicspositioners.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp index b96b8b8..9f6baae 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp @@ -173,8 +173,20 @@ void QmlGraphicsBasePositioner::componentComplete() QVariant QmlGraphicsBasePositioner::itemChange(GraphicsItemChange change, const QVariant &value) { - if (change == ItemChildAddedChange || - change == ItemChildRemovedChange) { + Q_D(QmlGraphicsBasePositioner); + if (change == ItemChildAddedChange){ + QmlGraphicsItem* child = value.value(); + if(!child) + return QVariant(); + if(!d->watched.contains(child)) + d->watchChanges(child); + prePositioning(); + }else if (change == ItemChildRemovedChange) { + QmlGraphicsItem* child = value.value(); + if(!child) + return QVariant(); + if(d->watched.contains(child)) + d->unwatchChanges(child); prePositioning(); } @@ -212,10 +224,8 @@ void QmlGraphicsBasePositioner::prePositioning() //Assumed that (aside from init) every add/remove triggers this check //thus the above check will be triggered every time an item is removed QSet deletedItems = d->items - positionedItems.toSet(); - foreach(QmlGraphicsItem *child, deletedItems){ - d->unwatchChanges(child); + foreach(QmlGraphicsItem *child, deletedItems) d->items -= child; - } } doPositioning(); if(d->addTransition || d->moveTransition) -- cgit v0.12 From 7f9bfd5dae0aa55a9425908995ba9249b7921ad4 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 16 Dec 2009 15:41:27 +0100 Subject: Set score text color (so that it will be visible) --- demos/declarative/samegame/content/samegame.js | 2 +- demos/declarative/samegame/samegame.qml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 8651c84..0a42e88 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -56,7 +56,7 @@ function initBoard() } timer = new Date(); - print(timer.valueOf() - a.valueOf()); + //print(timer.valueOf() - a.valueOf()); } var fillFound;//Set after a floodFill call to the number of tiles found diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 19b929f..72ea564 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -72,6 +72,7 @@ Rectangle { text: "Score: " + gameCanvas.score; font.bold: true anchors.right: parent.right; anchors.rightMargin: 3 anchors.verticalCenter: parent.verticalCenter + color: activePalette.text } } } -- cgit v0.12 From 3dbe316e92204963765d74665d4f33f56d3c1730 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 16 Dec 2009 15:48:49 +0100 Subject: Add a quit button to the toolbar Allows to run SameGame full-screen on the N900, and being able to quit without having to use xkill :) --- demos/declarative/samegame/samegame.qml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 72ea564..d40d644 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -67,6 +67,12 @@ Rectangle { anchors.verticalCenter: parent.verticalCenter } + Button { + id: btnB; text: "Quit"; onClicked: {Qt.quit();} + anchors.left: btnA.right; anchors.leftMargin: 3 + anchors.verticalCenter: parent.verticalCenter + } + Text { id: score text: "Score: " + gameCanvas.score; font.bold: true -- cgit v0.12