90 lines
2.0 KiB
QML
90 lines
2.0 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import ".."
|
|
|
|
// Date + time widget. Click it to open/close the calendar popup.
|
|
// barWindow must be set by the parent (Bar.qml) so the popup has a Wayland parent.
|
|
|
|
RowLayout {
|
|
id: root
|
|
|
|
required property var barWindow
|
|
|
|
spacing: 8
|
|
implicitHeight: 32
|
|
|
|
CalendarPopup {
|
|
id: cal
|
|
|
|
anchor.window: root.barWindow
|
|
anchor.item: root
|
|
anchor.edges: Edges.Bottom | Edges.Right
|
|
anchor.gravity: Edges.Bottom | Edges.Left
|
|
}
|
|
|
|
// Full-screen transparent overlay: captures outside clicks and Escape to close calendar.
|
|
// WlrLayershell.keyboardFocus: Exclusive gives it real keyboard focus from the compositor.
|
|
PanelWindow {
|
|
visible: cal.visible
|
|
screen: root.barWindow.screen
|
|
color: "transparent"
|
|
exclusionMode: ExclusionMode.Ignore
|
|
anchors { top: true; bottom: true; left: true; right: true }
|
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
|
|
|
TapHandler {
|
|
onTapped: cal.close()
|
|
}
|
|
|
|
Item {
|
|
focus: true
|
|
Keys.onEscapePressed: cal.close()
|
|
}
|
|
}
|
|
|
|
Text {
|
|
id: dateLabel
|
|
color: Colors.fg
|
|
font.pixelSize: 13
|
|
}
|
|
|
|
Text {
|
|
text: "|"
|
|
color: Colors.fgDim
|
|
font.pixelSize: 13
|
|
}
|
|
|
|
Text {
|
|
id: timeLabel
|
|
color: Colors.fg
|
|
font.pixelSize: 13
|
|
font.weight: Font.Medium
|
|
Behavior on color {
|
|
ColorAnimation {
|
|
duration: 80
|
|
}
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
interval: 15000
|
|
running: true
|
|
repeat: true
|
|
triggeredOnStart: true
|
|
onTriggered: {
|
|
const now = new Date();
|
|
const de = Qt.locale("de_DE");
|
|
dateLabel.text = now.toLocaleDateString(de, "ddd, d. MMM");
|
|
timeLabel.text = Qt.formatTime(now, "HH:mm");
|
|
}
|
|
}
|
|
|
|
TapHandler {
|
|
onTapped: cal.visible ? cal.close() : cal.open()
|
|
}
|
|
}
|