-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCloseButton.qml
49 lines (45 loc) · 1.34 KB
/
CloseButton.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
import QtQuick 2.0
Rectangle {
id: root
property int size
property bool hovered: false
width: size
height: size
color: "#c42"
radius: size / 2
signal clicked()
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: root.clicked()
hoverEnabled: true
onEntered: root.hovered = true
onExited: root.hovered = false
Text {
id: txt
anchors.fill: parent
anchors.leftMargin: 0
anchors.topMargin: 0
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: "black"
text: "x"//"\u2a2f" size issue with \u2a2f
minimumPixelSize: 20
font.weight: Font.Bold
fontSizeMode: Text.VerticalFit
}
}
states: [
State {
name: "down"; when: mouseArea.pressed
PropertyChanges { target: txt; anchors.leftMargin: 2; anchors.topMargin: 2 }
PropertyChanges { target: root; color: "red" }
PropertyChanges { target: txt; color: "white" }
},
State {
name: "hovered"; when: root.hovered && !mouseArea.pressed
PropertyChanges { target: root; color: "red" }
PropertyChanges { target: txt; color: "white" }
}
]
}