repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
quickshell/nugu/NotificationToast.qml
Rawimport QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Services.Notifications
import Quickshell.Wayland
PanelWindow {
id: root
required property QtObject theme
required property var notification
required property int stackIndex
signal dismissRequested(var notification)
// Match Mako's top-right overlay geometry while keeping the daemon isolated
// from the bar; notification replacement must be visually comparable first.
anchors { top: true; right: true }
margins { top: 14 + stackIndex * 174; right: 14 }
exclusiveZone: -1
implicitWidth: 360
implicitHeight: 160
color: "transparent"
WlrLayershell {
layer: WlrLayer.Overlay
exclusiveZone: -1
}
function semanticBorder(): string {
const summary = notification ? notification.summary : ""
if (!notification) return theme.ui.accent
if (notification.urgency === NotificationUrgency.Critical || /[Ee]rror|[Ff]ailed|[Ff]ailure|[Cc]rash/.test(summary)) return theme.error
if (/[Ww]arn|[Ww]arning/.test(summary)) return theme.warning
if (/[Ii]nfo|[Nn]otice/.test(summary)) return theme.info
return theme.ui.accent
}
Rectangle {
anchors.fill: parent
radius: 12
color: notification && notification.urgency === NotificationUrgency.Low ? `${root.theme.content.backdrop}e6` : `${root.theme.ui.backdrop}f2`
border.width: notification && notification.urgency === NotificationUrgency.Critical ? 3 : 2
border.color: root.semanticBorder()
clip: true
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
onClicked: mouse => {
if (mouse.button === Qt.LeftButton && root.notification && root.notification.actions.length > 0) {
root.notification.actions[0].invoke()
}
root.dismissRequested(root.notification)
}
}
RowLayout {
anchors.fill: parent
anchors.margins: 12
spacing: 10
Rectangle {
Layout.preferredWidth: 48
Layout.preferredHeight: 48
Layout.alignment: Qt.AlignTop
radius: 7
color: root.theme.ui.focus
visible: (root.notification && (root.notification.image.length > 0 || root.notification.appIcon.length > 0))
Image {
anchors.fill: parent
anchors.margins: 3
source: root.notification ? (root.notification.image || root.notification.appIcon) : ""
fillMode: Image.PreserveAspectFit
asynchronous: true
}
}
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 4
Text {
Layout.fillWidth: true
text: root.notification ? root.notification.appName : ""
color: root.theme.ui.minor
font.family: "IBM Plex Sans"
font.pixelSize: 10
elide: Text.ElideRight
}
Text {
Layout.fillWidth: true
text: root.notification ? root.notification.summary : ""
color: root.theme.ui.important_global
font.family: "IBM Plex Sans"
font.pixelSize: 10
font.bold: true
elide: Text.ElideRight
maximumLineCount: 1
}
Text {
Layout.fillWidth: true
Layout.fillHeight: true
text: root.notification ? root.notification.body : ""
color: root.theme.ui.normal
font.family: "IBM Plex Sans"
font.pixelSize: 10
wrapMode: Text.Wrap
elide: Text.ElideRight
maximumLineCount: 3
textFormat: Text.RichText
visible: text.length > 0
}
RowLayout {
Layout.fillWidth: true
visible: root.notification && root.notification.actions.length > 0
spacing: 6
Repeater {
model: root.notification ? root.notification.actions : []
Rectangle {
required property var modelData
Layout.preferredHeight: 22
Layout.preferredWidth: actionText.implicitWidth + 16
radius: 6
color: actionMouse.containsMouse ? root.theme.ui.accent : root.theme.ui.focus
Text {
id: actionText
anchors.centerIn: parent
text: modelData.text
color: root.theme.content.backdrop
font.family: "IBM Plex Sans"
font.pixelSize: 10
elide: Text.ElideRight
}
MouseArea {
id: actionMouse
anchors.fill: parent
hoverEnabled: true
onClicked: {
modelData.invoke()
root.dismissRequested(root.notification)
}
}
}
}
}
}
}
}
}