-
Notifications
You must be signed in to change notification settings - Fork 1
/
CircularMenu.qml
83 lines (68 loc) · 2.14 KB
/
CircularMenu.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import QtQuick 2.15
import QtQuick.Shapes
import QtQuick.Controls.Material
import QtQuick.Layouts
Item {
// ----------------------------------------- properties
property ListModel listModel: ListModel{}
property double outerRadius: 400
property double innerRadius: 300
property double startAngle: -90 - currentCutLen * listModel.count / 2
property double currentCutLen: 45
property double animationDuration: 2000
readonly property double scaleNameLen: 10
anchors.fill: parent
// ----------------------------------------- animation
PropertyAnimation on outerRadius {
id: outerAnimation
easing.type: Easing.OutElastic
from: 0
to: outerRadius
duration: parseInt(animationDuration)
}
PropertyAnimation on innerRadius {
id: innerAnimation
easing.type: Easing.OutElastic
from: 0
to: innerRadius
duration: parseInt(animationDuration)
}
// ----------------------------------------- fake background
Rectangle {
id: fakeOuterCircle
// visible: false
width: outerRadius * 2
height: outerRadius * 2
radius: outerRadius
opacity: 0.5
color: 'transparent'
// color: 'pink'
anchors.centerIn: parent
Rectangle {
id: fakeInnerCircle
width: innerRadius * 2
height: innerRadius * 2
radius: innerRadius
opacity: 0.6
color: 'gold'
anchors.centerIn: parent
}
}
// ----------------------------------------- Circular Menu
Repeater {
anchors.fill: parent
model: listModel.count
CircularCut {
required property var model
cutText: listModel.get(model.index).name
cutOuterRadius: outerRadius
cutInnerRadius: innerRadius
cutStartAngle: startAngle + model.index * currentCutLen
cutLen: currentCutLen
cutIconColor: listModel.get(model.index).color
onCutClicked: {
console.log(listModel.get(model.index).name)
}
}
}
}