-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathFlatButton.qml
48 lines (45 loc) · 1.16 KB
/
FlatButton.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
import QtQuick 2.2
Rectangle {
id: bkgnd;
implicitWidth: 120;
implicitHeight: 50;
color: "transparent";
property alias iconSource: icon.source;
property alias iconWidth: icon.width;
property alias iconHeight: icon.height;
property alias textColor: btnText.color;
property alias font: btnText.font;
property alias text: btnText.text;
radius: 6;
property bool hovered: false;
border.color: "lightgray";
border.width: hovered ? 2 : 1;
signal clicked;
Image {
id: icon;
anchors.left: parent.left;
anchors.verticalCenter: parent.verticalCenter;
}
Text {
id: btnText;
anchors.left: icon.right;
anchors.verticalCenter: icon.verticalCenter;
anchors.margins: 4;
color: ma.pressed ? "blue" : (parent.hovered ? "#0000a0" : "black");
}
MouseArea {
id: ma;
anchors.fill: parent;
hoverEnabled: true;
onEntered: {
bkgnd.hovered = true;
}
onExited: {
bkgnd.hovered = false;
}
onClicked: {
bkgnd.hovered = false;
bkgnd.clicked();
}
}
}