summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2026-01-20 20:53:34 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2026-01-20 20:53:34 +1100
commit685ad569a3d362c1b02cd2d26862059889232c9b (patch)
tree44d991f9da1429800777b56c265d516ddcf6272c
parentcontrolcenter: add per-application audio controls (#1098) (diff)
downloadcaelestia-shell-685ad569a3d362c1b02cd2d26862059889232c9b.tar.gz
caelestia-shell-685ad569a3d362c1b02cd2d26862059889232c9b.tar.bz2
caelestia-shell-685ad569a3d362c1b02cd2d26862059889232c9b.zip
background: fix desktop clock 12h format
-rw-r--r--modules/background/DesktopClock.qml23
-rw-r--r--modules/dashboard/dash/DateTime.qml8
-rw-r--r--modules/lock/Center.qml7
-rw-r--r--services/Time.qml8
4 files changed, 28 insertions, 18 deletions
diff --git a/modules/background/DesktopClock.qml b/modules/background/DesktopClock.qml
index a6b05c2..77fe447 100644
--- a/modules/background/DesktopClock.qml
+++ b/modules/background/DesktopClock.qml
@@ -79,7 +79,7 @@ Item {
spacing: Appearance.spacing.small
StyledText {
- text: Time.format(Config.services.useTwelveHourClock ? "hh" : "HH")
+ text: Time.hourStr
font.pointSize: Appearance.font.size.extraLarge * 3 * root.scale
font.weight: Font.Bold
color: root.safePrimary
@@ -94,19 +94,24 @@ Item {
}
StyledText {
- text: Time.format("mm")
+ text: Time.minuteStr
font.pointSize: Appearance.font.size.extraLarge * 3 * root.scale
font.weight: Font.Bold
color: root.safeSecondary
}
- StyledText {
- visible: Config.services.useTwelveHourClock
- text: Time.format("A")
- font.pointSize: Appearance.font.size.large * root.scale
- color: root.safeSecondary
+ Loader {
Layout.alignment: Qt.AlignTop
Layout.topMargin: Appearance.padding.large * 1.4 * root.scale
+
+ active: Config.services.useTwelveHourClock
+ visible: active
+
+ sourceComponent: StyledText {
+ text: Time.amPmStr
+ font.pointSize: Appearance.font.size.large * root.scale
+ color: root.safeSecondary
+ }
}
}
@@ -155,10 +160,10 @@ Item {
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
}
}
-
+
Behavior on implicitWidth {
Anim {
duration: Appearance.anim.durations.small
}
}
-} \ No newline at end of file
+}
diff --git a/modules/dashboard/dash/DateTime.qml b/modules/dashboard/dash/DateTime.qml
index d80acd4..e740448 100644
--- a/modules/dashboard/dash/DateTime.qml
+++ b/modules/dashboard/dash/DateTime.qml
@@ -9,8 +9,6 @@ import QtQuick.Layouts
Item {
id: root
- readonly property list<string> timeComponents: Time.format(Config.services.useTwelveHourClock ? "hh:mm:A" : "hh:mm").split(":")
-
anchors.top: parent.top
anchors.bottom: parent.bottom
implicitWidth: Config.dashboard.sizes.dateTimeWidth
@@ -24,7 +22,7 @@ Item {
StyledText {
Layout.bottomMargin: -(font.pointSize * 0.4)
Layout.alignment: Qt.AlignHCenter
- text: root.timeComponents[0]
+ text: Time.hourStr
color: Colours.palette.m3secondary
font.pointSize: Appearance.font.size.extraLarge
font.family: Appearance.font.family.clock
@@ -42,7 +40,7 @@ Item {
StyledText {
Layout.topMargin: -(font.pointSize * 0.4)
Layout.alignment: Qt.AlignHCenter
- text: root.timeComponents[1]
+ text: Time.minuteStr
color: Colours.palette.m3secondary
font.pointSize: Appearance.font.size.extraLarge
font.family: Appearance.font.family.clock
@@ -56,7 +54,7 @@ Item {
visible: active
sourceComponent: StyledText {
- text: root.timeComponents[2] ?? ""
+ text: Time.amPmStr
color: Colours.palette.m3primary
font.pointSize: Appearance.font.size.large
font.family: Appearance.font.family.clock
diff --git a/modules/lock/Center.qml b/modules/lock/Center.qml
index e37207a..19cf9d2 100644
--- a/modules/lock/Center.qml
+++ b/modules/lock/Center.qml
@@ -13,7 +13,6 @@ ColumnLayout {
id: root
required property var lock
- readonly property list<string> timeComponents: Time.format(Config.services.useTwelveHourClock ? "hh:mm:A" : "hh:mm").split(":")
readonly property real centerScale: Math.min(1, (lock.screen?.height ?? 1440) / 1440)
readonly property int centerWidth: Config.lock.sizes.centerWidth * centerScale
@@ -29,7 +28,7 @@ ColumnLayout {
StyledText {
Layout.alignment: Qt.AlignVCenter
- text: root.timeComponents[0]
+ text: Time.hourStr
color: Colours.palette.m3secondary
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 3 * root.centerScale)
font.family: Appearance.font.family.clock
@@ -47,7 +46,7 @@ ColumnLayout {
StyledText {
Layout.alignment: Qt.AlignVCenter
- text: root.timeComponents[1]
+ text: Time.minuteStr
color: Colours.palette.m3secondary
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 3 * root.centerScale)
font.family: Appearance.font.family.clock
@@ -62,7 +61,7 @@ ColumnLayout {
visible: active
sourceComponent: StyledText {
- text: root.timeComponents[2] ?? ""
+ text: Time.amPmStr
color: Colours.palette.m3primary
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 2 * root.centerScale)
font.family: Appearance.font.family.clock
diff --git a/services/Time.qml b/services/Time.qml
index c4b3913..a07d9ef 100644
--- a/services/Time.qml
+++ b/services/Time.qml
@@ -1,6 +1,8 @@
pragma Singleton
+import qs.config
import Quickshell
+import QtQuick
Singleton {
property alias enabled: clock.enabled
@@ -9,6 +11,12 @@ Singleton {
readonly property int minutes: clock.minutes
readonly property int seconds: clock.seconds
+ readonly property string timeStr: format(Config.services.useTwelveHourClock ? "hh:mm:A" : "hh:mm")
+ readonly property list<string> timeComponents: timeStr.split(":")
+ readonly property string hourStr: timeComponents[0] ?? ""
+ readonly property string minuteStr: timeComponents[1] ?? ""
+ readonly property string amPmStr: timeComponents[2] ?? ""
+
function format(fmt: string): string {
return Qt.formatDateTime(clock.date, fmt);
}