mirror of
https://github.com/AquaMorph/dotfiles.git
synced 2026-09-29 20:04:21 +00:00
feat(quickshell): toggle clock seconds display
This commit is contained in:
@@ -14,6 +14,13 @@ PanelWindow {
|
||||
property var battery: UPower.displayDevice
|
||||
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 {
|
||||
top: true
|
||||
left: true
|
||||
@@ -251,10 +258,12 @@ PanelWindow {
|
||||
|
||||
Block {
|
||||
id: clockBlock
|
||||
property bool showSeconds: false
|
||||
|
||||
interactive: true
|
||||
text: Qt.formatDateTime(clock.date, "hh:mm")
|
||||
text: bar.formatClock(clock.date, showSeconds)
|
||||
onClicked: detailsPopup.toggle("clock", clockBlock)
|
||||
onDoubleClicked: showSeconds = !showSeconds
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ Rectangle {
|
||||
property string secondaryIcon: ""
|
||||
property string secondaryText: ""
|
||||
signal clicked(var mouse)
|
||||
signal doubleClicked(var mouse)
|
||||
signal wheel(var wheel)
|
||||
|
||||
implicitWidth: content.implicitWidth + 20
|
||||
@@ -54,6 +55,7 @@ Rectangle {
|
||||
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: mouse => root.clicked(mouse)
|
||||
onDoubleClicked: mouse => root.doubleClicked(mouse)
|
||||
onWheel: wheel => root.wheel(wheel)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ PopupWindow {
|
||||
top: parent.top
|
||||
topMargin: 40
|
||||
}
|
||||
text: Qt.formatDateTime(parent.now, "hh:mm:ss")
|
||||
text: Qt.formatDateTime(parent.now, "h:mm:ss AP")
|
||||
color: "#ffffff"
|
||||
font.family: "SF Pro Display, Helvetica, Arial, sans-serif"
|
||||
font.pixelSize: 30
|
||||
|
||||
Reference in New Issue
Block a user