blob: 97d1d50eda3c7be5cb7a2727261317a7658f892f (
plain)
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
|
import "root:/widgets"
import "root:/services"
import "root:/config"
import QtQuick
Rectangle {
id: root
readonly property alias hovered: mouse.hovered
readonly property alias pressed: mouse.pressed
property bool disabled
function onClicked(event: MouseEvent): void {
}
anchors.fill: parent
color: Colours.palette.m3onSurface
opacity: disabled ? 0 : mouse.pressed ? 0.1 : mouse.hovered ? 0.08 : 0
MouseArea {
id: mouse
property bool hovered
anchors.fill: parent
cursorShape: root.disabled ? undefined : Qt.PointingHandCursor
hoverEnabled: true
onEntered: hovered = true
onExited: hovered = false
onClicked: event => !root.disabled && root.onClicked(event)
}
Behavior on opacity {
NumberAnimation {
duration: Appearance.anim.durations.smaller
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
}
}
Behavior on color {
ColorAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
}
}
}
|