-
Notifications
You must be signed in to change notification settings - Fork 7
/
SysBtn.qml
64 lines (56 loc) · 1.39 KB
/
SysBtn.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
import QtQuick 2.4
Rectangle
{
id:sysbtn
property string picCurrent: ""
property string picNormal: ""
property string picHover: ""
property string picPressed: ""
signal clicked
width: 32
height: 32
color:"#00000000"
state:"normal"
Image
{
source: picCurrent;
anchors.verticalCenter: parent.verticalCenter //设置图片资源垂直居中
}
MouseArea
{
hoverEnabled: true
anchors.fill: parent
onEntered: sysbtn.state == "pressed" ? sysbtn.state = "pressed" : sysbtn.state = "hover"
onExited: sysbtn.state == "pressed" ? sysbtn.state = "pressed" : sysbtn.state = "normal"
onPressed: sysbtn.state = "pressed"
onReleased:
{
sysbtn.state = "normal"
sysbtn.clicked()
}
}
states:
[
State{
name:"hover"
PropertyChanges {
target: sysbtn
picCurrent:picHover
}
},
State {
name: "normal"
PropertyChanges {
target: sysbtn
picCurrent:picNormal
}
},
State {
name: "pressed"
PropertyChanges {
target: sysbtn
picCurrent:picPressed
}
}
]
}