diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-07-17 01:09:10 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-07-17 01:09:10 (GMT) |
commit | 98468a7d49735b30697b8364a40338ed5838222f (patch) | |
tree | 098a411c2edba6896a630bf9f6b65b31b0f5e0f8 | |
parent | 3abcfa0872138edb00c0c82dd77bbf175462f5b4 (diff) | |
download | Qt-98468a7d49735b30697b8364a40338ed5838222f.zip Qt-98468a7d49735b30697b8364a40338ed5838222f.tar.gz Qt-98468a7d49735b30697b8364a40338ed5838222f.tar.bz2 |
Compile, tidy up code.
-rw-r--r-- | examples/declarative/minehunt/Description.qml | 4 | ||||
-rw-r--r-- | examples/declarative/minehunt/main.cpp | 4 | ||||
-rw-r--r-- | examples/declarative/minehunt/minehunt.qml | 34 |
3 files changed, 29 insertions, 13 deletions
diff --git a/examples/declarative/minehunt/Description.qml b/examples/declarative/minehunt/Description.qml index 0241ae5..ea71d85 100644 --- a/examples/declarative/minehunt/Description.qml +++ b/examples/declarative/minehunt/Description.qml @@ -29,8 +29,4 @@ Item { wrap: true } } - filter: Shadow { - xOffset: 5 - yOffset: 5 - } } diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp index 7f10757..d8e60cc 100644 --- a/examples/declarative/minehunt/main.cpp +++ b/examples/declarative/minehunt/main.cpp @@ -62,7 +62,7 @@ public: MyWidget(int = 370, int = 480, QWidget *parent=0, Qt::WindowFlags flags=0); ~MyWidget(); - Q_PROPERTY(QList<Tile *> *tiles READ tiles); + Q_PROPERTY(QList<Tile *> *tiles READ tiles CONSTANT); QList<Tile *> *tiles() { return &_tiles; } Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged); @@ -134,9 +134,7 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags canvas->setQml(qml, fileName); QmlContext *ctxt = canvas->rootContext(); - ctxt->activate(); ctxt->addDefaultObject(this); - ctxt->deactivate(); canvas->execute(); } diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index 03fcc8d..286e485 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -46,7 +46,7 @@ Item { text: modelData.hint color: "white" font.bold: true - opacity: modelData.hasMine == false && modelData.hint > 0 + opacity: !modelData.hasMine && modelData.hint > 0 } Image { anchors.horizontalCenter: parent.horizontalCenter @@ -57,13 +57,13 @@ Item { Explosion { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - explode: modelData.hasMine==true && modelData.flipped==true + explode: modelData.hasMine && modelData.flipped } } states: [ State { name: "back" - when: modelData.flipped == true + when: modelData.flipped SetProperties { target: flipable; rotation: 180 } } ] @@ -71,7 +71,19 @@ Item { Transition { SequentialAnimation { PauseAnimation { - duration: {var ret = Math.abs(flipable.parent.x-field.clickx) + Math.abs(flipable.parent.y-field.clicky); if (ret > 0) {if(modelData.hasMine==true && modelData.flipped==true){ret*3;}else{ret;}} else {0}} + duration: { + var ret = Math.abs(flipable.parent.x-field.clickx) + + Math.abs(flipable.parent.y-field.clicky); + if (ret > 0) { + if (modelData.hasMine && modelData.flipped) { + ret*3 + } else { + ret + } + } else { + 0 + } + } } NumberAnimation { easing: "easeInOutQuad" @@ -82,7 +94,17 @@ Item { ] MouseRegion { anchors.fill: parent - onClicked: { field.clickx = flipable.parent.x; field.clicky = flipable.parent.y; row = Math.floor(index/9); col = index - (Math.floor(index/9) * 9); if(mouse.button==undefined || mouse.button==Qt.RightButton){flag(row,col);}else{flip(row,col);} } + onClicked: { + field.clickx = flipable.parent.x; + field.clicky = flipable.parent.y; + row = Math.floor(index/9); + col = index - (Math.floor(index/9) * 9); + if (mouse.button==undefined || mouse.button==Qt.RightButton) { + flag(row,col); + } else { + flip(row,col); + } + } } } } @@ -146,7 +168,7 @@ Item { Image { x: 280 y: 10 - source: if(isPlaying==true){'pics/face-smile.png'}else{if(hasWon==true){'pics/face-smile-big.png'}else{'pics/face-sad.png'}} + source: isPlaying ? 'pics/face-smile.png' : hasWon ? 'pics/face-smile-big.png': 'pics/face-sad.png' MouseRegion { anchors.fill: parent onClicked: { reset() } |