Skip to content

Commit 519d1b5

Browse files
committed
PreferencesDialog: Add accent color option
1 parent 4a60c11 commit 519d1b5

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

src/app/qml/dialogs/PreferencesDialog.qml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,31 @@ CustomDialog {
1717
ThemeEngine.reloadTheme();
1818
}
1919

20+
QtObject {
21+
id: priv
22+
property int accentColorIndex: -1
23+
24+
readonly property list<color> darkAccentColors: [
25+
Qt.rgba(0.85, 0.31, 0.33, 1),
26+
Qt.rgba(0.85, 0.62, 0.31, 1),
27+
Qt.rgba(0.85, 0.84, 0.31, 1),
28+
Qt.rgba(0.39, 0.85, 0.31, 1),
29+
Qt.rgba(0.31, 0.75, 0.85, 1),
30+
Qt.rgba(0.32, 0.32, 0.85, 1),
31+
Qt.rgba(0.68, 0.31, 0.85, 1),
32+
]
33+
34+
readonly property list<color> lightAccentColors: [
35+
Qt.rgba(0.75, 0.08, 0.09, 1),
36+
Qt.rgba(0.75, 0.47, 0.08, 1),
37+
Qt.rgba(0.75, 0.74, 0.08, 1),
38+
Qt.rgba(0.17, 0.75, 0.08, 1),
39+
Qt.rgba(0.08, 0.63, 0.75, 1),
40+
Qt.rgba(0.08, 0.08, 0.75, 1),
41+
Qt.rgba(0.54, 0.08, 0.75, 1),
42+
]
43+
}
44+
2045
contentItem: ColumnLayout {
2146
// Themes
2247
Label {
@@ -38,5 +63,47 @@ CustomDialog {
3863
onCheckedChanged: if(checked) ThemeEngine.theme = ThemeEngine.DarkTheme
3964
}
4065
}
66+
67+
RowLayout {
68+
Label {
69+
text: qsTr("Accent color:")
70+
}
71+
72+
Repeater {
73+
id: accentColors
74+
model: ThemeEngine.theme == ThemeEngine.DarkTheme ? priv.darkAccentColors : priv.lightAccentColors
75+
76+
ColorButton {
77+
required property color modelData
78+
required property int index
79+
color: modelData
80+
checked: {
81+
if(ThemeEngine.accentColor === modelData) {
82+
priv.accentColorIndex = index;
83+
return true;
84+
} else {
85+
return false;
86+
}
87+
}
88+
autoExclusive: true
89+
checkable: true
90+
onPressed: ThemeEngine.accentColor = modelData;
91+
}
92+
}
93+
}
94+
95+
Connections {
96+
target: ThemeEngine
97+
98+
function onThemeChanged() {
99+
console.log(priv.accentColorIndex, ThemeEngine.theme);
100+
101+
if(ThemeEngine.theme == ThemeEngine.DarkTheme) {
102+
ThemeEngine.accentColor = priv.darkAccentColors[priv.accentColorIndex];
103+
} else {
104+
ThemeEngine.accentColor = priv.lightAccentColors[priv.accentColorIndex];
105+
}
106+
}
107+
}
41108
}
42109
}

0 commit comments

Comments
 (0)