mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-04 04:42:05 -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:
@@ -14,8 +14,15 @@ Rectangle {
|
||||
|
||||
signal closeDash
|
||||
|
||||
function weekStartQt() {
|
||||
if (SettingsData.firstDayOfWeek >= 7 || SettingsData.firstDayOfWeek < 0) {
|
||||
return Qt.locale().firstDayOfWeek;
|
||||
}
|
||||
return SettingsData.firstDayOfWeek;
|
||||
}
|
||||
|
||||
function weekStartJs() {
|
||||
return Qt.locale().firstDayOfWeek % 7;
|
||||
return weekStartQt() % 7;
|
||||
}
|
||||
|
||||
function startOfWeek(dateObj) {
|
||||
@@ -223,7 +230,7 @@ Rectangle {
|
||||
Repeater {
|
||||
model: {
|
||||
const days = [];
|
||||
const qtFirst = Qt.locale().firstDayOfWeek;
|
||||
const qtFirst = weekStartQt();
|
||||
for (let i = 0; i < 7; ++i) {
|
||||
const qtDay = ((qtFirst - 1 + i) % 7) + 1;
|
||||
days.push(I18n.locale().dayName(qtDay, Locale.ShortFormat));
|
||||
|
||||
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user