Skip to content

Commit a2135b9

Browse files
committed
add close button and timeout progress indicators
1 parent 6f147b2 commit a2135b9

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: false
7+
property bool timeoutCircle: false
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 && panel) {
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: x = 0
@@ -312,12 +313,78 @@ StyledRect {
312313
font.pointSize: Appearance.font.size.small
313314
}
314315

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

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

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

@@ -438,6 +505,30 @@ StyledRect {
438505
}
439506
}
440507

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

0 commit comments

Comments
 (0)