blob: 09af769127e60476267b4a2867c24c2e75720f37 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
Item {
id: button
width: 30
height: 30
property var icon: ""
signal clicked
Rect {
id: buttonRect
anchors.fill: parent
color: "lightgreen"
radius: 5
Image {
id: iconImage
source: button.icon
anchors.horizontalCenter: buttonRect.horizontalCenter
anchors.verticalCenter: buttonRect.verticalCenter
}
MouseRegion {
id: buttonMouseRegion
anchors.fill: buttonRect
onClicked: { button.clicked.emit() }
}
states: [
State {
name: "pressed"
when: buttonMouseRegion.pressed == true
SetProperties {
target: buttonRect
color: "green"
}
}
]
transitions: [
Transition {
fromState: "*"
toState: "pressed"
ColorAnimation {
property: "color"
duration: 200
}
},
Transition {
fromState: "pressed"
toState: "*"
ColorAnimation {
property: "color"
duration: 1000
}
}
]
}
opacity: Behavior {
NumberAnimation {
property: "opacity"
duration: 250
}
}
}
|