Skip to content

Commit aa98f35

Browse files
committed
qml: Add Hover, Filled, and Active color interaction states to Setting
1 parent 403d57e commit aa98f35

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/qml/controls/Setting.qml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,42 @@ AbstractButton {
1313
property alias actionItem: action_loader.sourceComponent
1414
property alias loadedItem: action_loader.item
1515
property string description
16+
property color stateColor
17+
state: "FILLED"
18+
19+
states: [
20+
State {
21+
name: "FILLED"
22+
PropertyChanges { target: root; stateColor: Theme.color.neutral9 }
23+
},
24+
State {
25+
name: "HOVER"
26+
PropertyChanges { target: root; stateColor: Theme.color.orangeLight1 }
27+
},
28+
State {
29+
name: "ACTIVE"
30+
PropertyChanges { target: root; stateColor: Theme.color.orange }
31+
}
32+
]
33+
34+
MouseArea {
35+
id: mouseArea
36+
anchors.fill: root
37+
hoverEnabled: true
38+
onEntered: {
39+
root.state = "HOVER"
40+
}
41+
onExited: {
42+
root.state = "FILLED"
43+
}
44+
onPressed: {
45+
root.state = "ACTIVE"
46+
}
47+
onReleased: {
48+
root.state = "HOVER"
49+
root.clicked()
50+
}
51+
}
1652

1753
contentItem: ColumnLayout {
1854
spacing: 20
@@ -23,6 +59,7 @@ AbstractButton {
2359
center: false
2460
header: root.header
2561
headerSize: 18
62+
headerColor: root.stateColor
2663
description: root.description
2764
descriptionSize: 15
2865
descriptionMargin: 0

0 commit comments

Comments
 (0)