summaryrefslogtreecommitdiff
path: root/modules/sidebar/NotifDock.qml
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-19 00:08:56 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-19 00:08:56 +1000
commit1e35caa6f7a3b8e3aaf77bfeb307d15c3ea7e32d (patch)
tree2b717d58ba7c41a0cf2130e83354daed88d6e6c0 /modules/sidebar/NotifDock.qml
parentnotifs: persistent notifs + better sidebar notifs (diff)
downloadcaelestia-shell-1e35caa6f7a3b8e3aaf77bfeb307d15c3ea7e32d.tar.gz
caelestia-shell-1e35caa6f7a3b8e3aaf77bfeb307d15c3ea7e32d.tar.bz2
caelestia-shell-1e35caa6f7a3b8e3aaf77bfeb307d15c3ea7e32d.zip
sidebar/notifs: add mouse actions
Diffstat (limited to 'modules/sidebar/NotifDock.qml')
-rw-r--r--modules/sidebar/NotifDock.qml63
1 files changed, 60 insertions, 3 deletions
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 {