glassMxrph now owns org.freedesktop.Notifications. Banners drop out of the bar like the OSD; Control Center stacks history per app like macOS Notification Center. Do Not Disturb lives in the shell and falls back to SwayNC while another daemon holds the bus name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
190 lines
6.3 KiB
QML
190 lines
6.3 KiB
QML
pragma ComponentBehavior: Bound
|
||
import QtQuick
|
||
import QtQuick.Layouts
|
||
import Quickshell
|
||
import ".."
|
||
import "../../notifications"
|
||
import "../../services"
|
||
import "../../theme"
|
||
|
||
// macOS-style Notification Center: one stack per app, newest first. A stack
|
||
// shows its latest notification with the rest peeking out underneath; clicking
|
||
// expands it, "Show Less" folds it back and × clears the app's notifications.
|
||
ColumnLayout {
|
||
id: root
|
||
objectName: "notificationCenter"
|
||
spacing: 8
|
||
// Group key -> expanded. Reassigned so bindings update.
|
||
property var expanded: ({})
|
||
property bool showAll: false
|
||
readonly property int groupLimit: 4
|
||
readonly property var groups: NotificationService.groups
|
||
readonly property var shownGroups: showAll ? groups : groups.slice(0, groupLimit)
|
||
function setExpanded(key, on) {
|
||
const next = Object.assign({}, expanded);
|
||
next[key] = on;
|
||
expanded = next;
|
||
}
|
||
|
||
component Pill: Rectangle {
|
||
id: pill
|
||
property string text
|
||
signal clicked
|
||
implicitWidth: label.implicitWidth + 18
|
||
implicitHeight: 22
|
||
radius: 11
|
||
color: pillArea.containsMouse ? Theme.hover : Theme.surfaceVariant
|
||
border.width: 1
|
||
border.color: Theme.hairline
|
||
Accessible.role: Accessible.Button
|
||
Accessible.name: text
|
||
Text {
|
||
id: label
|
||
anchors.centerIn: parent
|
||
text: pill.text
|
||
color: Theme.text
|
||
font.pixelSize: 11
|
||
font.weight: Font.Medium
|
||
}
|
||
MouseArea {
|
||
id: pillArea
|
||
anchors.fill: parent
|
||
hoverEnabled: true
|
||
cursorShape: Qt.PointingHandCursor
|
||
onClicked: pill.clicked()
|
||
}
|
||
}
|
||
|
||
RowLayout {
|
||
Layout.fillWidth: true
|
||
Layout.leftMargin: 4
|
||
spacing: 6
|
||
Text {
|
||
text: "Notifications"
|
||
color: Theme.text
|
||
font.pixelSize: 13
|
||
font.weight: Font.DemiBold
|
||
Layout.fillWidth: true
|
||
}
|
||
Text {
|
||
visible: NotificationService.dnd
|
||
text: (Icons.available ? " " : "") + "Do Not Disturb"
|
||
color: Theme.textSecondary
|
||
font.pixelSize: 11
|
||
}
|
||
Pill {
|
||
objectName: "notificationsClearAll"
|
||
visible: NotificationService.count > 0
|
||
text: "Clear All"
|
||
onClicked: {
|
||
NotificationService.clearAll();
|
||
root.expanded = {};
|
||
root.showAll = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
ControlCard {
|
||
visible: !NotificationService.active || NotificationService.count === 0
|
||
Layout.fillWidth: true
|
||
heading: false
|
||
padding: 14
|
||
Text {
|
||
objectName: "notificationsEmpty"
|
||
Layout.fillWidth: true
|
||
horizontalAlignment: Text.AlignHCenter
|
||
wrapMode: Text.Wrap
|
||
text: NotificationService.active ? "No Notifications" : NotificationService.notice || "Starting notifications…"
|
||
color: Theme.textSecondary
|
||
font.pixelSize: 12
|
||
}
|
||
}
|
||
|
||
Repeater {
|
||
model: ScriptModel {
|
||
values: root.shownGroups
|
||
}
|
||
ColumnLayout {
|
||
id: group
|
||
required property var modelData
|
||
readonly property var items: modelData.items
|
||
readonly property bool open: items.length > 1 && !!root.expanded[modelData.key]
|
||
Layout.fillWidth: true
|
||
spacing: 6
|
||
// Expanded stack header.
|
||
RowLayout {
|
||
visible: group.open
|
||
Layout.fillWidth: true
|
||
Layout.leftMargin: 4
|
||
spacing: 6
|
||
Text {
|
||
text: group.modelData.name
|
||
color: Theme.text
|
||
font.pixelSize: 12
|
||
font.weight: Font.DemiBold
|
||
elide: Text.ElideRight
|
||
Layout.fillWidth: true
|
||
}
|
||
Pill {
|
||
text: "Show Less"
|
||
onClicked: root.setExpanded(group.modelData.key, false)
|
||
}
|
||
Pill {
|
||
text: "×"
|
||
implicitWidth: 22
|
||
Accessible.name: "Clear " + group.modelData.name
|
||
onClicked: NotificationService.dismissGroup(group.modelData.key)
|
||
}
|
||
}
|
||
// Collapsed: the newest card with up to two slivers beneath it.
|
||
Item {
|
||
visible: !group.open
|
||
Layout.fillWidth: true
|
||
implicitHeight: top.implicitHeight + Math.min(2, group.items.length - 1) * 6
|
||
Repeater {
|
||
model: Math.min(2, group.items.length - 1)
|
||
Rectangle {
|
||
required property int index
|
||
x: parent.width * 0.04 * (index + 1)
|
||
width: parent.width - 2 * x
|
||
y: top.height + index * 6 - 1
|
||
height: 7
|
||
z: -1 - index
|
||
radius: 3.5
|
||
color: Qt.alpha(Theme.tint, 0.22 - index * 0.06)
|
||
border.width: 1
|
||
border.color: Theme.hairline
|
||
}
|
||
}
|
||
NotificationCard {
|
||
id: top
|
||
objectName: "notificationStack"
|
||
width: parent.width
|
||
notification: group.items[0]
|
||
bodyLines: 2
|
||
stackKey: group.items.length > 1 ? group.modelData.key : ""
|
||
stackCount: group.items.length
|
||
onExpand: root.setExpanded(group.modelData.key, true)
|
||
}
|
||
}
|
||
Repeater {
|
||
model: ScriptModel {
|
||
values: group.open ? group.items : []
|
||
}
|
||
NotificationCard {
|
||
required property var modelData
|
||
Layout.fillWidth: true
|
||
notification: modelData
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Pill {
|
||
visible: !root.showAll && root.groups.length > root.groupLimit
|
||
Layout.alignment: Qt.AlignHCenter
|
||
text: "Show " + (root.groups.length - root.groupLimit) + " more"
|
||
onClicked: root.showAll = true
|
||
}
|
||
}
|