-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSoundButton.qml
More file actions
93 lines (79 loc) · 2.15 KB
/
Copy pathSoundButton.qml
File metadata and controls
93 lines (79 loc) · 2.15 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
import QtQuick 2.0
import QtMultimedia 5.0
import Ubuntu.Components 0.1
UbuntuShape {
id: box;
antialiasing: true;
radius: "medium"
property alias color: box.color;
property alias description: label.text;
property alias imageSource: image.source;
property alias soundSource: sound.source;
property var state: false;
Image {
id: image;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.verticalCenter: parent.verticalCenter;
width: parent.width * 0.8;
height: parent.height * 0.8;
fillMode: Image.PreserveAspectFit
}
Label {
id: label;
anchors.horizontalCenter: image.horizontalCenter
anchors.top: image.bottom
text: "Hello, world!"
fontSize: "medium"
}
Audio {
id: sound;
onStopped: {
box.color = "#32222C"
if (box.state == true) {
box.color = UbuntuColors.warmGrey
sound.play()
}
}
}
SequentialAnimation {
id: animation;
RotationAnimation {
target: box;
properties: "rotation";
duration: 100;
to: 10;
easing.type: Easing.OutQuad;
}
RotationAnimation {
target: box;
properties: "rotation";
duration: 200;
to: -10;
easing.type: Easing.OutQuad;
}
RotationAnimation {
target: box;
properties: "rotation";
duration: 100;
to: 0;
easing.type: Easing.OutQuad;
}
}
MouseArea {
anchors.fill: parent;
onPressed: {
if (box.state == false) {
box.state = true;
sound.play();
box.color = UbuntuColors.warmGrey
}
else if (box.state == true) {
box.state = false;
sound.stop()
box.color = "#32222C"
}
animation.start();
}
//onClicked: PropertyAnimation { target: box; property: "opacity"; to: 0.5 }
}
}