Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit c9b0a68

Browse files
committed
feat: add notification progress indicators (caelestia-dots#569)
1 parent 6467d83 commit c9b0a68

File tree

3 files changed

+96
-3
lines changed

3 files changed

+96
-3
lines changed

config/NotifsConfig.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Quickshell.Io
33
JsonObject {
44
property bool expire: true
55
property int defaultExpireTimeout: 5000
6+
property bool timeoutBar: true
7+
property bool timeoutCircle: true
68
property real clearThreshold: 0.3
79
property int expandThreshold: 20
810
property bool actionOnClick: false

modules/notifications/Content.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Item {
2525

2626
let height = (count - 1) * Appearance.spacing.smaller;
2727
for (let i = 0; i < count; i++)
28-
height += list.itemAtIndex(i)?.nonAnimHeight ?? 0;
28+
height += list.itemAtIndex(i)?.implicitHeight ?? 0;
2929

3030
if (visibilities && panels) {
3131
if (visibilities.osd) {

modules/notifications/Notification.qml

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Quickshell.Widgets
1010
import Quickshell.Services.Notifications
1111
import QtQuick
1212
import QtQuick.Layouts
13+
import QtQuick.Shapes
1314

1415
StyledRect {
1516
id: root
@@ -23,7 +24,7 @@ StyledRect {
2324
color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3secondaryContainer : Colours.tPalette.m3surfaceContainer
2425
radius: Appearance.rounding.normal
2526
implicitWidth: Config.notifs.sizes.width
26-
implicitHeight: inner.implicitHeight
27+
implicitHeight: inner.implicitHeight + progressBar.implicitHeight
2728

2829
x: Config.notifs.sizes.width
2930
Component.onCompleted: {
@@ -311,12 +312,78 @@ StyledRect {
311312
font.pointSize: Appearance.font.size.small
312313
}
313314

315+
Loader {
316+
active: Config.notifs.timeoutCircle
317+
asynchronous: true
318+
anchors.centerIn: closeBtn
319+
320+
sourceComponent: Shape {
321+
id: progressCircle
322+
width: closeBtn.implicitWidth + Appearance.padding.small
323+
height: closeBtn.implicitHeight + Appearance.padding.small
324+
preferredRendererType: Shape.CurveRenderer
325+
326+
ShapePath {
327+
capStyle: ShapePath.FlatCap
328+
fillColor: "transparent"
329+
strokeWidth: Appearance.padding.small
330+
strokeColor: Colours.palette.m3tertiary
331+
332+
PathAngleArc {
333+
centerX: progressCircle.width / 2
334+
centerY: progressCircle.height / 2
335+
radiusX: progressCircle.width / 2 - Appearance.padding.small / 2
336+
radiusY: progressCircle.height / 2 - Appearance.padding.small / 2
337+
338+
startAngle: -90
339+
340+
NumberAnimation on sweepAngle {
341+
from: 360
342+
to: 0
343+
duration: Config.notifs.defaultExpireTimeout
344+
running: root.modelData.timer.running
345+
}
346+
}
347+
}
348+
}
349+
}
350+
314351
Item {
315-
id: expandBtn
352+
id: closeBtn
316353

317354
anchors.right: parent.right
318355
anchors.top: parent.top
319356

357+
implicitWidth: closeIcon.height
358+
implicitHeight: closeIcon.height
359+
360+
StateLayer {
361+
radius: Appearance.rounding.full
362+
color: Colours.palette.m3onSurface
363+
364+
function onClicked() {
365+
root.modelData.notification.dismiss();
366+
}
367+
}
368+
369+
MaterialIcon {
370+
id: closeIcon
371+
372+
anchors.centerIn: parent
373+
374+
animate: true
375+
text: "close"
376+
font.pointSize: Appearance.font.size.normal
377+
}
378+
}
379+
380+
Item {
381+
id: expandBtn
382+
383+
anchors.right: closeBtn.left
384+
anchors.top: parent.top
385+
anchors.rightMargin: Appearance.spacing.small
386+
320387
implicitWidth: expandIcon.height
321388
implicitHeight: expandIcon.height
322389

@@ -437,6 +504,30 @@ StyledRect {
437504
}
438505
}
439506

507+
Loader {
508+
id: progressBar
509+
active: Config.notifs.timeoutBar
510+
asynchronous: true
511+
512+
anchors.right: parent.right
513+
anchors.bottom: parent.bottom
514+
515+
sourceComponent: StyledRect {
516+
anchors.topMargin: Appearance.padding.small
517+
518+
implicitHeight: Appearance.padding.small
519+
520+
color: Colours.palette.m3tertiary
521+
522+
NumberAnimation on implicitWidth {
523+
from: root.width
524+
to: 0
525+
duration: Config.notifs.defaultExpireTimeout
526+
running: root.modelData.timer.running
527+
}
528+
}
529+
}
530+
440531
component Action: StyledRect {
441532
id: action
442533

0 commit comments

Comments
 (0)