working notifications

This commit is contained in:
lucy 2026-05-14 22:33:06 +02:00
commit e1504bfc92
5 changed files with 112 additions and 0 deletions

View file

@ -0,0 +1,44 @@
import Quickshell
import Quickshell.Widgets
import QtQuick.Layouts
import QtQuick
import qs
import qs.settings
import qs.widgets
WrapperRectangle {
id: root
required property var notification
implicitWidth: 300
implicitHeight: 100
radius: Config.rounding
anchors.right: parent?.right
color: Colors.base01
child: WrapperMouseArea {
RowLayout {
anchors.fill: parent
IconImage {
id: appIcon
Layout.leftMargin: 16
source: root.notification.image ? root.notification.image : ''
implicitSize: 48
}
ColumnLayout {
Layout.alignment: Qt.AlignLeft
StyledText {
id: title
text: root.notification?.summary == null ? '' : root.notification.summary
}
StyledText {
id: body
text: root.notification.body ? root.notification.body : ''
}
}
}
acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor
onClicked: {
root.notification.dismiss();
}
}
}

View file

@ -0,0 +1,46 @@
pragma ComponentBehavior: Bound
import Quickshell
import QtQuick
import Quickshell.Wayland
import qs.settings
import Quickshell.Hyprland
WlrLayershell {
id: notiPopup
property ShellScreen activeScreen: getActiveScreen()
function getActiveScreen() {
let current = Quickshell.screens[0];
for (let i = 0; i < Quickshell.screens.length; i++) {
current = Quickshell.screens[i];
if (Hyprland.monitorFor(current) == Hyprland.focusedMonitor) {
console.log(current.name);
return current;
}
}
return current;
}
exclusionMode: ExclusionMode.Ignore
layer: WlrLayer.Overlay
screen: activeScreen
anchors {
top: true
right: true
}
margins.top: Config.barHeight + 8
margins.right: 8
implicitHeight: notiList.contentHeight
implicitWidth: activeScreen.width / 8
color: 'transparent'
visible: NotiServer.notifications.values.length > 0
ListView {
id: notiList
anchors.fill: parent
model: NotiServer.notifications
spacing: 6
delegate: NotiCard {
required property var modelData
notification: modelData
}
}
}

View file

@ -0,0 +1,17 @@
pragma Singleton
import Quickshell
import Quickshell.Services.Notifications
import QtQuick
Singleton {
id: root
property alias notifications: server.trackedNotifications
NotificationServer {
id: server
imageSupported: true
bodyImagesSupported: true
onNotification: notification => {
notification.tracked = true;
}
}
}

View file

@ -0,0 +1,3 @@
singleton NotiServer 1.0 NotiServer.qml
NotiPopup 1.0 NotiPopup.qml
NotiCard 1.0 NotiCard.qml