-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageButton.qml
executable file
·67 lines (64 loc) · 1.9 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import QtQuick 2.5
import QtGraphicalEffects 1.0
Item {
property alias radius: button.radius
property alias color: button.color
property alias image: image
property alias source: image.source
property alias action : mouseArea
property real zoom : 1.1
property bool responsive : false
property int elevation : 3
property alias colorize: colorOverlay.visible
property alias imageColor: colorOverlay.color
property bool lotOfClicks : false
property int coolDownTime : 400
height:parent.height/10; width:parent.width/8
Timer {
id: timer
interval: lotOfClicks?0:coolDownTime
running: false
repeat: false
triggeredOnStart: false
onTriggered: mouseArea.visible = true
}
DropShadow {
id:shadow
anchors.fill: button
horizontalOffset: 0
verticalOffset: elevation
radius: 3*elevation
samples: 32
color: "#80000000"
source: button
transparentBorder: true
scale: mouseArea.containsMouse ? zoom : 1
Behavior on scale { NumberAnimation { duration: 100 } }
}
Rectangle {
id:button
anchors.fill: parent
scale: mouseArea.containsMouse ? zoom : 1
Behavior on scale { NumberAnimation { duration: 100 } }
Image {
id:image
height:parent.height*0.7; width: parent.width*0.7
anchors.centerIn: parent;
sourceSize.height: parent.height; sourceSize.width: parent.width
}
ColorOverlay {
id:colorOverlay
visible: false
anchors.fill: image
source: image
color: "#3b3b3b"
}
MouseArea {
id:mouseArea; anchors.fill: parent; hoverEnabled: responsive
onClicked: {
mouseArea.visible = false
timer.start()
}
}
}
}