Files
arthur-os/shell/plugins/bar/widgets/daytime.qml
T
David Heinemeier Hansson 16604c67b3 Lift setting / vertical / barSize onto BarWidget
Six widgets (clock, daytime, keyboardLayout, lockKeys, activeWindow,
media) shipped identical copies of `function setting(name, fallback)`.
Eight widgets reimplemented `readonly property bool vertical`, and
three reimplemented `readonly property int barSize`. Move all three
onto the BarWidget base so widgets read the same wiring everyone else
gets for free.

While in here, drop the dead `setting()` declaration on media.qml — it
was defined but never called.
2026-05-20 19:50:10 +02:00

44 lines
912 B
QML

import QtQuick
import Quickshell
import qs.Commons
import qs.Ui
BarWidget {
id: root
moduleName: "daytime"
property date now: new Date()
function formatLabel() {
if (!bar) return ""
var fmt = bar.vertical
? String(setting("verticalFormat", "HH\n—\nmm"))
: String(setting("format", "dddd HH:mm"))
return Qt.formatDateTime(now, fmt)
}
function tooltipLabel() {
return Qt.formatDateTime(root.now, String(setting("formatAlt", "dd MMMM yyyy")))
}
implicitWidth: button.implicitWidth
implicitHeight: button.implicitHeight
SystemClock {
id: clockTimer
precision: SystemClock.Minutes
onDateChanged: root.now = clockTimer.date
}
WidgetButton {
id: button
anchors.fill: parent
bar: root.bar
text: root.formatLabel()
horizontalMargin: 8.75
verticalPadding: 8.75
tooltipText: root.tooltipLabel()
pressable: false
}
}