Notifications WIP
This commit is contained in:
66
Services/NotificationService.qml
Normal file
66
Services/NotificationService.qml
Normal 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()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user