Skip to content

Commit a2764a6

Browse files
committed
adds MenuBar style
1 parent dfa4879 commit a2764a6

File tree

4 files changed

+80
-28
lines changed

4 files changed

+80
-28
lines changed

background/Button.qml

+5-28
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,25 @@
11
import QtQuick 2.0
2+
import "qrc:/.styles/Material/components"
23

34
Rectangle {
45
id: buttonBackground
5-
color: parent.enabled ? parent.Material.primary : "#E0E0E0"
6+
color: parent.enabled ? parent.Material.background : "#E0E0E0"
67
radius: 4
78
clip: true
89

910
Component.onCompleted: {
1011
buttonBackground.dom.style.boxShadow = "rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px";
11-
buttonBackground.dom.style.cursor = "pointer";
1212
}
1313

14-
// Ripple
15-
Rectangle {
14+
RippleEffect {
1615
id: ripple
17-
color: "white"
18-
anchors.centerIn: parent
19-
radius: 999
20-
width: 1
21-
height: 1
22-
opacity: 0
23-
}
24-
NumberAnimation {
25-
id: rippleAnimationPart1
26-
target: ripple
27-
properties: "height,width"
28-
from: 0
29-
to: Math.max(buttonBackground.width, buttonBackground.height) * 1.25
30-
onFinished: rippleAnimationPart2.start()
31-
}
32-
NumberAnimation {
33-
id: rippleAnimationPart2
34-
target: ripple
35-
properties: "opacity"
36-
from: 0.32
37-
to: 0
3816
}
17+
3918
Connections {
4019
target: buttonBackground.parent
4120
onDownChanged: {
4221
if (buttonBackground.parent.down) {
43-
ripple.opacity = 0.32;
44-
ripple.height = ripple.width = 1;
45-
rippleAnimationPart1.start();
22+
ripple.start();
4623
}
4724
}
4825
}

components/RippleEffect.qml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import QtQuick 2.0
2+
3+
Rectangle {
4+
id: ripple
5+
color: "white"
6+
anchors.centerIn: parent
7+
radius: 999
8+
width: 1
9+
height: 1
10+
opacity: 0
11+
12+
function start() {
13+
ripple.opacity = 0.32;
14+
ripple.height = ripple.width = 1;
15+
rippleAnimationPart1.start();
16+
}
17+
18+
NumberAnimation {
19+
id: rippleAnimationPart1
20+
target: ripple
21+
properties: "height,width"
22+
from: 0
23+
to: Math.max(ripple.parent.width, ripple.parent.height) * 1.25
24+
onFinished: rippleAnimationPart2.start()
25+
}
26+
27+
NumberAnimation {
28+
id: rippleAnimationPart2
29+
target: ripple
30+
properties: "opacity"
31+
from: 0.32
32+
to: 0
33+
}
34+
}

delegate/MenuBar.qml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import QtQuick 2.0
2+
import QtQuick.Controls 2.0
3+
import "qrc:/.styles/Material/components"
4+
5+
Button {
6+
property var menu: parent.parent.menus[index]
7+
property bool opened: menu.opened
8+
text: menu.title
9+
padding: 10
10+
11+
contentItem: Text {
12+
anchors.centerIn: parent
13+
text: parent.$formatLabel(parent.text.toUpperCase(), parent.display, parent.icon)
14+
color: parent.enabled ? "black" : "grey"
15+
font.size: 14
16+
font.weight: 500
17+
font.family: "Roboto"
18+
horizontalAlignment: Text.AlignHCenter
19+
}
20+
21+
background: Rectangle {
22+
color: opened ? "#d3d3d3" : "transparent"
23+
clip: true
24+
RippleEffect {
25+
id: ripple
26+
color: Material.Grey
27+
}
28+
}
29+
30+
Connections {
31+
target: menu
32+
onOpenedChanged: {
33+
if (menu.opened) {
34+
ripple.start();
35+
}
36+
}
37+
}
38+
}

material.qrc

+3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<file>background/Popup.qml</file>
44
<file>background/Button.qml</file>
55
<file>background/ScrollBar.qml</file>
6+
<file>background/MenuBar.qml</file>
67
<file>content/Button.qml</file>
78
<file>content/ScrollBar.qml</file>
9+
<file>delegate/MenuBar.qml</file>
10+
<file>components/RippleEffect.qml</file>
811
</qresource>
912
</RCC>

0 commit comments

Comments
 (0)