Something went wrong. Try again.
Something went wrong. Try again.
3.0 kB · 109 lines
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110pragma ComponentBehavior: Bound
import "../components"import "../popups"import QtQuickimport Quickshell
Item { id: root
required property var barWindow property var ipc: null property bool popupIpcEnabled: true property bool alternativeMode: false property bool popupOpen: false property bool popupPinned: false readonly property CalendarPopup calendar: calendarLoader.item as CalendarPopup signal alternativeModeToggled
function updateHover() { if (pill.hovered || popupHover.hovered || popupPinned) { hideDelay.stop(); popupOpen = true; } else { hideDelay.restart(); } }
implicitWidth: pill.implicitWidth implicitHeight: pill.implicitHeight
SystemClock { id: clock
precision: SystemClock.Minutes }
Timer { id: hideDelay interval: 300 // Allow the pointer to cross the gap below the bar. onTriggered: { if (!pill.hovered && !popupHover.hovered && !root.popupPinned) root.popupOpen = false; } }
ModulePill { id: pill
barWindow: root.barWindow text: Qt.formatDateTime(clock.date, "hh:mm") + " " moduleClass: root.alternativeMode ? "warning" : "" onHoveredChanged: root.updateHover() onClicked: button => { if (button === Qt.MiddleButton) { root.alternativeModeToggled(); root.popupPinned = false; root.popupOpen = false; } else { root.popupPinned = !root.popupPinned; root.updateHover(); } } }
Connections { target: root.ipc function onRefreshRequested(name) { if ((name === "calendar" || name === "all") && root.calendar) root.calendar.refresh(); } function onPopupRequested(name) { if (name === "calendar" && root.popupIpcEnabled) { root.popupPinned = !root.popupPinned; root.updateHover(); } } }
PopupWindow { anchor.window: root.barWindow anchor.rect.x: root.barWindow ? root.barWindow.width - width - 8 : 0 anchor.rect.y: root.barWindow ? root.barWindow.height + 8 : 0 implicitWidth: 380 implicitHeight: root.calendar ? root.calendar.implicitHeight : 500 color: "transparent" visible: root.popupOpen grabFocus: false onVisibleChanged: { if (!visible) { root.popupOpen = false; root.popupPinned = false; } }
Loader { id: calendarLoader anchors.fill: parent active: root.popupOpen HoverHandler { id: popupHover onHoveredChanged: root.updateHover() } sourceComponent: CalendarPopup { today: clock.date } } }}