summaryrefslogtreecommitdiffstats
path: root/demos/declarative/samegame/SameGame.qml
blob: e2c20895079b9064334f33a9e418bef155a056e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Qt 4.6

import "content"

Rect {
    width: 460
    height: 700
    color: activePalette.window
    Script { source: "content/samegame.js" }
    Rect{
        property int score: 0
        y:20; width:400; height:600; id: gameCanvas;
        //For Fixed Size
        anchors.horizontalCenter: parent.horizontalCenter
        //For flexible width
        //anchors.left: parent.left; anchors.leftMargin: 30
        //anchors.right: parent.right; anchors.rightMargin: 30
        color: "white"
        pen.width: 1
        Image { id:background;
            source: "content/pics/background.png"
            anchors.fill: parent
        }

    }
    HorizontalLayout {
        anchors.top: gameCanvas.bottom
        anchors.topMargin: 10
        anchors.horizontalCenter: parent.horizontalCenter
        MediaButton { id: btnA; text: "New Game"; onClicked: {initBoard();} }
        MediaButton { id: btnB; text: "Swap Tiles"; onClicked: {swapTileSrc(); dialog.opacity = 1;
            dialog.text="Takes effect next game.";} }
        Text{ text: "Score: " + gameCanvas.score; width:120; font.size:14 }
    }
    SameDialog {
        id: dialog
        anchors.centeredIn: parent
        text: "Hello World"
    }
}