diff --git a/modules/notifications/NotiCard.qml b/modules/notifications/NotiCard.qml new file mode 100644 index 0000000..07ca59c --- /dev/null +++ b/modules/notifications/NotiCard.qml @@ -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(); + } + } +} diff --git a/modules/notifications/NotiPopup.qml b/modules/notifications/NotiPopup.qml new file mode 100644 index 0000000..dbef813 --- /dev/null +++ b/modules/notifications/NotiPopup.qml @@ -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 + } + } +} diff --git a/modules/notifications/NotiServer.qml b/modules/notifications/NotiServer.qml new file mode 100644 index 0000000..7ecc639 --- /dev/null +++ b/modules/notifications/NotiServer.qml @@ -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; + } + } +} diff --git a/modules/notifications/qmldir b/modules/notifications/qmldir new file mode 100644 index 0000000..d1c7785 --- /dev/null +++ b/modules/notifications/qmldir @@ -0,0 +1,3 @@ +singleton NotiServer 1.0 NotiServer.qml +NotiPopup 1.0 NotiPopup.qml +NotiCard 1.0 NotiCard.qml diff --git a/shell.qml b/shell.qml index 8a4962c..209b9ef 100644 --- a/shell.qml +++ b/shell.qml @@ -4,9 +4,11 @@ import qs.modules.bar import qs.modules.ipc import qs.modules.wallpaper import qs.settings +import qs.modules.notifications ShellRoot { Bar {} Ipc {} Wallpaper {} + NotiPopup {} }