From a55d232b9ab98ae1d779add3fa82e1ccf0312d2a Mon Sep 17 00:00:00 2001 From: Damocles Date: Sat, 18 Apr 2026 10:19:45 +0200 Subject: [PATCH] color lock screen clock with accent colors per segment --- shell/lock/LockClock.qml | 48 ++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/shell/lock/LockClock.qml b/shell/lock/LockClock.qml index b3dba90..ef3671b 100644 --- a/shell/lock/LockClock.qml +++ b/shell/lock/LockClock.qml @@ -6,6 +6,8 @@ Item { required property real screenHeight + readonly property real _fontSize: Math.max(48, screenHeight * 0.28) + opacity: 0 property real _slideX: -80 @@ -30,19 +32,47 @@ Item { rotation: -90 transformOrigin: Item.Center - Text { - id: _clockText - text: Qt.formatTime(new Date(), "HH:mm") - color: S.Theme.base05 - font.pixelSize: Math.max(48, root.screenHeight * 0.28) - font.family: S.Theme.fontFamily - font.bold: true + Row { + id: _clockRow + + property string _hours: "" + property string _minutes: "" + + function _update() { + const now = new Date(); + _hours = Qt.formatTime(now, "HH"); + _minutes = Qt.formatTime(now, "mm"); + } + + Component.onCompleted: _update() Timer { interval: 1000 running: true repeat: true - onTriggered: parent.text = Qt.formatTime(new Date(), "HH:mm") + onTriggered: _clockRow._update() + } + + Text { + text: _clockRow._hours + color: S.Theme.base0C + font.pixelSize: root._fontSize + font.family: S.Theme.fontFamily + font.bold: true + } + Text { + text: ":" + color: S.Theme.base0E + font.pixelSize: root._fontSize + font.family: S.Theme.fontFamily + font.bold: true + } + Text { + text: _clockRow._minutes + color: S.Theme.base09 + font.pixelSize: root._fontSize + font.family: S.Theme.fontFamily + font.bold: true } } @@ -61,5 +91,5 @@ Item { } } - implicitWidth: _clockText.height + implicitWidth: _clockRow.height }