From 528e976f274176ef80d2ec0dcce0b9dd10fb7777 Mon Sep 17 00:00:00 2001 From: lysec Date: Sun, 19 Oct 2025 17:44:52 +0200 Subject: [PATCH] Revert "LocationTab: add setting for first day of the week" This reverts commit af7498155c4d8fbf4196562eb865d668db0413d0. --- Assets/Translations/de.json | 8 -- Assets/Translations/en.json | 8 -- Assets/Translations/es.json | 8 -- Assets/Translations/fr.json | 8 -- Assets/Translations/pt.json | 8 -- Assets/Translations/zh-CN.json | 8 -- Assets/settings-default.json | 3 +- Commons/I18n.qml | 1 + Commons/Settings.qml | 1 - Modules/Bar/Calendar/CalendarPanel.qml | 110 +++++++------------------ Modules/Settings/Tabs/GeneralTab.qml | 28 +++---- Modules/Settings/Tabs/LocationTab.qml | 21 ----- 12 files changed, 43 insertions(+), 169 deletions(-) diff --git a/Assets/Translations/de.json b/Assets/Translations/de.json index b5fc5c9b..ade02602 100644 --- a/Assets/Translations/de.json +++ b/Assets/Translations/de.json @@ -631,14 +631,6 @@ "week-numbers": { "label": "Wochennummern anzeigen", "description": "Zeigt die Woche des Jahres (z.B. Woche 38) im Kalender an." - }, - "first-day-of-week": { - "label": "Erster Tag der Woche", - "description": "Wählen Sie, welcher Tag die Kalenderwoche beginnt.", - "auto": "Systemstandard", - "monday": "Montag", - "saturday": "Samstag", - "sunday": "Sonntag" } } }, diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 765201aa..cbad3dd8 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -631,14 +631,6 @@ "week-numbers": { "label": "Show week numbers", "description": "Displays the week of the year (e.g., Week 38) in the calendar." - }, - "first-day-of-week": { - "label": "First day of week", - "description": "Choose which day starts the calendar week.", - "auto": "System default", - "monday": "Monday", - "saturday": "Saturday", - "sunday": "Sunday" } } }, diff --git a/Assets/Translations/es.json b/Assets/Translations/es.json index 37929c83..236c7860 100644 --- a/Assets/Translations/es.json +++ b/Assets/Translations/es.json @@ -631,14 +631,6 @@ "week-numbers": { "label": "Mostrar números de semana", "description": "Muestra la semana del año (ej., Semana 38) en el calendario." - }, - "first-day-of-week": { - "label": "Primer día de la semana", - "description": "Elige qué día comienza la semana del calendario.", - "auto": "Predeterminado del sistema", - "monday": "Lunes", - "saturday": "Sábado", - "sunday": "Domingo" } } }, diff --git a/Assets/Translations/fr.json b/Assets/Translations/fr.json index 0feda9ff..1c1bb259 100644 --- a/Assets/Translations/fr.json +++ b/Assets/Translations/fr.json @@ -631,14 +631,6 @@ "week-numbers": { "label": "Afficher les numéros de semaine", "description": "Affiche la semaine de l'année (ex: Semaine 38) dans le calendrier." - }, - "first-day-of-week": { - "label": "Premier jour de la semaine", - "description": "Choisissez quel jour commence la semaine du calendrier.", - "auto": "Par défaut du système", - "monday": "Lundi", - "saturday": "Samedi", - "sunday": "Dimanche" } } }, diff --git a/Assets/Translations/pt.json b/Assets/Translations/pt.json index 11008643..86d1b7be 100644 --- a/Assets/Translations/pt.json +++ b/Assets/Translations/pt.json @@ -593,14 +593,6 @@ "week-numbers": { "label": "Mostrar números da semana", "description": "Exibe a semana do ano (ex., Semana 38) no calendário." - }, - "first-day-of-week": { - "label": "Primeiro dia da semana", - "description": "Escolha qual dia inicia a semana do calendário.", - "auto": "Padrão do sistema", - "monday": "Segunda-feira", - "saturday": "Sábado", - "sunday": "Domingo" } } }, diff --git a/Assets/Translations/zh-CN.json b/Assets/Translations/zh-CN.json index 4631a11d..2082e765 100644 --- a/Assets/Translations/zh-CN.json +++ b/Assets/Translations/zh-CN.json @@ -631,14 +631,6 @@ "week-numbers": { "label": "显示周数", "description": "在日历中显示一年中的第几周(例如:第 38 周)。" - }, - "first-day-of-week": { - "label": "每周第一天", - "description": "选择日历每周的起始日。", - "auto": "系统默认", - "monday": "星期一", - "saturday": "星期六", - "sunday": "星期日" } } }, diff --git a/Assets/settings-default.json b/Assets/settings-default.json index 6e1b77a2..57033237 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -74,8 +74,7 @@ "weatherEnabled": true, "useFahrenheit": false, "use12hourFormat": false, - "showWeekNumberInCalendar": false, - "firstDayOfWeek": "auto" + "showWeekNumberInCalendar": false }, "screenRecorder": { "directory": "", diff --git a/Commons/I18n.qml b/Commons/I18n.qml index 59eeb922..4ec5e86f 100644 --- a/Commons/I18n.qml +++ b/Commons/I18n.qml @@ -8,6 +8,7 @@ import qs.Commons Singleton { id: root + property bool isLoaded: false property string langCode: "" property string systemDetectedLangCode: "" diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 236277b1..f98e3e3e 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -202,7 +202,6 @@ Singleton { property bool useFahrenheit: false property bool use12hourFormat: false property bool showWeekNumberInCalendar: false - property string firstDayOfWeek: "auto" // "auto", "monday", "saturday", "sunday" } // screen recorder diff --git a/Modules/Bar/Calendar/CalendarPanel.qml b/Modules/Bar/Calendar/CalendarPanel.qml index b6652675..f1b4a4d0 100644 --- a/Modules/Bar/Calendar/CalendarPanel.qml +++ b/Modules/Bar/Calendar/CalendarPanel.qml @@ -22,7 +22,7 @@ NPanel { anchors.margins: Style.marginL spacing: Style.marginM - readonly property int firstDayOfWeek: Qt.Monday // Always start week on Monday (use Qt.Sunday for Sunday, 6 for Saturday) + readonly property int firstDayOfWeek: Qt.locale().firstDayOfWeek property bool isCurrentMonth: checkIsCurrentMonth() readonly property bool weatherReady: Settings.data.location.weatherEnabled && (LocationService.data.weather !== null) @@ -278,7 +278,7 @@ NPanel { } } - // Weather forecast + // ... (rest of the file is unchanged) ... RowLayout { visible: weatherReady Layout.fillWidth: true @@ -462,90 +462,38 @@ NPanel { } } } - - // Calendar days grid - GridLayout { + MonthGrid { id: grid Layout.fillWidth: true Layout.fillHeight: true - columns: 7 - rowSpacing: Style.marginXXS - columnSpacing: Style.marginXXS - - property int month: Time.date.getMonth() - property int year: Time.date.getFullYear() - - Repeater { - model: 42 // 6 rows × 7 days - delegate: Item { - id: cellItem - Layout.fillWidth: true - Layout.fillHeight: true - - required property int index - - property int cellDay: { - let firstOfMonth = new Date(grid.year, grid.month, 1) - let firstDayOfWeek = content.firstDayOfWeek - let firstOfMonthDayOfWeek = firstOfMonth.getDay() - let daysBeforeFirst = (firstOfMonthDayOfWeek - firstDayOfWeek + 7) % 7 - let startDate = new Date(grid.year, grid.month, 1 - daysBeforeFirst) - let currentDate = new Date(startDate) - currentDate.setDate(startDate.getDate() + cellItem.index) - return currentDate.getDate() - } - - property int cellMonth: { - let firstOfMonth = new Date(grid.year, grid.month, 1) - let firstDayOfWeek = content.firstDayOfWeek - let firstOfMonthDayOfWeek = firstOfMonth.getDay() - let daysBeforeFirst = (firstOfMonthDayOfWeek - firstDayOfWeek + 7) % 7 - let startDate = new Date(grid.year, grid.month, 1 - daysBeforeFirst) - let currentDate = new Date(startDate) - currentDate.setDate(startDate.getDate() + cellItem.index) - return currentDate.getMonth() - } - - property int cellYear: { - let firstOfMonth = new Date(grid.year, grid.month, 1) - let firstDayOfWeek = content.firstDayOfWeek - let firstOfMonthDayOfWeek = firstOfMonth.getDay() - let daysBeforeFirst = (firstOfMonthDayOfWeek - firstDayOfWeek + 7) % 7 - let startDate = new Date(grid.year, grid.month, 1 - daysBeforeFirst) - let currentDate = new Date(startDate) - currentDate.setDate(startDate.getDate() + cellItem.index) - return currentDate.getFullYear() - } - - property bool isToday: cellDay === Time.date.getDate() && cellMonth === Time.date.getMonth() && cellYear === Time.date.getFullYear() - property bool isCurrentMonth: cellMonth === grid.month - - Rectangle { - width: Style.baseWidgetSize * 0.9 - height: Style.baseWidgetSize * 0.9 + spacing: Style.marginXXS + month: Time.date.getMonth() + year: Time.date.getFullYear() + locale: Qt.locale() + delegate: Item { + Rectangle { + width: Style.baseWidgetSize * 0.9 + height: Style.baseWidgetSize * 0.9 + anchors.centerIn: parent + radius: Style.radiusM + color: model.today ? Color.mSecondary : Color.transparent + NText { anchors.centerIn: parent - radius: Style.radiusM - color: parent.isToday ? Color.mSecondary : Color.transparent - - NText { - anchors.centerIn: parent - text: cellItem.cellDay - color: { - if (cellItem.isToday) - return Color.mOnSecondary - if (cellItem.isCurrentMonth) - return Color.mOnSurface - return Color.mOnSurfaceVariant - } - opacity: cellItem.isCurrentMonth ? 1.0 : 0.4 - pointSize: Style.fontSizeM - font.weight: cellItem.isToday ? Style.fontWeightBold : Style.fontWeightMedium + text: model.day + color: { + if (model.today) + return Color.mOnSecondary + if (model.month === grid.month) + return Color.mOnSurface + return Color.mOnSurfaceVariant } - - Behavior on color { - ColorAnimation { - duration: Style.animationFast - } + opacity: model.month === grid.month ? 1.0 : 0.4 + pointSize: Style.fontSizeM + font.weight: model.today ? Style.fontWeightBold : Style.fontWeightMedium + } + Behavior on color { + ColorAnimation { + duration: Style.animationFast } } } diff --git a/Modules/Settings/Tabs/GeneralTab.qml b/Modules/Settings/Tabs/GeneralTab.qml index 4f084445..40b5276d 100644 --- a/Modules/Settings/Tabs/GeneralTab.qml +++ b/Modules/Settings/Tabs/GeneralTab.qml @@ -204,24 +204,20 @@ ColumnLayout { Layout.fillWidth: true label: I18n.tr("settings.general.language.select.label") description: I18n.tr("settings.general.language.select.description") - model: [{ - "key": "", - "name": I18n.tr("settings.general.language.select.auto-detect") + " (" + I18n.systemDetectedLangCode + ")" - }].concat(I18n.availableLanguages.map(function (langCode) { - return { - "key": langCode, - "name": langCode - } - })) + model: [ + { "key": "", "name": I18n.tr("settings.general.language.select.auto-detect") + " (" + I18n.systemDetectedLangCode + ")" } + ].concat(I18n.availableLanguages.map(function(langCode) { + return { "key": langCode, "name": langCode } + })) currentKey: Settings.data.general.language onSelected: key => { - Settings.data.general.language = key - if (key === "") { - I18n.detectLanguage() // Re-detect system language if "Automatic" is selected - } else { - I18n.setLanguage(key) // Set specific language - } - } + Settings.data.general.language = key + if (key === "") { + I18n.detectLanguage() // Re-detect system language if "Automatic" is selected + } else { + I18n.setLanguage(key) // Set specific language + } + } } } diff --git a/Modules/Settings/Tabs/LocationTab.qml b/Modules/Settings/Tabs/LocationTab.qml index 0fb7f8a2..7b6c340b 100644 --- a/Modules/Settings/Tabs/LocationTab.qml +++ b/Modules/Settings/Tabs/LocationTab.qml @@ -117,27 +117,6 @@ ColumnLayout { checked: Settings.data.location.showWeekNumberInCalendar onToggled: checked => Settings.data.location.showWeekNumberInCalendar = checked } - - NComboBox { - label: I18n.tr("settings.location.date-time.first-day-of-week.label") - description: I18n.tr("settings.location.date-time.first-day-of-week.description") - minimumWidth: 220 * Style.uiScaleRatio - model: [{ - "key": "auto", - "name": I18n.tr("settings.location.date-time.first-day-of-week.auto") - }, { - "key": "monday", - "name": I18n.tr("settings.location.date-time.first-day-of-week.monday") - }, { - "key": "saturday", - "name": I18n.tr("settings.location.date-time.first-day-of-week.saturday") - }, { - "key": "sunday", - "name": I18n.tr("settings.location.date-time.first-day-of-week.sunday") - }] - currentKey: Settings.data.location.firstDayOfWeek - onSelected: key => Settings.data.location.firstDayOfWeek = key - } } NDivider {