-
Notifications
You must be signed in to change notification settings - Fork 28
/
ImageButton.qml
43 lines (39 loc) · 976 Bytes
/
ImageButton.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
import QtQuick 2.2
Rectangle {
id: btn;
implicitWidth: 48;
implicitHeight: 48;
color: "transparent";
property var iconNormal;
property var iconPressed;
signal clicked();
Image {
id: icon;
anchors.fill: parent;
anchors.margins: 1;
fillMode: Image.PreserveAspectFit;
}
onIconNormalChanged: icon.source = iconNormal;
MouseArea {
anchors.fill: parent;
onPressed: {
if(btn.iconPressed != undefined){
icon.source = iconPressed;
}else{
border.width = 1;
border.color = "gray";
}
}
onReleased: {
if(btn.iconPressed == undefined){
border.width = 0;
border.color = "gray";
}
icon.source = iconNormal;
}
onClicked: btn.clicked();
}
Component.onCompleted: {
icon.source = iconNormal;
}
}