-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTagLabel.qml
51 lines (47 loc) · 1.31 KB
/
TagLabel.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
import QtQuick 2.0
import QtQuick.Controls 2.4
Rectangle {
id: root
property int horizontalMargin: 6
property int verticalMargin: 3
width: childrenRect.width + 2 * horizontalMargin
height: childrenRect.height + 2 * verticalMargin
radius: height / 2
color: "#08f"
property alias text: textLabel.text
property alias textColor: textLabel.color
property bool closeButton: false
property int closeButtonSize: 15
signal closeClicked()
property bool selected: false
Row {
anchors.centerIn: parent
spacing: 4
Text {
id: textLabel
color: "#fff"
font.weight: Font.Bold
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: root.focus = true
}
}
CloseButton {
size: closeButtonSize
visible: root.closeButton
onClicked: root.closeClicked()
}
}
states: [
State {
name: "selected"; when: root.selected
PropertyChanges { target: root; border.color: "#00f" }
},
State {
name: "hovered"; when: mouseArea.containsMouse
PropertyChanges { target: root; color: "#2af" }
}
]
}