-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTile.qml
89 lines (75 loc) · 2.18 KB
/
Tile.qml
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import QtQuick 2.13
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.5
import "Colors.js" as C
Flipable {
id: flipable;
Layout.fillWidth: true;
Layout.fillHeight: true;
property var question;
signal selected();
clip: true
transform: Rotation {
id: rotation
origin.x: flipable.width/2
origin.y: flipable.height/2
axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis
angle: 0 // the default angle
}
states: State {
name: "back"
PropertyChanges {
target: rotation; angle: 180;
}
when: question.revealed;
}
transitions: Transition {
NumberAnimation {
target: rotation;
property: "angle";
duration: 200
easing.type: Easing.InOutQuad
}
}
front: Button {
anchors.fill: parent;
text: question.points;
font.pointSize: 30;
onClicked: {
selected();
}
}
back: Rectangle {
anchors.fill: parent;
property var winner: question.playerAnswers.length > 0 ? question.playerAnswers[question.playerAnswers.length - 1].player : null;
color: winner ? winner.color : "gray";
id: tile
MouseArea {
anchors.fill: parent;
onClicked: {
if (mouse.modifiers & Qt.ControlModifier) {
selected();
}
}
}
ColumnLayout {
anchors.centerIn: parent;
Repeater {
model: question.playerAnswers;
delegate: Text {
Layout.alignment: Qt.AlignHCenter
property var playerAnswer: model.modelData;
color: C.textColorFor(tile.color)
text: {
if (playerAnswer.player !== null) {
return playerAnswer.player.name + " [" + playerAnswer.score + "]";
}
else {
return "Nobody";
}
}
}
}
}
}
}