nosignal-shell/modules/bar/components/Clock.qml
2026-04-22 22:47:18 +10:00

69 lines
1.9 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import Caelestia.Config
import qs.components
import qs.services
StyledRect {
id: root
readonly property color colour: Colours.palette.m3tertiary
readonly property int padding: Config.bar.clock.background ? Tokens.padding.medium : Tokens.padding.extraSmall
implicitWidth: Tokens.sizes.bar.innerWidth
implicitHeight: layout.implicitHeight + root.padding * 2
color: Qt.alpha(Colours.tPalette.m3surfaceContainer, Config.bar.clock.background ? Colours.tPalette.m3surfaceContainer.a : 0)
radius: Tokens.rounding.full
Column {
id: layout
anchors.centerIn: parent
spacing: Tokens.spacing.small
Loader {
asynchronous: true
anchors.horizontalCenter: parent.horizontalCenter
active: Config.bar.clock.showIcon
visible: active
sourceComponent: MaterialIcon {
text: "calendar_month"
color: root.colour
}
}
StyledText {
anchors.horizontalCenter: parent.horizontalCenter
visible: Config.bar.clock.showDate
horizontalAlignment: StyledText.AlignHCenter
text: Time.format("ddd\nd")
font: Tokens.font.body.small
color: root.colour
}
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
visible: Config.bar.clock.showDate
height: visible ? 1 : 0
width: parent.width * 0.8
color: root.colour
opacity: 0.2
}
StyledText {
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: StyledText.AlignHCenter
text: Time.format(GlobalConfig.services.useTwelveHourClock ? "hh\nmm\nA" : "hh\nmm")
font: Tokens.font.mono.small
color: root.colour
}
}
}