diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-09-23 01:00:38 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-09-23 01:00:38 (GMT) |
commit | 4594ccff8ee55a5bbc640f764e0767da885a3c9f (patch) | |
tree | 353d2f94919a2c59ad06110effb46eb8a962baac /demos | |
parent | 1c011c7f70791e0a4a38bd9f8bb1988cd604305c (diff) | |
parent | 30379e098ef31a8a1f670bdeab212ed419e80b5b (diff) | |
download | Qt-4594ccff8ee55a5bbc640f764e0767da885a3c9f.zip Qt-4594ccff8ee55a5bbc640f764e0767da885a3c9f.tar.gz Qt-4594ccff8ee55a5bbc640f764e0767da885a3c9f.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'demos')
-rw-r--r-- | demos/declarative/minehunt/main.cpp | 6 | ||||
-rwxr-xr-x | demos/declarative/samegame/content/samegame.js | 49 |
2 files changed, 15 insertions, 40 deletions
diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp index 20f7492..a9b8828 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/main.cpp @@ -2,7 +2,7 @@ #include "qmlcontext.h" #include "qml.h" #include <qfxitem.h> -#include <qfxview.h> +#include <qmlview.h> #include <QWidget> #include <QApplication> @@ -94,7 +94,7 @@ private: int getHint(int row, int col); void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} - QFxView *canvas; + QmlView *canvas; QList<Tile *> _tiles; int numCols; @@ -123,7 +123,7 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags vbox->setMargin(0); setLayout(vbox); - canvas = new QFxView(this); + canvas = new QmlView(this); canvas->setFixedSize(width, height); vbox->addWidget(canvas); diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 0a3a4db..e42b7cc 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -44,7 +44,7 @@ function initBoard() for(xIdx=0; xIdx<maxX; xIdx++){ for(yIdx=0; yIdx<maxY; yIdx++){ board[index(xIdx,yIdx)] = null; - startCreatingBlock(xIdx,yIdx); + createBlock(xIdx,yIdx); } } timer = new Date(); @@ -170,22 +170,15 @@ function floodMoveCheck(xIdx, yIdx, type) floodMoveCheck(xIdx, yIdx - 1, board[index(xIdx,yIdx)].type); } -//If the component isn't ready, then the signal doesn't include the game x,y -//So we store any x,y sent that we couldn't create at the time, and use those -//if we are triggered by the signal. -var waitStack = new Array(maxIndex); -var waitTop = -1; +function createBlock(xIdx,yIdx){ + if(component==null) + component = createComponent(tileSrc); -function finishCreatingBlock(xIdx,yIdx){ + // Note that we don't wait for the component to become ready. This will + // only work if the block QML is a local file. Otherwise the component will + // not be ready immediately. There is a statusChanged signal on the + // component you could use if you want to wait to load remote files. if(component.isReady){ - if(xIdx == undefined){ - //Called without arguments, create a previously stored (xIdx,yIdx) - if(waitTop == -1) - return;//Don't have a previously stored (xIdx,yIdx) - xIdx = waitStack[waitTop] % maxX; - yIdx = Math.floor(waitStack[waitTop] / maxX); - waitTop -= 1; - } dynamicObject = component.createObject(); if(dynamicObject == null){ print("error creating block"); @@ -201,30 +194,12 @@ function finishCreatingBlock(xIdx,yIdx){ dynamicObject.height = tileSize; dynamicObject.spawned = true; board[index(xIdx,yIdx)] = dynamicObject; - return true; - }else if(component.isError){ - print("error creating block"); + }else{//isError or isLoading + print("error loading block component"); print(component.errorsString()); - }else{ - //It isn't ready, but we'll be called again when it is. - //So store the requested (xIdx,yIdx) for later use - waitTop += 1; - waitStack[waitTop] = index(xIdx,yIdx); - } - return false; -} - -function startCreatingBlock(xIdx,yIdx){ - if(component!=null){ - finishCreatingBlock(xIdx,yIdx); - return; + return false; } - - component = createComponent(tileSrc); - if(finishCreatingBlock(xIdx,yIdx)) - return; - component.statusChanged.connect(finishCreatingBlock()); - return; + return true; } function sendHighScore(name) { |