Files
Quickbar/Services/NotificationService.qml
2025-10-08 20:18:51 -03:00

76 lines
2.0 KiB
QML

pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Services.Notifications
import qs.Widgets
Singleton {
id: notificationRoot
readonly property var notificationServer: notificationServer
readonly property var trackedNotifications: notificationServer.trackedNotifications
readonly property var notificationsNumber: notificationServer.trackedNotifications.values.length
property bool shouldShowOsd: false
property var currentNotification: null
NotificationServer {
id: notificationServer
imageSupported: true
}
Connections {
function onNotification(notif) {
if (notif.body == "MediaOngoingActivity") {
return;
}
if (notif.tracked) {
return;
}
notif.tracked = true;
notificationRoot.currentNotification = notif;
notificationRoot.shouldShowOsd = true;
notificationTimer.start();
}
target: notificationServer
}
Timer {
id: notificationTimer
interval: 5000
onTriggered: parent.shouldShowOsd = false
}
LazyLoader {
id: popupLoader
active: notificationRoot.currentNotification && notificationRoot.shouldShowOsd
component: PanelWindow {
id: notificationWindow
anchors.top: true
margins.top: screen.height / 100
exclusiveZone: 0
implicitWidth: 400
implicitHeight: 905
color: "transparent"
NotificationWrapper {
id: notificationWrapper
notification: notificationRoot.currentNotification
implicitWidth: notificationWindow.implicitWidth
onDismissed: {
notificationRoot.shouldShowOsd = false;
notificationRoot.currentNotification.dismiss();
}
}
}
}
}