From be98be01002bbc78197c9f856508d399712aaf99 Mon Sep 17 00:00:00 2001 From: Erik Simon Date: Sat, 19 Sep 2026 02:25:14 +0200 Subject: [PATCH] feat(quickshell): move notifications into HyprChrome The notification daemon and popup stack now live under HyprChrome/Widgets/Notifications and are owned by HyprChromeShell, so popups land on the rail's monitor below its exclusive zone. Replaces widgets/notifications; NotificationCard renders headless for tests. Co-Authored-By: Claude Opus 5 --- dotfiles/quickshell/CLAUDE.md | 7 +- .../HyprChrome/Widgets/HyprChromeShell.qml | 6 + .../Notifications/NotificationCard.qml | 272 ++++++++++++++++++ .../Notifications/NotificationPanel.qml | 210 ++++++++++++++ .../Widgets/Notifications/Notifications.qml | 131 +++++++++ dotfiles/quickshell/shell.qml | 3 - .../tests/NotificationCardHeadless.qml | 58 ++++ .../notifications/NotificationPopup.qml | 120 -------- .../widgets/notifications/Notifications.qml | 79 ----- 9 files changed, 682 insertions(+), 204 deletions(-) create mode 100644 dotfiles/quickshell/HyprChrome/Widgets/Notifications/NotificationCard.qml create mode 100644 dotfiles/quickshell/HyprChrome/Widgets/Notifications/NotificationPanel.qml create mode 100644 dotfiles/quickshell/HyprChrome/Widgets/Notifications/Notifications.qml create mode 100644 dotfiles/quickshell/tests/NotificationCardHeadless.qml delete mode 100644 dotfiles/quickshell/widgets/notifications/NotificationPopup.qml delete mode 100644 dotfiles/quickshell/widgets/notifications/Notifications.qml diff --git a/dotfiles/quickshell/CLAUDE.md b/dotfiles/quickshell/CLAUDE.md index c1bb8e9..7ee450e 100644 --- a/dotfiles/quickshell/CLAUDE.md +++ b/dotfiles/quickshell/CLAUDE.md @@ -70,8 +70,9 @@ configured via `.qmlls.ini` for editor diagnostics. ## Architecture `shell.qml` is a `Scope` instantiating the top-level pieces as siblings: -`HyprChromeShell` (the status rail), the eleven launcher variants, -`Notifications`, `VolumeOsd` and `Vitals`. Each manages its own +`HyprChromeShell` (the status rail, plus the surfaces it owns — launcher, polkit, +askpass, notifications), the ten remaining launcher variants, +`VolumeOsd` and `Vitals`. Each manages its own `PanelWindow`(s); there is no central layout manager. The one exception, and the pattern to follow for anything new that needs it, is @@ -100,6 +101,8 @@ on it, hence the index loops in `HyprChromeShell`. and its panels, with `Bar/Panels/BarPanel.qml` the chamfered chrome they all extend; `Widgets/Polkit/` is the authentication agent and its dialog; `Widgets/Launcher/` is the primary application launcher (`SUPER_L`); + `Widgets/Notifications/` is the notification daemon and its popup stack on the + rail's monitor (`NotificationCard` is the headless-renderable card); `Widgets/Greeter/` is the greetd login screen, run standalone via `greeter.qml` (see `services/desktop/quickshell-greeter.nix`), NOT part of `shell.qml`; `Theme/Theme.qml` is this tree's palette singleton. `DebugWindow.qml` stages a diff --git a/dotfiles/quickshell/HyprChrome/Widgets/HyprChromeShell.qml b/dotfiles/quickshell/HyprChrome/Widgets/HyprChromeShell.qml index 3d6f7cf..0e21110 100644 --- a/dotfiles/quickshell/HyprChrome/Widgets/HyprChromeShell.qml +++ b/dotfiles/quickshell/HyprChrome/Widgets/HyprChromeShell.qml @@ -8,6 +8,7 @@ import qs.HyprChrome.Widgets import qs.HyprChrome.Widgets.Polkit import qs.HyprChrome.Widgets.Launcher import qs.HyprChrome.Widgets.Askpass +import qs.HyprChrome.Widgets.Notifications // The hyprchrome shell: owns everything the rail's surfaces have to agree on, // and instantiates them. @@ -210,6 +211,11 @@ Scope { onDismissed: shell.expanded = false } + // Popups on the rail's monitor, below its exclusive zone. + Notifications { + screen: shell.targetScreen + } + // Polkit authentication agent. It registers for this logind session on // creation, so it replaces hyprpolkitagent rather than coexisting with it — // only one agent may hold a session (see hosts/terra/home/hyprland.nix). diff --git a/dotfiles/quickshell/HyprChrome/Widgets/Notifications/NotificationCard.qml b/dotfiles/quickshell/HyprChrome/Widgets/Notifications/NotificationCard.qml new file mode 100644 index 0000000..a1c7c52 --- /dev/null +++ b/dotfiles/quickshell/HyprChrome/Widgets/Notifications/NotificationCard.qml @@ -0,0 +1,272 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import QtQuick.Layouts +import Quickshell +import Quickshell.Widgets +import qs.HyprChrome.Theme + +// Headlessly renderable visual core of one notification. Every field arrives as +// a plain property and every action leaves as a signal; Notifications.qml maps +// the server's Notification onto it. +// +// Owns its own expiry: the drain meter IS the timer, so hovering pauses both. +Item { + id: root + + property string appName: "" + property string summary: "" + property string body: "" + // Icon name, path or URL; `image` (avatar, album art) wins over it. + property string appIcon: "" + property string image: "" + // 0 low, 1 normal, 2 critical — NotificationUrgency's values. + property int urgency: 1 + property string time: "" + + // Read structurally ({ identifier, text }). The "default" action is the + // card's own click, not a chip. + property var actions: [] + + // Milliseconds; 0 never expires. + property int timeout: 0 + // Off for headless renders, which set `remaining` directly. + property bool countdown: true + property real remaining: 1 + + signal dismissed + signal expired + signal actionInvoked(string identifier) + + readonly property bool critical: root.urgency === 2 + readonly property color tint: root.critical ? Theme.hot : root.urgency === 0 ? Theme.muted : Theme.accent + + readonly property var chipActions: { + const out = []; + for (let i = 0; i < root.actions.length; i++) { + if (root.actions[i].identifier !== "default") + out.push(root.actions[i]); + } + return out; + } + readonly property bool hasDefault: root.chipActions.length !== root.actions.length + + readonly property string iconSource: { + const s = root.image !== "" ? root.image : root.appIcon; + if (s === "") + return ""; + if (s.startsWith("/")) + return "file://" + s; + if (s.includes(":/")) + return s; + return Quickshell.iconPath(s, true); + } + + implicitWidth: 360 + implicitHeight: panel.implicitHeight + + NumberAnimation on remaining { + id: drain + + from: 1 + to: 0 + duration: Math.max(1, root.timeout) + running: root.countdown && root.timeout > 0 + paused: running && hover.hovered + } + + // Not drain's finished(): a value-source animation need not emit it. + onRemainingChanged: { + if (root.remaining <= 0 && root.countdown && root.timeout > 0) + root.expired(); + } + + HoverHandler { + id: hover + } + + // Under the panel, so the close box and chips take their own clicks. + MouseArea { + anchors.fill: parent + cursorShape: root.hasDefault ? Qt.PointingHandCursor : Qt.ArrowCursor + onClicked: { + if (root.hasDefault) + root.actionInvoked("default"); + else + root.dismissed(); + } + } + + component MicroText: Text { + color: Theme.muted + font.family: Theme.microFont + font.pixelSize: 8 + font.letterSpacing: 0.9 + elide: Text.ElideRight + } + + NotificationPanel { + id: panel + + width: root.width + panelId: root.critical ? "CRT" : root.urgency === 0 ? "LOW" : "NTF" + title: (root.appName !== "" ? root.appName : "NOTIFICATION").toUpperCase() + meta: root.time + accentColor: root.tint + + onCloseRequested: root.dismissed() + + ColumnLayout { + width: parent.width + spacing: 8 + + RowLayout { + Layout.fillWidth: true + spacing: 10 + + // Framed, so a transparent icon still reads as a tile. + Rectangle { + Layout.alignment: Qt.AlignTop + visible: root.iconSource !== "" + implicitWidth: 40 + implicitHeight: 40 + color: Theme.selection + border.width: 1 + border.color: Theme.hair + + IconImage { + anchors.centerIn: parent + implicitSize: root.image !== "" ? 38 : 28 + source: root.iconSource + } + } + + ColumnLayout { + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + spacing: 3 + + Text { + Layout.fillWidth: true + visible: root.summary !== "" + text: root.summary + textFormat: Text.PlainText + wrapMode: Text.Wrap + maximumLineCount: 2 + elide: Text.ElideRight + color: Theme.text + font.family: Theme.displayFont + font.pixelSize: 13 + font.bold: true + font.letterSpacing: 0.4 + } + + // Body markup is advertised, so StyledText, never RichText. + Text { + Layout.fillWidth: true + visible: root.body !== "" + text: root.body + textFormat: Text.StyledText + wrapMode: Text.Wrap + maximumLineCount: 5 + elide: Text.ElideRight + color: Theme.textAlpha(0.72) + linkColor: root.tint + font.family: Theme.displayFont + font.pixelSize: 11 + font.letterSpacing: 0.3 + onLinkActivated: link => Qt.openUrlExternally(link) + } + } + } + + Flow { + Layout.fillWidth: true + visible: root.chipActions.length > 0 + spacing: 6 + + Repeater { + model: root.chipActions + + Rectangle { + id: chip + + required property var modelData + + width: chipLabel.implicitWidth + 16 + height: chipLabel.implicitHeight + 10 + color: chipArea.containsMouse ? root.tint : "transparent" + border.width: 1 + border.color: chipArea.containsMouse ? root.tint : Theme.disabled + + Text { + id: chipLabel + + anchors.centerIn: parent + text: chip.modelData.text.toUpperCase() + color: chipArea.containsMouse ? Theme.surface : Theme.text + font.family: Theme.microFont + font.pixelSize: 9 + font.letterSpacing: 0.8 + } + + MouseArea { + id: chipArea + + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: root.actionInvoked(chip.modelData.identifier) + } + } + } + } + + // Expiry drain; a sticky card states it instead. + RowLayout { + Layout.fillWidth: true + spacing: 8 + + Row { + id: meter + + readonly property int segments: 24 + + Layout.fillWidth: true + Layout.preferredHeight: 4 + visible: root.timeout > 0 + spacing: 2 + + Repeater { + model: meter.segments + + Rectangle { + required property int index + + readonly property bool lit: index < Math.ceil(root.remaining * meter.segments) + + width: Math.max(2, (meter.width - (meter.segments - 1) * meter.spacing) / meter.segments) + height: meter.height + color: lit ? root.tint : Theme.textAlpha(0.06) + border.width: 1 + border.color: lit ? root.tint : Theme.textAlpha(0.18) + } + } + } + + MicroText { + visible: root.timeout > 0 + text: hover.hovered ? "HOLD" : Math.ceil(root.remaining * root.timeout / 1000) + "S" + color: hover.hovered ? root.tint : Theme.muted + } + + MicroText { + Layout.fillWidth: true + visible: root.timeout <= 0 + text: root.critical ? "CRITICAL · STICKY" : "STICKY" + color: root.critical ? Theme.hot : Theme.muted + } + } + } + } +} diff --git a/dotfiles/quickshell/HyprChrome/Widgets/Notifications/NotificationPanel.qml b/dotfiles/quickshell/HyprChrome/Widgets/Notifications/NotificationPanel.qml new file mode 100644 index 0000000..3bc4002 --- /dev/null +++ b/dotfiles/quickshell/HyprChrome/Widgets/Notifications/NotificationPanel.qml @@ -0,0 +1,210 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import QtQuick.Shapes +import qs.HyprChrome.Theme + +// Chamfered chrome for one notification card: PolkitPanel's silhouette, tighter +// metrics, a tintable accent (urgency) and a close box in the header. +// +// Not PolkitPanel itself: that file is the prompt's alone to restyle. +Item { + id: panel + + property string panelId: "" + property string title: "" + property string meta: "" + property color accentColor: Theme.accent + + property int chamfer: 12 + property int padding: 12 + property int outlineWidth: 1 + property int accentLineThickness: 3 + + readonly property int headerHeight: 26 + property int headerGap: 10 + readonly property int headerPadding: 8 + + property real capGap: 4 + readonly property real capOffset: panel.capGap / Math.SQRT2 + readonly property real activeChamfer: Math.max(2, Math.min(panel.chamfer, panel.height / 2 - 1)) + readonly property real accentLineWidth: Math.min(panel.width, slugChip.width + panel.headerPadding * 2) + + default property alias content: body.data + + signal closeRequested + + implicitHeight: Math.round(body.y + body.height + panel.padding) + + Shape { + id: panelShape + + anchors.fill: parent + preferredRendererType: Shape.CurveRenderer + + ShapePath { + fillColor: Theme.surface + strokeColor: Theme.hair + strokeWidth: panel.outlineWidth + + startX: 0; startY: 0 + PathLine { x: panelShape.width - panel.activeChamfer; y: 0 } + PathLine { x: panelShape.width; y: panel.activeChamfer } + PathLine { x: panelShape.width; y: panelShape.height } + PathLine { x: panel.activeChamfer; y: panelShape.height } + PathLine { x: 0; y: panelShape.height - panel.activeChamfer } + PathLine { x: 0; y: 0 } + } + + ShapePath { + fillColor: panel.accentColor + strokeWidth: 0 + + startX: panelShape.width - panel.activeChamfer + panel.capOffset + startY: -panel.capOffset + PathLine { x: panelShape.width + panel.capOffset; y: panel.activeChamfer - panel.capOffset } + PathLine { x: panelShape.width + panel.capOffset; y: -panel.capOffset } + PathLine { x: panelShape.width - panel.activeChamfer + panel.capOffset; y: -panel.capOffset } + } + + ShapePath { + fillColor: panel.accentColor + strokeWidth: 0 + + startX: panel.activeChamfer - panel.capOffset + startY: panelShape.height + panel.capOffset + PathLine { x: -panel.capOffset; y: panelShape.height - panel.activeChamfer + panel.capOffset } + PathLine { x: -panel.capOffset; y: panelShape.height + panel.capOffset } + PathLine { x: panel.activeChamfer - panel.capOffset; y: panelShape.height + panel.capOffset } + } + + ShapePath { + fillColor: panel.accentColor + strokeWidth: 0 + + startX: 0; startY: 0 + PathLine { x: panel.accentLineWidth; y: 0 } + PathLine { x: panel.accentLineWidth; y: panel.accentLineThickness } + PathLine { x: 0; y: panel.accentLineThickness } + PathLine { x: 0; y: 0 } + } + + ShapePath { + fillColor: panel.accentColor + strokeWidth: 0 + + startX: panelShape.width; startY: panelShape.height + PathLine { x: panelShape.width - panel.accentLineWidth; y: panelShape.height } + PathLine { x: panelShape.width - panel.accentLineWidth; y: panelShape.height - panel.accentLineThickness } + PathLine { x: panelShape.width; y: panelShape.height - panel.accentLineThickness } + PathLine { x: panelShape.width; y: panelShape.height } + } + } + + Row { + id: headerRow + + x: panel.headerPadding + y: Math.round((panel.headerHeight - height) / 2) + width: headerEnd.x - x - 8 + spacing: panel.headerPadding + 6 + + Rectangle { + id: slugChip + + width: slugText.implicitWidth + 8 + height: slugText.implicitHeight + 4 + color: panel.accentColor + + Text { + id: slugText + + anchors.centerIn: parent + text: panel.panelId + color: Theme.surface + font.family: Theme.microFont + font.pixelSize: 10 + font.bold: true + } + } + + Text { + anchors.verticalCenter: slugChip.verticalCenter + width: Math.max(0, headerRow.width - slugChip.width - headerRow.spacing) + text: panel.title + color: Theme.text + font.family: Theme.displayFont + font.pixelSize: 11 + font.bold: true + font.letterSpacing: 1.1 + elide: Text.ElideRight + } + } + + Row { + id: headerEnd + + // Clear of the top-right chamfer. + anchors.right: parent.right + anchors.rightMargin: panel.activeChamfer + 2 + y: Math.round((panel.headerHeight - height) / 2) + spacing: 8 + + Text { + anchors.verticalCenter: parent.verticalCenter + visible: panel.meta.length > 0 + text: panel.meta + color: Theme.muted + font.family: Theme.microFont + font.pixelSize: 8 + font.letterSpacing: 0.7 + } + + Rectangle { + id: closeBox + + width: 16 + height: 16 + color: closeArea.containsMouse ? panel.accentColor : "transparent" + border.width: 1 + border.color: closeArea.containsMouse ? panel.accentColor : Theme.disabled + + Text { + anchors.centerIn: parent + text: "✕" + color: closeArea.containsMouse ? Theme.surface : Theme.muted + font.family: Theme.microFont + font.pixelSize: 9 + font.bold: true + } + + MouseArea { + id: closeArea + + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: panel.closeRequested() + } + } + } + + Rectangle { + x: 1 + y: panel.headerHeight + width: parent.width - 2 + height: 1 + color: Theme.text + opacity: 0.12 + } + + // Measured by childrenRect: children carry their own size, no anchoring. + Item { + id: body + + x: panel.padding + y: panel.headerHeight + panel.headerGap + width: Math.max(0, panel.width - panel.padding * 2) + height: childrenRect.height + } +} diff --git a/dotfiles/quickshell/HyprChrome/Widgets/Notifications/Notifications.qml b/dotfiles/quickshell/HyprChrome/Widgets/Notifications/Notifications.qml new file mode 100644 index 0000000..3d7cf85 --- /dev/null +++ b/dotfiles/quickshell/HyprChrome/Widgets/Notifications/Notifications.qml @@ -0,0 +1,131 @@ +pragma ComponentBehavior: Bound + +import Quickshell +import Quickshell.Services.Notifications +import Quickshell.Wayland +import QtQuick + +// Notification daemon and its popup stack, migrated from widgets/notifications. +// Owns the server and the surface; NotificationCard is the visual core. +Scope { + id: root + + // Driven by the shell: the rail's monitor. + property var screen: null + + // Arrival time per notification id; the server keeps none. + property var arrived: ({}) + + // expireTimeout is in ms (verified); -1 means "server default". + function timeoutFor(n) { + if (n.expireTimeout > 0) + return n.expireTimeout; + if (n.expireTimeout === 0 || n.urgency === NotificationUrgency.Critical) + return 0; + return 5000; + } + + NotificationServer { + id: server + + keepOnReload: true + bodySupported: true + bodyMarkupSupported: true + bodyHyperlinksSupported: true + imageSupported: true + actionsSupported: true + + onNotification: notification => { + const id = notification.id; + root.arrived[id] = Qt.formatTime(new Date(), "hh:mm"); + notification.closed.connect(() => delete root.arrived[id]); + notification.tracked = true; + } + } + + PanelWindow { + id: win + + screen: root.screen + visible: server.trackedNotifications.values.length > 0 + + WlrLayershell.namespace: "hyprchrome-notifications" + WlrLayershell.layer: WlrLayer.Overlay + // Normal with no zone of its own: sits below the rail's exclusive zone. + exclusionMode: ExclusionMode.Normal + color: "transparent" + + anchors { + top: true + right: true + } + + margins.top: 12 + margins.right: 16 + + // Slack on every side for the corner caps, which sit outside each card. + implicitWidth: 360 + 8 + implicitHeight: Math.max(1, stack.implicitHeight + 8) + + mask: Region { + item: stack + } + + Column { + id: stack + + x: 4 + y: 4 + width: 360 + spacing: 14 + + Repeater { + model: server.trackedNotifications + + NotificationCard { + id: card + + required property Notification modelData + + width: stack.width + + appName: card.modelData.appName + summary: card.modelData.summary + body: card.modelData.body + appIcon: card.modelData.appIcon + image: card.modelData.image + urgency: card.modelData.urgency + time: root.arrived[card.modelData.id] ?? "" + actions: card.modelData.actions + timeout: root.timeoutFor(card.modelData) + + onDismissed: card.modelData.dismiss() + onExpired: card.modelData.expire() + + // invoke() closes a non-resident notification itself. + onActionInvoked: identifier => { + const actions = card.modelData.actions; + for (let i = 0; i < actions.length; i++) { + if (actions[i].identifier === identifier) { + actions[i].invoke(); + return; + } + } + } + + // Slides in from the right edge. + opacity: 0 + transform: Translate { id: slide; x: 40 } + Component.onCompleted: enter.start() + + ParallelAnimation { + id: enter + + NumberAnimation { target: card; property: "opacity"; to: 1; duration: 160; easing.type: Easing.OutCubic } + NumberAnimation { target: slide; property: "x"; to: 0; duration: 200; easing.type: Easing.OutCubic } + } + } + } + } + } +} diff --git a/dotfiles/quickshell/shell.qml b/dotfiles/quickshell/shell.qml index 99dfee1..8e27641 100644 --- a/dotfiles/quickshell/shell.qml +++ b/dotfiles/quickshell/shell.qml @@ -5,7 +5,6 @@ import Quickshell import Quickshell.Widgets import qs.widgets.bar import qs.widgets.launcher -import qs.widgets.notifications import qs.widgets.osd import qs.widgets.systray import qs.widgets.theme @@ -36,8 +35,6 @@ Scope { OrbitLauncher {} // 10 — radial targeting arena CyberDock {} // 11 — cyberpunk bottom cartridge dock - Notifications {} - VolumeOsd {} // Host vitals HUD — toggle with SUPER CTRL V. diff --git a/dotfiles/quickshell/tests/NotificationCardHeadless.qml b/dotfiles/quickshell/tests/NotificationCardHeadless.qml new file mode 100644 index 0000000..7021f86 --- /dev/null +++ b/dotfiles/quickshell/tests/NotificationCardHeadless.qml @@ -0,0 +1,58 @@ +import QtQuick +import qs.HyprChrome.Widgets.Notifications + +// Offscreen render of the three urgencies, with actions, a link and a +// part-drained meter. +// +// ./tools/quickshell-preview/render.sh \ +// tests/NotificationCardHeadless.qml \ +// .artifacts/quickshell-preview/notifications.png 400 520 +Rectangle { + width: 400 + height: 520 + color: "#1b1d20" + + Column { + x: 20 + y: 20 + width: 360 + spacing: 14 + + NotificationCard { + width: parent.width + appName: "Firefox" + summary: "Download complete" + body: "nixos-26.05-x86_64.iso finished — open folder" + appIcon: "firefox" + time: "14:32" + actions: [ + { identifier: "default", text: "Open" }, + { identifier: "show", text: "Show in folder" }, + { identifier: "dismiss", text: "Dismiss" } + ] + timeout: 5000 + countdown: false + remaining: 0.6 + } + + NotificationCard { + width: parent.width + appName: "smartd" + summary: "Disk /dev/sdb reports 8 reallocated sectors" + body: "SMART attribute 5 crossed its threshold. Back up the RAID0 set on /mnt/data now." + urgency: 2 + time: "14:30" + } + + NotificationCard { + width: parent.width + appName: "nix" + summary: "Build finished" + urgency: 0 + time: "14:28" + timeout: 5000 + countdown: false + remaining: 0.2 + } + } +} diff --git a/dotfiles/quickshell/widgets/notifications/NotificationPopup.qml b/dotfiles/quickshell/widgets/notifications/NotificationPopup.qml deleted file mode 100644 index 31a9c9f..0000000 --- a/dotfiles/quickshell/widgets/notifications/NotificationPopup.qml +++ /dev/null @@ -1,120 +0,0 @@ -import Quickshell.Services.Notifications -import Quickshell.Widgets -import QtQuick -import QtQuick.Layouts -import qs.widgets.theme - -ColumnLayout { - id: root - - required property Notification modelData - - spacing: 0 - Layout.fillWidth: true - - Rectangle { - color: Theme.accent - implicitHeight: 5 - - Layout.fillWidth: true - } - - WrapperRectangle { - Layout.fillWidth: true - - margin: 12 - border.width: 1 - border.color: Theme.accent - color: Theme.surface - opacity: .9 - - ColumnLayout { - spacing: 4 - - Layout.fillWidth: true - - RowLayout { - spacing: 8 - - Layout.fillWidth: true - - IconImage { - visible: root.modelData.appIcon !== "" - source: root.modelData.appIcon - implicitSize: 20 - } - - Text { - text: root.modelData.summary - color: Theme.text - font.pointSize: 14 - font.bold: true - elide: Text.ElideRight - - Layout.fillWidth: true - } - - Text { - id: dismissButton - - text: "×" - color: Theme.accent - font.pointSize: 18 - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: root.modelData.dismiss() - } - } - } - - Text { - visible: root.modelData.body !== "" - text: root.modelData.body - color: Theme.text - font.pointSize: 12 - wrapMode: Text.Wrap - - Layout.fillWidth: true - } - - RowLayout { - visible: root.modelData.actions.length > 0 - spacing: 6 - - Layout.fillWidth: true - - Repeater { - model: root.modelData.actions - - Rectangle { - id: actionButton - - required property NotificationAction modelData - - color: Theme.raised - border.width: 1 - border.color: Theme.accent - implicitHeight: 28 - implicitWidth: actionText.implicitWidth + 16 - - Text { - id: actionText - anchors.centerIn: parent - text: actionButton.modelData.text - color: Theme.text - font.pointSize: 12 - } - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: actionButton.modelData.invoke() - } - } - } - } - } - } -} diff --git a/dotfiles/quickshell/widgets/notifications/Notifications.qml b/dotfiles/quickshell/widgets/notifications/Notifications.qml deleted file mode 100644 index 31f6e54..0000000 --- a/dotfiles/quickshell/widgets/notifications/Notifications.qml +++ /dev/null @@ -1,79 +0,0 @@ -import Quickshell -import Quickshell.Services.Notifications -import QtQuick -import QtQuick.Layouts - -Scope { - id: root - - NotificationServer { - id: server - - keepOnReload: true - bodySupported: true - bodyMarkupSupported: true - imageSupported: true - actionsSupported: true - actionIconsSupported: true - - onNotification: notification => { - notification.tracked = true; - - const timeout = notification.expireTimeout === 0 ? 0 : notification.expireTimeout > 0 ? notification.expireTimeout : (notification.urgency === NotificationUrgency.Critical ? 0 : 5000); - - if (timeout <= 0) - return; - - let closed = false; - notification.closed.connect(() => { - closed = true; - }); - - const timer = expiryTimerComponent.createObject(root, { - interval: timeout - }); - timer.triggered.connect(() => { - if (!closed) - notification.expire(); - timer.destroy(); - }); - } - } - - Component { - id: expiryTimerComponent - - Timer { - running: true - } - } - - PanelWindow { - screen: Quickshell.screens.find(s => s.name === "DP-2") - - color: "transparent" - - anchors { - top: true - right: true - } - - margins.top: 12 - margins.right: 12 - - implicitWidth: 340 - implicitHeight: column.implicitHeight - - ColumnLayout { - id: column - anchors.fill: parent - spacing: 8 - - Repeater { - model: server.trackedNotifications - - NotificationPopup {} - } - } - } -}