-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameGridItem.qml
128 lines (103 loc) · 3.44 KB
/
GameGridItem.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Pegasus Frontend
// Copyright (C) 2017-2018 Mátyás Mustoha
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import QtQuick 2.8
import QtGraphicalEffects 1.12
Rectangle {
id: root
property bool selected: false
property var game
property var systemColor
antialiasing: true
border.color: selected ? systemColor : "transparent"//"#99FFFFFF"
border.width: vpx (6) // selected ? vpx(3) : 0
color: selected ? "#000000" : "transparent"
property alias imageWidth: boxFront.paintedWidth
property alias imageHeight: boxFront.paintedHeight
property real imageHeightRatio: 0.5
height: width * imageHeightRatio
signal clicked()
signal doubleClicked()
signal imageLoaded(int imgWidth, int imgHeight)
scale: selected ? 1.5 : 1
opacity: 1 //selected ? 1 : 0.666
z: selected ? 3 : 1
Behavior on scale { PropertyAnimation { duration: 150 } }
// Behavior on opacity { PropertyAnimation { duration: 333 } }
layer.enabled: selected ? true : false
layer.effect: DropShadow {
fast: true
spread: 0.1
horizontalOffset: 0
verticalOffset: 0
radius: vpx(12)
samples: 20
color: "#000000"
transparentBorder: true
}
Image {
id: boxFront
anchors { fill: parent; margins: vpx(4) }
asynchronous: true
visible: game.assets.boxFront
source: game.assets.boxFront || ""
sourceSize { width: 256; height: 256 }
fillMode: Image.PreserveAspectFit
smooth: true
onStatusChanged: if (status === Image.Ready) {
imageHeightRatio = paintedHeight / paintedWidth;
root.imageLoaded(paintedWidth, paintedHeight);
}
}
Image {
anchors.centerIn: parent
visible: boxFront.status === Image.Loading
source: "assets/loading-spinner.png"
RotationAnimator on rotation {
loops: Animator.Infinite;
from: 0;
to: 360;
duration: 2000
}
}
Rectangle {
id: textBox
width: boxFront.width
height: boxFront.height
anchors.centerIn: parent
// anchors.margins: vpx(4)
visible: !game.assets.boxFront
color: "#000000"
}
Text {
width: parent.width - vpx(10)
height: parent.height - vpx(10)
anchors.centerIn: parent
visible: !game.assets.boxFront
text: game.title
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
color: "#eee"
font {
pixelSize: vpx(16)
family: globalFonts.condensed
}
}
MouseArea {
anchors.fill: parent
onClicked: root.clicked()
onDoubleClicked: root.doubleClicked()
}
}