working notifications
This commit is contained in:
parent
cf4696fe04
commit
e1504bfc92
5 changed files with 112 additions and 0 deletions
44
modules/notifications/NotiCard.qml
Normal file
44
modules/notifications/NotiCard.qml
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
46
modules/notifications/NotiPopup.qml
Normal file
46
modules/notifications/NotiPopup.qml
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
17
modules/notifications/NotiServer.qml
Normal file
17
modules/notifications/NotiServer.qml
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
modules/notifications/qmldir
Normal file
3
modules/notifications/qmldir
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
singleton NotiServer 1.0 NotiServer.qml
|
||||
NotiPopup 1.0 NotiPopup.qml
|
||||
NotiCard 1.0 NotiCard.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 {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue