feat(quickshell): toggle clock seconds display

This commit is contained in:
2026-09-25 17:23:53 -04:00
parent c31b2486e3
commit 1a9d6a6a78
3 changed files with 13 additions and 2 deletions
+10 -1
View File
@@ -14,6 +14,13 @@ PanelWindow {
property var battery: UPower.displayDevice property var battery: UPower.displayDevice
property var hardware property var hardware
function formatClock(date, includeSeconds) {
const hour = date.getHours() % 12 || 12;
const minute = date.getMinutes().toString().padStart(2, "0");
const second = date.getSeconds().toString().padStart(2, "0");
return hour + ":" + minute + (includeSeconds ? ":" + second : "");
}
anchors { anchors {
top: true top: true
left: true left: true
@@ -251,10 +258,12 @@ PanelWindow {
Block { Block {
id: clockBlock id: clockBlock
property bool showSeconds: false
interactive: true interactive: true
text: Qt.formatDateTime(clock.date, "hh:mm") text: bar.formatClock(clock.date, showSeconds)
onClicked: detailsPopup.toggle("clock", clockBlock) onClicked: detailsPopup.toggle("clock", clockBlock)
onDoubleClicked: showSeconds = !showSeconds
} }
} }
} }
+2
View File
@@ -12,6 +12,7 @@ Rectangle {
property string secondaryIcon: "" property string secondaryIcon: ""
property string secondaryText: "" property string secondaryText: ""
signal clicked(var mouse) signal clicked(var mouse)
signal doubleClicked(var mouse)
signal wheel(var wheel) signal wheel(var wheel)
implicitWidth: content.implicitWidth + 20 implicitWidth: content.implicitWidth + 20
@@ -54,6 +55,7 @@ Rectangle {
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: mouse => root.clicked(mouse) onClicked: mouse => root.clicked(mouse)
onDoubleClicked: mouse => root.doubleClicked(mouse)
onWheel: wheel => root.wheel(wheel) onWheel: wheel => root.wheel(wheel)
} }
} }
@@ -112,7 +112,7 @@ PopupWindow {
top: parent.top top: parent.top
topMargin: 40 topMargin: 40
} }
text: Qt.formatDateTime(parent.now, "hh:mm:ss") text: Qt.formatDateTime(parent.now, "h:mm:ss AP")
color: "#ffffff" color: "#ffffff"
font.family: "SF Pro Display, Helvetica, Arial, sans-serif" font.family: "SF Pro Display, Helvetica, Arial, sans-serif"
font.pixelSize: 30 font.pixelSize: 30