summaryrefslogtreecommitdiffstats
path: root/demos/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-02 00:52:12 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-02 00:52:12 (GMT)
commitb88740e48ce82bc118a598358a8d8aff79d2a279 (patch)
tree4274091038e0b375d377acb3f4d5b515e1ab62cb /demos/declarative
parent2790cb59f6877c1027c833578b72e168c912758a (diff)
parent172df566d0ff512012afbc5039535e532868a1e5 (diff)
downloadQt-b88740e48ce82bc118a598358a8d8aff79d2a279.zip
Qt-b88740e48ce82bc118a598358a8d8aff79d2a279.tar.gz
Qt-b88740e48ce82bc118a598358a8d8aff79d2a279.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Conflicts: demos/declarative/minehunt/main.cpp demos/declarative/minehunt/minehunt.qml
Diffstat (limited to 'demos/declarative')
-rw-r--r--demos/declarative/flickr/mobile/ImageDetails.qml5
-rw-r--r--demos/declarative/minehunt/main.cpp26
-rw-r--r--demos/declarative/minehunt/minehunt.qml14
3 files changed, 24 insertions, 21 deletions
diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml
index f1b3c7d..2f4df8a 100644
--- a/demos/declarative/flickr/mobile/ImageDetails.qml
+++ b/demos/declarative/flickr/mobile/ImageDetails.qml
@@ -66,10 +66,7 @@ Flipable {
Image {
id: bigImage; source: container.photoUrl; scale: slider.value
- // Center image if it is smaller than the flickable area.
- x: imageContainer.width > width*scale ? (imageContainer.width - width*scale) / 2 : 0
- y: imageContainer.height > height*scale ? (imageContainer.height - height*scale) / 2 : 0
- smooth: !flickable.moving
+ anchors.centerIn: parent; smooth: !flickable.moving
onStatusChanged : {
// Default scale shows the entire image.
if (status == 1 && width != 0) {
diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp
index c8b4b54..99856ed 100644
--- a/demos/declarative/minehunt/main.cpp
+++ b/demos/declarative/minehunt/main.cpp
@@ -116,8 +116,8 @@ public:
int numFlags() const{return nFlags;}
public slots:
- Q_INVOKABLE void flip(int row, int col);
- Q_INVOKABLE void flag(int row, int col);
+ Q_INVOKABLE bool flip(int row, int col);
+ Q_INVOKABLE bool flag(int row, int col);
void setBoard();
void reset();
@@ -145,6 +145,7 @@ private:
int nFlags;
};
+Q_DECLARE_METATYPE(QList<Tile*>)
MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags)
: QWidget(parent, flags), canvas(0), numCols(9), numRows(9), playing(true), won(false)
{
@@ -155,7 +156,6 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags
for(int ii = 0; ii < numRows * numCols; ++ii) {
_tiles << new Tile;
}
-
reset();
QVBoxLayout *vbox = new QVBoxLayout;
@@ -234,14 +234,14 @@ int MyWidget::getHint(int row, int col)
return hint;
}
-void MyWidget::flip(int row, int col)
+bool MyWidget::flip(int row, int col)
{
if(!playing)
- return;
+ return false;
Tile *t = tile(row, col);
if (!t || t->hasFlag())
- return;
+ return false;
if(t->flipped()){
int flags = 0;
@@ -254,7 +254,7 @@ void MyWidget::flip(int row, int col)
flags++;
}
if(!t->hint() || t->hint() != flags)
- return;
+ return false;
for (int c = col-1; c <= col+1; c++)
for (int r = row-1; r <= row+1; r++) {
Tile *nearT = tile(r, c);
@@ -262,7 +262,7 @@ void MyWidget::flip(int row, int col)
flip( r, c );
}
}
- return;
+ return true;
}
t->flip();
@@ -296,22 +296,28 @@ void MyWidget::flip(int row, int col)
hasWonChanged();
setPlaying(false);
}
+ return true;
}
-void MyWidget::flag(int row, int col)
+bool MyWidget::flag(int row, int col)
{
Tile *t = tile(row, col);
if(!t)
- return;
+ return false;
t->setHasFlag(!t->hasFlag());
nFlags += (t->hasFlag()?1:-1);
emit numFlagsChanged();
+ return true;
}
/////////////////////////////////////////////////////////
int main(int argc, char ** argv)
{
+#ifdef Q_WS_X11
+ // native on X11 is terrible for this demo.
+ QApplication::setGraphicsSystem("raster");
+#endif
QApplication app(argc, argv);
bool frameless = false;
diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml
index c54e741..456f25b 100644
--- a/demos/declarative/minehunt/minehunt.qml
+++ b/demos/declarative/minehunt/minehunt.qml
@@ -31,7 +31,7 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
source: "pics/flag.png"
- opacity: model.hasFlag
+ opacity: modelData.hasFlag
Behavior on opacity {
NumberAnimation {
property: "opacity"
@@ -47,16 +47,16 @@ Item {
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
- text: model.hint
+ text: modelData.hint
color: "white"
font.bold: true
- opacity: !model.hasMine && model.hint > 0
+ opacity: !modelData.hasMine && modelData.hint > 0
}
Image {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
source: "pics/bomb.png"
- opacity: model.hasMine
+ opacity: modelData.hasMine
}
Explosion {
id: expl
@@ -65,7 +65,7 @@ Item {
states: [
State {
name: "back"
- when: model.flipped
+ when: modelData.flipped
PropertyChanges { target: flipable; angle: 180 }
}
]
@@ -81,7 +81,7 @@ Item {
else
ret = 0;
if (ret > 0) {
- if (model.hasMine && model.flipped) {
+ if (modelData.hasMine && modelData.flipped) {
ret*3;
} else {
ret;
@@ -96,7 +96,7 @@ Item {
properties: "angle"
}
ScriptAction{
- script: if(model.hasMine && model.flipped){expl.explode = true;}
+ script: if(modelData.hasMine && modelData.flipped){expl.explode = true;}
}
}
}