Notifications WIP

This commit is contained in:
Amaro Lopes
2025-10-07 17:11:20 -03:00
parent c66d043ece
commit d9406f2a90
9 changed files with 326 additions and 79 deletions

View File

@@ -0,0 +1,66 @@
pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Services.Notifications
import Quickshell.Widgets
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") {
notif.dismiss();
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: currentNotification && shouldShowOsd
component: NotificationPopup {
notification: currentNotification
// No signal handler here!
}
onItemChanged: {
if (item) {
item.dismissed.connect(function() {
notificationRoot.shouldShowOsd = false
currentNotification.dismiss()
})
}
}
}
}

View File

@@ -1,28 +0,0 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Services.Notifications
Singleton {
id: notificationsRoot
NotificationServer {
id: nServer
imageSupported: true
}
Connections {
function onNotification(rapazinho) {
console.log(rapazinho.id)
console.log(nServer.trackedNotifications)
}
target: nServer
}
property var tracked: nServer.trackedNotifications
}