From 1e35caa6f7a3b8e3aaf77bfeb307d15c3ea7e32d Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Fri, 19 Sep 2025 00:08:56 +1000 Subject: sidebar/notifs: add mouse actions --- modules/sidebar/NotifDock.qml | 63 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) (limited to 'modules/sidebar/NotifDock.qml') diff --git a/modules/sidebar/NotifDock.qml b/modules/sidebar/NotifDock.qml index 490eeb8..7ddee30 100644 --- a/modules/sidebar/NotifDock.qml +++ b/modules/sidebar/NotifDock.qml @@ -95,11 +95,68 @@ Item { clip: true model: ScriptModel { - values: [...new Set(Notifs.list.map(notif => notif.appName))].reverse() + values: [...new Set(Notifs.list.filter(n => !n.closed).map(n => n.appName))].reverse() } - delegate: NotifGroup { - props: root.props + delegate: MouseArea { + id: notif + + required property int index + required property string modelData + + property int startY + + function closeAll(): void { + for (const n of Notifs.list.filter(n => !n.closed && n.appName === modelData)) + n.close(); + } + + implicitWidth: root.width + implicitHeight: notifInner.implicitHeight + + hoverEnabled: true + cursorShape: pressed ? Qt.ClosedHandCursor : undefined + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton + preventStealing: true + + drag.target: this + drag.axis: Drag.XAxis + + onPressed: event => { + if (event.button === Qt.LeftButton) + startY = event.y; + else if (event.button === Qt.RightButton) + notifInner.toggleExpand(); + else if (event.button === Qt.MiddleButton) + closeAll(); + } + onPositionChanged: event => { + if (pressed) { + const diffY = event.y - startY; + if (Math.abs(diffY) > Config.notifs.expandThreshold) + notifInner.toggleExpand(diffY > 0); + } + } + onReleased: event => { + if (Math.abs(x) < width * Config.notifs.clearThreshold) + x = 0; + else + closeAll(); + } + + NotifGroup { + id: notifInner + + modelData: notif.modelData + props: root.props + } + + Behavior on x { + Anim { + duration: Appearance.anim.durations.expressiveDefaultSpatial + easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial + } + } } add: Transition { -- cgit v1.2.3-freya