-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Button.qml
121 lines (99 loc) · 2.7 KB
/
Button.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
import Qt5Compat.GraphicalEffects
import QtQuick 2.12
import QtQuick.Controls 2.12
import "Theme"
AbstractButton {
id: root
property color normalColor: Theme.buttonNormalColor
required property color activeColor
property color pressedColor: activeColor
property bool highlight: false
implicitWidth: 52
implicitHeight: 26
states: [
State {
name: "pressed"
when: root.pressed
PropertyChanges {
target: backgroundImage
source: Theme.imgButtonPressed
}
PropertyChanges {
target: label
color: root.pressedColor
}
PropertyChanges {
target: labelGlow
visible: true
}
},
State {
name: "active"
when: (root.highlight || root.checked) && !root.pressed
PropertyChanges {
target: backgroundImage
source: Theme.imgButton
}
PropertyChanges {
target: label
color: root.activeColor
}
PropertyChanges {
target: labelGlow
visible: true
}
},
State {
name: "inactive"
when: !root.checked && !root.highlight && !root.pressed
PropertyChanges {
target: backgroundImage
source: Theme.imgButton
}
PropertyChanges {
target: label
color: root.normalColor
}
PropertyChanges {
target: labelGlow
visible: false
}
}
]
background: BorderImage {
id: backgroundImage
anchors.fill: parent
horizontalTileMode: BorderImage.Stretch
verticalTileMode: BorderImage.Stretch
source: Theme.imgButton
border {
top: 10
left: 10
right: 10
bottom: 10
}
}
contentItem: Item {
anchors.fill: parent
Glow {
id: labelGlow
anchors.fill: parent
radius: 5
spread: 0.1
color: label.color
source: label
}
Label {
id: label
anchors.fill: parent
text: root.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.family: Theme.fontFamily
font.capitalization: Font.AllUppercase
font.bold: true
font.pixelSize: Theme.buttonFontPixelSize
color: root.normalColor
}
}
}