1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-04 21:02:06 -04:00

feat: add setting for first day of the week (#1854)

* feat: add setting for first day of the week

* fix: extract settings indices

* fix: formatting mistake

* fix(ui): add outline rectangle between settings and reorder settings

* fix: don't set firstDayOfWeek automatically to system's locale
This commit is contained in:
Jonas Bloch
2026-03-01 02:37:16 +01:00
committed by GitHub
parent 20d383d4ab
commit ee1a2bc7de
5 changed files with 179 additions and 46 deletions

View File

@@ -9,6 +9,16 @@ import qs.Modules.Settings.Widgets
Item {
id: root
function weekStartQt() {
if (SettingsData.firstDayOfWeek >= 7 || SettingsData.firstDayOfWeek < 0) {
return Qt.locale().firstDayOfWeek;
}
return SettingsData.firstDayOfWeek;
}
function weekStartJs() {
return weekStartQt() % 7;
}
DankFlickable {
anchors.fill: parent
clip: true
@@ -69,6 +79,35 @@ Item {
settingKey: "dateFormat"
iconName: "calendar_today"
SettingsDropdownRow {
tab: "time"
tags: ["first", "day", "week"]
settingKey: "firstDayOfWeek"
text: I18n.tr("First Day of Week")
// Days from Sunday to Saturday in the selected language
// 1st of February 2026 is a Sunday, any Sunday works
options: {
return Array(7).fill(0).map(
(_, i) => new Date(Date.UTC(2026, 2, 1 + i, 0, 0, 0)).toLocaleDateString(
I18n.locale(), "dddd"
)
).map(
d => d[0].toUpperCase() + d.slice(1)
);
}
currentValue: options[root.weekStartJs()]
onValueChanged: value => {
SettingsData.set("firstDayOfWeek", options.indexOf(value));
}
}
Rectangle {
width: parent.width
height: 1
color: Theme.outline
opacity: 0.15
}
SettingsDropdownRow {
tab: "time"
tags: ["date", "format", "topbar"]