-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCustomButton.qml
More file actions
120 lines (103 loc) · 2.74 KB
/
CustomButton.qml
File metadata and controls
120 lines (103 loc) · 2.74 KB
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
import QtQuick 2.15
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.15
import AppStyle 1.0
Button {
id:control
implicitWidth: 46
implicitHeight: 46
property real radius: 8
property color backgroundColor: "#14A44D"
property string setIcon: ""
property color textColor: "#FFFFFF"
property real borderWidth: 0
property color borderColor: "transparent"
font.pixelSize: FontStyle.h3
font.family: FontStyle.getContentFont.name
font.bold: Font.Bold
font.weight: Font.Bold
contentItem:ColumnLayout{
width: parent.width
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
Label{
z:2
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
font:control.font
text: control.text
color: control.textColor
visible: !setIcon
}
Image{
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
sourceSize: Qt.size(control.implicitWidth* 0.6,control.implicitHeight*0.6)
source: setIcon
}
}
background: Rectangle{
implicitHeight: control.implicitHeight
implicitWidth: control.implicitWidth
radius: control.radius
color: control.backgroundColor
border.width: control.borderWidth
border.color: control.borderColor
visible: false
Behavior on color {
ColorAnimation {
easing.type: Easing.Linear
duration: 200
}
}
Rectangle{
id:indicator
property int mx
property int my
x:mx-width/2
y:my-height/2
height:width
radius: control.radius
color: Qt.lighter(AppStyle.appStyle)
}
}
Rectangle{
id:mask
radius: control.radius
anchors.fill: parent
visible: false
}
OpacityMask{
anchors.fill: background
source: background
maskSource: mask
}
MouseArea{
id:mouseArea
hoverEnabled: true
acceptedButtons: Qt.NoButton
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
}
ParallelAnimation{
id:main
NumberAnimation{
target: indicator
properties: 'width'
from:0
to:control.width *2.5
duration: 200
}
NumberAnimation{
target: indicator
properties: 'opacity'
from:0.9
to:0
duration: 200
}
}
onPressed: {
indicator.mx = mouseArea.mouseX
indicator.my = mouseArea.mouseY
main.restart()
}
}