nova-shell/shell/lock/LockClock.qml

93 lines
2.6 KiB
QML

import QtQuick
import "../services" as S
Item {
id: root
required property real screenHeight
property real wavePhase: 0
property real unlockFade: 1
readonly property real _fontSize: Math.max(48, screenHeight * 0.28)
// Appear as wave reaches the clock (left edge), latch once fully revealed.
// With reducedMotion the wave never runs, so show immediately.
property bool _revealed: false
on_RawProgressChanged: if (_rawProgress >= 1)
_revealed = true
readonly property real _rawProgress: S.Theme.reducedMotion ? 1 : Math.max(0, Math.min(1, wavePhase / 300))
readonly property real _progress: (_revealed ? 1 : _rawProgress) * unlockFade
opacity: _progress
property real _slideX: (1 - _progress) * -80
transform: Translate {
x: root._slideX
}
Column {
anchors.centerIn: parent
spacing: 8
rotation: -90
transformOrigin: Item.Center
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: _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
}
}
Text {
text: Qt.formatDate(new Date(), "dddd, d MMMM")
color: S.Theme.base04
font.pixelSize: S.Theme.fontSize + 2
font.family: S.Theme.fontFamily
Timer {
interval: 60000
running: true
repeat: true
onTriggered: parent.text = Qt.formatDate(new Date(), "dddd, d MMMM")
}
}
}
implicitWidth: _clockRow.height
}