From feed6e905cfc616bdac3ead1687c1b686e96f38f Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Sun, 5 Oct 2025 14:13:46 -0400 Subject: [PATCH] Calendar: added support for 12 hours format. --- Assets/Translations/de.json | 4 ++-- Assets/Translations/en.json | 2 +- Assets/Translations/es.json | 4 ++-- Assets/Translations/fr.json | 2 +- Assets/Translations/pt.json | 4 ++-- Assets/Translations/zh-CN.json | 4 ++-- Modules/Bar/Calendar/CalendarPanel.qml | 26 +++++++++++++++----------- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Assets/Translations/de.json b/Assets/Translations/de.json index 70079385..ec708fff 100644 --- a/Assets/Translations/de.json +++ b/Assets/Translations/de.json @@ -610,8 +610,8 @@ "description": "Anpassen, wie Datum und Zeit erscheinen." }, "12hour-format": { - "label": "12-Stunden-Zeitformat auf dem Sperrbildschirm verwenden", - "description": "An für AM/PM-Format (z.B. 8:00 PM), aus für 24-Stunden-Format (z.B. 20:00)." + "description": "An für AM/PM-Format (z.B. 8:00 PM), aus für 24-Stunden-Format (z.B. 20:00).", + "label": "Benutze das 12-Stunden-Zeitformat." }, "week-numbers": { "label": "Wochennummern anzeigen", diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 8aa238bf..fbf29280 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -608,7 +608,7 @@ "description": "Customize how date and time appear." }, "12hour-format": { - "label": "Use 12-hour time format on the lock screen", + "label": "Use 12-hour time format.", "description": "On for AM/PM format (e.g., 8:00 PM), off for 24-hour format (e.g., 20:00)." }, "week-numbers": { diff --git a/Assets/Translations/es.json b/Assets/Translations/es.json index c0f69fb6..ac13c55f 100644 --- a/Assets/Translations/es.json +++ b/Assets/Translations/es.json @@ -606,8 +606,8 @@ "description": "Personaliza cómo aparecen la fecha y la hora." }, "12hour-format": { - "label": "Usar formato de 12 horas en la pantalla de bloqueo", - "description": "Activado para formato AM/PM (ej., 8:00 PM), desactivado para formato de 24 horas (ej., 20:00)." + "description": "Activado para formato AM/PM (ej., 8:00 PM), desactivado para formato de 24 horas (ej., 20:00).", + "label": "Utilice el formato de hora de 12 horas." }, "week-numbers": { "label": "Mostrar números de semana", diff --git a/Assets/Translations/fr.json b/Assets/Translations/fr.json index d2df99a3..31d6cf66 100644 --- a/Assets/Translations/fr.json +++ b/Assets/Translations/fr.json @@ -606,7 +606,7 @@ "description": "Personnalisez l'affichage de la date et de l'heure." }, "12hour-format": { - "label": "Utiliser le format horaire de 12 heures sur l'écran de verrouillage", + "label": "Utiliser le format horaire de 12 heures", "description": "Activé pour le format AM/PM (ex: 8:00 PM), désactivé pour le format 24 heures (ex: 20:00)." }, "week-numbers": { diff --git a/Assets/Translations/pt.json b/Assets/Translations/pt.json index 1f6a20d2..16c05998 100644 --- a/Assets/Translations/pt.json +++ b/Assets/Translations/pt.json @@ -572,8 +572,8 @@ "description": "Personalize como a data e a hora aparecem." }, "12hour-format": { - "label": "Usar formato de 12 horas na tela de bloqueio", - "description": "Ativado para formato AM/PM (ex., 8:00 PM), desativado para formato de 24 horas (ex., 20:00)." + "description": "Ativado para formato AM/PM (ex., 8:00 PM), desativado para formato de 24 horas (ex., 20:00).", + "label": "Use o formato de hora de 12 horas." }, "week-numbers": { "label": "Mostrar números da semana", diff --git a/Assets/Translations/zh-CN.json b/Assets/Translations/zh-CN.json index b37eb7ce..dc1925a7 100644 --- a/Assets/Translations/zh-CN.json +++ b/Assets/Translations/zh-CN.json @@ -606,8 +606,8 @@ "description": "自定义日期和时间的显示方式。" }, "12hour-format": { - "label": "在锁屏上使用 12 小时制", - "description": "开启为 AM/PM 格式(例如:8:00 PM),关闭为 24 小时制(例如:20:00)。" + "description": "开启为 AM/PM 格式(例如:8:00 PM),关闭为 24 小时制(例如:20:00)。", + "label": "使用 12 小时制时间格式。" }, "week-numbers": { "label": "显示周数", diff --git a/Modules/Bar/Calendar/CalendarPanel.qml b/Modules/Bar/Calendar/CalendarPanel.qml index fc6a419a..55747538 100644 --- a/Modules/Bar/Calendar/CalendarPanel.qml +++ b/Modules/Bar/Calendar/CalendarPanel.qml @@ -95,9 +95,15 @@ NPanel { anchors.fill: parent property real progress: Time.date.getSeconds() / 60 - onProgressChanged: requestPaint() + Connections { + target: Time + function onDateChanged() { + secondsProgress.progress = Time.date.getSeconds() / 60 + } + } + onPaint: { var ctx = getContext("2d") var centerX = width / 2 @@ -122,22 +128,20 @@ NPanel { ctx.stroke() } - Connections { - target: Time - function onDateChanged() { - secondsProgress.progress = (Time.date.getSeconds() + Time.date.getMilliseconds() / 1000) / 60 - } - } + } // Digital clock ColumnLayout { anchors.centerIn: parent - spacing: -2 * scaling + spacing: -3 * scaling NText { - text: Qt.formatTime(Time.date, "HH") - pointSize: Style.fontSizeL * 0.7 * scaling + text: { + var t = Settings.data.location.use12hourFormat ? Qt.locale().toString(new Date(), "hh AP") : Qt.locale().toString(new Date(), "HH") + return t.split(" ")[0] + } + pointSize: Style.fontSizeS * scaling font.weight: Style.fontWeightBold color: Color.mOnPrimary family: Settings.data.ui.fontFixed @@ -146,7 +150,7 @@ NPanel { NText { text: Qt.formatTime(Time.date, "mm") - pointSize: Style.fontSizeL * 0.7 * scaling + pointSize: Style.fontSizeS * scaling font.weight: Style.fontWeightBold color: Color.mOnPrimary family: Settings.data.ui.fontFixed