feat: better notification storage and image caching + blobs
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 11s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 12s
JS/TS / lint (pull_request) Successful in 10s
Python / static (pull_request) Failing after 27s
Rust / build (pull_request) Successful in 54s
Python / verify (pull_request) Failing after 1m26s
Rust / fmt (pull_request) Successful in 46s
Rust / clippy (pull_request) Successful in 1m6s

This commit is contained in:
2026-11-02 19:00:43 +01:00
parent 789305286a
commit 11e7aac195
56 changed files with 5003 additions and 2168 deletions
+136 -86
View File
@@ -3,12 +3,14 @@ pragma ComponentBehavior: Bound
import Quickshell
import Quickshell.Widgets
import QtQuick
import ZShell.Config
import ZShell.Components
import ZShell.Config
import ZShell.Services
import qs.Components
import qs.Components.Notifs
import qs.Daemons
import qs.Helpers
import qs.Services
Item {
id: root
@@ -21,13 +23,10 @@ Item {
anchors.right: parent.right
anchors.top: parent.top
implicitHeight: {
const count = list.count;
if (count === 0)
if (list.count === 0)
return 0;
let height = (count - 1) * Tokens.spacing.small;
for (let i = 0; i < count; i++)
height += (list.itemAtIndex(i) as NotifWrapper)?.nonAnimHeight ?? 0;
let height = list.layoutHeight;
if (panels.popouts.hasCurrent && (panels.popouts.currentCenter + (panels.popouts.current?.width / 2)) > panels.notifications.x)
return 0;
@@ -54,36 +53,55 @@ Item {
anchors.fill: parent
anchors.margins: root.padding
clip: true
// radius: Tokens.rounding.large - root.padding
CustomListView {
id: list
KineticFlickable {
id: view
anchors.fill: parent
cacheBuffer: (QsWindow.window as QsWindow)?.screen.height ?? 0
orientation: Qt.Vertical
spacing: 0
delegate: NotifWrapper {}
displaced: Transition {
Anim {
property: "y"
}
}
model: ScriptModel {
values: {
const popups = NotifServer.popups.filter(n => !n.closed);
contentHeight: list.implicitHeight
contentWidth: width
flickableDirection: Flickable.VerticalFlick
if (!Config.notifs.showInFullscreen) {
if (Hypr.monitorFor(root.panels.screen).activeWorkspace?.toplevels.values.some(t => t.lastIpcObject.fullscreen > 1) ?? false)
return [];
LazyListView {
id: list
anchors.left: parent.left
anchors.right: parent.right
implicitHeight: contentHeight
spacing: Tokens.spacing.medium
readyDelay: 1
cacheBuffer: (QsWindow.window as QsWindow)?.screen.height ?? 0
removeDuration: Tokens.anim.durations.normal
useCustomViewport: true
viewport: Qt.rect(0, view.contentY, width, view.height)
model: ScriptModel {
values: {
if (!Config.notifs.showInFullscreen) {
if (Hypr.monitorFor(root.panels.screen).activeWorkspace?.toplevels.values.some(t => t.lastIpcObject.fullscreen > 1) ?? false)
return [];
}
return [...NotifServer.popupGroups];
}
return popups;
}
}
move: Transition {
delegate: NotifWrapper {}
onViewportAdjustNeeded: d => {
if (contentYAnim.running)
contentYAnim.complete();
contentYAnim.to = Math.max(0, view.contentY + d);
contentYAnim.start();
}
Anim {
property: "y"
id: contentYAnim
target: view
property: "contentY"
}
}
}
@@ -96,74 +114,106 @@ Item {
component NotifWrapper: Item {
id: wrapper
property int idx
required property int index
required property NotificationRow modelData
readonly property alias nonAnimHeight: notif.nonAnimHeight
required property NotificationGroup modelData
property bool expanded: Config.notifs.openExpanded
readonly property bool holding: area.containsMouse || area.pressed || card.rowPressed
implicitHeight: notif.implicitHeight + (idx === 0 ? 0 : Tokens.spacing.small)
implicitWidth: notif.implicitWidth
ListView.onRemove: removeAnim.start()
onIndexChanged: {
if (index !== -1)
idx = index;
function forEachPopup(fn: var): void {
for (const n of [...card.notifs])
fn(n);
}
SequentialAnimation {
id: removeAnim
PropertyAction {
property: "ListView.delayRemove"
target: wrapper
value: true
}
PropertyAction {
property: "enabled"
target: wrapper
value: false
}
PropertyAction {
property: "implicitHeight"
target: wrapper
value: 0
}
PropertyAction {
property: "z"
target: wrapper
value: 1
}
Anim {
property: "x"
target: notif
to: (notif.x >= 0 ? Config.notifs.sizes.width : -Config.notifs.sizes.width) * 2
}
PropertyAction {
property: "ListView.delayRemove"
target: wrapper
value: false
}
function holdPopups(): void {
forEachPopup(n => n.holdPopup());
}
CustomRect {
LazyListView.trackViewport: !expanded && card.nonAnimHeight < card.implicitHeight
LazyListView.preferredHeight: LazyListView.removing ? 0 : card.nonAnimHeight
LazyListView.visibleHeight: LazyListView.removing ? 0 : card.implicitHeight
LazyListView.onRemovingChanged: {
if (!wrapper.LazyListView.removing)
return;
slideOut.to = (area.x >= 0 ? root.implicitWidth : -root.implicitWidth) * 2;
slideOut.start();
}
implicitWidth: area.implicitWidth
implicitHeight: card.implicitHeight
enabled: !LazyListView.removing
z: LazyListView.removing ? 1 : 0
onHoldingChanged: {
if (holding)
holdPopups();
else
forEachPopup(n => n.releasePopup());
}
Connections {
function onNotifsChanged(): void {
if (wrapper.holding)
wrapper.holdPopups();
}
target: wrapper.modelData
}
Anim {
id: slideOut
target: area
property: "x"
duration: Tokens.anim.durations.normal
easing: Tokens.anim.emphasized
}
Item {
anchors.top: parent.top
anchors.topMargin: wrapper.idx === 0 ? 0 : 8
color: "transparent"
implicitHeight: notif.implicitHeight
implicitWidth: notif.implicitWidth
radius: Tokens.rounding.small
Notification {
id: notif
implicitWidth: area.implicitWidth
implicitHeight: card.implicitHeight
clip: true
NotifSwipeArea {
id: area
implicitWidth: root.implicitWidth - root.padding * 2
modelData: wrapper.modelData
implicitHeight: card.implicitHeight
x: wrapper.LazyListView.adding ? implicitWidth : 0
expanded: wrapper.expanded
onRequestExpand: expand => wrapper.expanded = expand
onSwiped: wrapper.forEachPopup(n => n.dismissPopup())
onDismissed: wrapper.forEachPopup(n => n.dismiss())
onClicked: event => {
if (!Config.notifs.actionOnClick || event.button !== Qt.LeftButton || card.notifs.length !== 1)
return;
const actions = card.notifs[0].actions;
if (actions.length === 1)
actions[0].invoke();
}
NotifGroupCard {
id: card
group: wrapper.modelData
container: view
expanded: wrapper.expanded
onRequestExpand: expand => wrapper.expanded = expand
onSwiped: notif => notif.dismissPopup()
onLinkActivated: notif => notif.dismissPopup()
}
}
}
Behavior on y {
enabled: wrapper.LazyListView.ready
Anim {}
}
}
}
-515
View File
@@ -1,515 +0,0 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Shapes
import Quickshell
import Quickshell.Services.Notifications
import ZShell.Components
import ZShell.Services
import qs.Helpers
import ZShell.Config
import qs.Components
import qs.Services
CustomRect {
id: root
property bool expanded: Config.notifs.openExpanded
readonly property bool hasAppIcon: modelData.appIcon.length > 0
readonly property bool hasImage: modelData.image.length > 0
required property NotificationRow modelData
readonly property int nonAnimHeight: summary.implicitHeight + (root.expanded ? Tokens.spacing.extraSmall * 2 + appName.height + body.height + actions.height + actions.anchors.topMargin : bodyPreview.height) + inner.anchors.margins * 2
color: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3secondaryContainer : Colors.tPalette.m3surfaceContainer
implicitHeight: inner.implicitHeight
radius: Tokens.rounding.large - Tokens.padding.smaller
x: implicitWidth
Behavior on x {
Anim {
easing: Tokens.anim.emphasizedDecel
}
}
Component.onCompleted: {
x = 0;
modelData.lock(this);
}
Component.onDestruction: modelData.unlock(this)
MouseArea {
property int startY
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
anchors.fill: parent
cursorShape: root.expanded && body.hoveredLink ? Qt.PointingHandCursor : pressed ? Qt.ClosedHandCursor : undefined
drag.axis: Drag.XAxis
drag.target: parent
hoverEnabled: true
preventStealing: true
onClicked: event => {
if (!Config.notifs.actionOnClick || event.button !== Qt.LeftButton)
return;
const actions = root.modelData.actions;
if (actions.length === 1)
actions[0].invoke();
}
onEntered: root.modelData.pausePopup()
onExited: {
if (!pressed)
root.modelData.resumePopup();
}
onPositionChanged: event => {
if (pressed) {
const diffY = event.y - startY;
if (Math.abs(diffY) > Config.notifs.expandThreshold)
root.expanded = diffY > 0;
}
}
onPressed: event => {
root.modelData.pausePopup();
startY = event.y;
if (event.button === Qt.MiddleButton)
root.modelData.close();
}
onReleased: event => {
if (!containsMouse)
root.modelData.resumePopup();
if (Math.abs(root.x) < root.implicitWidth * Config.notifs.clearThreshold)
root.x = 0;
else
root.modelData.popup = false;
}
Item {
id: inner
anchors.left: parent.left
anchors.margins: Tokens.padding.small
anchors.right: parent.right
anchors.top: parent.top
implicitHeight: root.nonAnimHeight
Behavior on implicitHeight {
Anim {}
}
Loader {
id: image
active: root.hasImage
anchors.left: parent.left
anchors.top: parent.top
asynchronous: true
height: Config.notifs.sizes.image
visible: root.hasImage || root.hasAppIcon
width: Config.notifs.sizes.image
sourceComponent: ClipRect {
color: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3error : root.modelData.urgency === NotificationUrgency.Low ? Colors.layer(Colors.palette.m3surfaceContainerHighest, 2) : Colors.palette.m3secondaryContainer
implicitHeight: Config.notifs.sizes.image
implicitWidth: Config.notifs.sizes.image
radius: Tokens.rounding.full
Image {
anchors.fill: parent
asynchronous: true
cache: false
fillMode: Image.PreserveAspectCrop
source: Qt.resolvedUrl(root.modelData.image)
sourceSize: {
const size = Config.notifs.sizes.image * ((QsWindow.window as QsWindow)?.devicePixelRatio ?? 1);
return Qt.size(size, size);
}
}
}
}
Loader {
id: appIcon
active: root.hasAppIcon || !root.hasImage
anchors.bottom: root.hasImage ? image.bottom : undefined
anchors.horizontalCenter: root.hasImage ? undefined : image.horizontalCenter
anchors.right: root.hasImage ? image.right : undefined
anchors.verticalCenter: root.hasImage ? undefined : image.verticalCenter
asynchronous: true
sourceComponent: CustomRect {
color: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3error : root.modelData.urgency === NotificationUrgency.Low ? Colors.layer(Colors.palette.m3surfaceContainerHighest, 2) : Colors.palette.m3secondaryContainer
implicitHeight: root.hasImage ? Config.notifs.sizes.badge : Config.notifs.sizes.image
implicitWidth: root.hasImage ? Config.notifs.sizes.badge : Config.notifs.sizes.image
radius: Tokens.rounding.full
Loader {
id: icon
active: root.hasAppIcon
anchors.centerIn: parent
asynchronous: true
height: Math.round(parent.width * 0.6)
width: Math.round(parent.width * 0.6)
sourceComponent: ColoredIcon {
anchors.fill: parent
color: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3onError : root.modelData.urgency === NotificationUrgency.Low ? Colors.palette.m3onSurface : Colors.palette.m3onSecondaryContainer
layer.enabled: root.modelData.appIcon.endsWith("symbolic")
source: Quickshell.iconPath(root.modelData.appIcon)
}
}
Loader {
active: !root.hasAppIcon
anchors.centerIn: parent
anchors.verticalCenterOffset: 1
asynchronous: true
sourceComponent: MaterialIcon {
color: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3onError : root.modelData.urgency === NotificationUrgency.Low ? Colors.palette.m3onSurface : Colors.palette.m3onSecondaryContainer
text: Icons.getNotifIcon(root.modelData.summary, root.modelData.urgency)
fontStyle: Tokens.font.icon.medium
}
}
}
}
Shape {
id: progressIndicator
anchors.centerIn: appIcon
height: appIcon.implicitHeight + progressShape.strokeWidth * 2
preferredRendererType: Shape.CurveRenderer
width: appIcon.implicitWidth + progressShape.strokeWidth * 2
ShapePath {
id: progressShape
capStyle: ShapePath.RoundCap
fillColor: "transparent"
strokeColor: Colors.palette.m3primary
strokeWidth: 2
PathAngleArc {
id: progressArc
centerX: progressIndicator.width / 2
centerY: progressIndicator.height / 2
radiusX: progressIndicator.width / 2 - Tokens.padding.extraSmall / 2
radiusY: progressIndicator.height / 2 - Tokens.padding.extraSmall / 2
startAngle: -90
sweepAngle: (root.modelData.progress / 100) * 360
Behavior on sweepAngle {
Anim {
easing: Tokens.anim.emphasizedDecel
}
}
}
}
}
CustomText {
id: appName
anchors.left: image.right
anchors.leftMargin: Tokens.spacing.small
anchors.top: parent.top
animate: true
color: Colors.palette.m3onSurfaceVariant
maximumLineCount: 1
opacity: root.expanded ? 1 : 0
text: appNameMetrics.elidedText
font: Tokens.font.label.medium
Behavior on opacity {
Anim {
type: Anim.DefaultEffects
}
}
}
TextMetrics {
id: appNameMetrics
elide: Text.ElideRight
elideWidth: expandBtn.x - time.width - timeSep.width - summary.x - Tokens.spacing.small * 3
font: appName.font
text: root.modelData.appName
}
CustomText {
id: summary
anchors.left: image.right
anchors.leftMargin: Tokens.spacing.small
anchors.top: parent.top
animate: true
height: implicitHeight
maximumLineCount: 1
text: summaryMetrics.elidedText
Behavior on height {
Anim {}
}
states: State {
name: "expanded"
when: root.expanded
PropertyChanges {
body.anchors.topMargin: Tokens.spacing.extraSmall
bodyPreview.anchors.topMargin: Tokens.spacing.extraSmall
summary.anchors.topMargin: Tokens.spacing.extraSmall
summary.maximumLineCount: undefined
}
AnchorChanges {
anchors.top: appName.bottom
target: summary
}
}
transitions: Transition {
PropertyAction {
property: "maximumLineCount"
target: summary
}
Anim {
property: "topMargin"
}
AnchorAnim {}
}
}
TextMetrics {
id: summaryMetrics
elide: Text.ElideRight
elideWidth: expandBtn.x - time.width - timeSep.width - summary.x - Tokens.spacing.small * 3
font: summary.font
text: root.modelData.summary
}
CustomText {
id: timeSep
anchors.left: summary.right
anchors.leftMargin: Tokens.spacing.small
anchors.top: parent.top
color: Colors.palette.m3onSurfaceVariant
text: "•"
font: Tokens.font.body.small
states: State {
name: "expanded"
when: root.expanded
AnchorChanges {
anchors.left: appName.right
target: timeSep
}
}
transitions: Transition {
AnchorAnim {}
}
}
CustomText {
id: time
anchors.left: timeSep.right
anchors.leftMargin: Tokens.spacing.small
anchors.top: parent.top
animate: true
color: Colors.palette.m3onSurfaceVariant
font: Tokens.font.body.small
horizontalAlignment: Text.AlignLeft
text: root.modelData.timeStr
}
Item {
id: expandBtn
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: -Tokens.padding.extraSmall
implicitHeight: expandIcon.implicitHeight
implicitWidth: expandIcon.implicitHeight
StateLayer {
color: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3onSecondaryContainer : Colors.palette.m3onSurface
radius: Tokens.rounding.full
onClicked: root.expanded = !root.expanded
}
MaterialIcon {
id: expandIcon
anchors.centerIn: parent
anchors.verticalCenterOffset: root.expanded ? -1 : 1
rotation: root.expanded ? 180 : 0
text: "expand_more"
fontStyle: Tokens.font.icon.medium
Behavior on anchors.verticalCenterOffset {
Anim {}
}
Behavior on rotation {
Anim {}
}
}
}
CustomText {
id: bodyPreview
anchors.left: summary.left
anchors.right: expandBtn.left
anchors.rightMargin: Tokens.spacing.small
anchors.top: summary.bottom
animate: true
color: Colors.palette.m3onSurfaceVariant
font: Tokens.font.body.small
opacity: root.expanded ? 0 : 1
text: bodyPreviewMetrics.elidedText
textFormat: Text.MarkdownText
Behavior on opacity {
Anim {
type: Anim.DefaultEffects
}
}
}
TextMetrics {
id: bodyPreviewMetrics
elide: Text.ElideRight
elideWidth: bodyPreview.width
font: bodyPreview.font
text: root.modelData.body
}
CustomText {
id: body
anchors.left: summary.left
anchors.right: expandBtn.left
anchors.rightMargin: Tokens.spacing.small
anchors.top: summary.bottom
animate: true
color: Colors.palette.m3onSurfaceVariant
height: text ? implicitHeight : 0
font: Tokens.font.body.medium
opacity: root.expanded ? 1 : 0
text: root.modelData.body
textFormat: Text.MarkdownText
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
Behavior on opacity {
Anim {
type: Anim.DefaultEffects
}
}
onLinkActivated: link => {
if (!root.expanded)
return;
Quickshell.execDetached(["app2unit", "-O", "--", link]);
root.modelData.popup = false;
}
}
ButtonRow {
id: actions
anchors.left: parent.left
anchors.right: parent.right
anchors.top: body.bottom
anchors.topMargin: Tokens.spacing.small
opacity: root.expanded ? 1 : 0
spacing: Tokens.spacing.extraSmall
Behavior on opacity {
Anim {
type: Anim.DefaultEffects
}
}
IconButton {
enabled: root.expanded
fillWidth: root.modelData.actions.length === 0
icon: "close"
font: Tokens.font.icon.builders.small.size(14).build()
inactiveColor: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3secondary : Colors.layer(Colors.palette.m3surfaceContainerHighest, 2)
inactiveOnColor: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3onSecondary : Colors.palette.m3onSurfaceVariant
isRound: true
padding: Tokens.padding.extraSmall
shapeMorph: true
onClicked: root.modelData.close()
}
Repeater {
model: root.modelData.actions
TextButton {
required property var modelData
enabled: root.expanded
fillWidth: true
implicitWidth: label.implicitWidth
inactiveColor: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3secondary : Colors.layer(Colors.palette.m3surfaceContainerHighest, 2)
inactiveOnColor: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3onSecondary : Colors.palette.m3onSurfaceVariant
isRound: true
label.anchors.centerIn: undefined
label.anchors.left: left
label.anchors.margins: Tokens.padding.small
label.anchors.right: right
label.anchors.verticalCenter: verticalCenter
label.elide: Text.ElideRight
label.horizontalAlignment: Text.AlignHCenter
shapeMorph: true
text: modelData.text
onClicked: {
if (modelData.invokable)
modelData.invoke();
else if (!root.modelData.resident)
root.modelData.close();
}
}
}
IconButton {
enabled: root.expanded
fillWidth: root.modelData.actions.length === 0
icon: copyTimer.running ? "inventory" : "content_copy"
inactiveColor: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3secondary : Colors.layer(Colors.palette.m3surfaceContainerHighest, 2)
inactiveOnColor: root.modelData.urgency === NotificationUrgency.Critical ? Colors.palette.m3onSecondary : Colors.palette.m3onSurfaceVariant
isRound: true
label.animate: true
padding: Tokens.padding.extraSmall
shapeMorph: true
font: Tokens.font.icon.builders.small.size(14).build()
onClicked: {
Quickshell.clipboardText = root.modelData.body;
copyTimer.restart();
}
Timer {
id: copyTimer
interval: 3000
}
}
}
}
}
}