forked from oepi-loepi/solarPanel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
NewTextLabel.qml
96 lines (83 loc) · 2.2 KB
/
NewTextLabel.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
////// MODIFIED BUTTON BY OEPI-LOEPI for TOON
import QtQuick 2.1
import BasicUIControls 1.0
Item {
id: newTextLabel
width: 430
height: defaultHeight
property int defaultHeight: 36
property string buttonText
property alias labelFontFamily: labelTitle.font.family
property alias labelFontSize: labelTitle.font.pixelSize
property string buttonActiveColor : "grey"
property string buttonHoverColor : "blue"
property string buttonDisabledColor : "lightgrey"
property string textColor : "black"
property string textDisabledColor : "grey"
signal clicked()
function doClick(){
clicked();
}
Rectangle {
id: buttonRect
anchors {
fill: parent
leftMargin: 5
topMargin: 5
rightMargin: 5
bottomMargin: 5
}
color: buttonActiveColor
radius: 5
//onClicked: newTextLabel.clicked()
Text {
id: labelTitle
anchors {
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
}
font {
family: qfont.semiBold.name
//pixelSize: qfont.titleText
pixelSize:isNxt ? 20 : 16
}
text: buttonText
color: newTextLabel.enabled? textColor: textDisabledColor
}
state: newTextLabel.enabled ? "active" : "disabled"
Component.onCompleted: state = state
states: [
State {
name: "hover"
when: buttonArea.containsMouse || newTextLabel.focus
PropertyChanges {
target: buttonRect
color: buttonHoverColor
}
},
State {
name: "active"
when: newTextLabel.enabled
PropertyChanges {
target: buttonRect
color: buttonActiveColor
}
},
State {
name: "disabled"
when: !newTextLabel.enabled
PropertyChanges {
target: buttonRect
color: buttonDisabledColor
}
}
]
}
MouseArea {
id: buttonArea
anchors.fill: parent
hoverEnabled: true
onClicked: doClick()
cursorShape: Qt.PointingHandCursor
}
}