diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-10 19:52:35 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-10 19:52:35 +1000 |
| commit | 4c892f53e842d224f55d7abbdcb3dd1520817bf4 (patch) | |
| tree | a404e1a42a5c186f9062485e2ee421feaddbd36e | |
| parent | notifs: minor fixes (diff) | |
| download | caelestia-shell-4c892f53e842d224f55d7abbdcb3dd1520817bf4.tar.gz caelestia-shell-4c892f53e842d224f55d7abbdcb3dd1520817bf4.tar.bz2 caelestia-shell-4c892f53e842d224f55d7abbdcb3dd1520817bf4.zip | |
notifs: slide to remove
| -rw-r--r-- | config/NotifsConfig.qml | 2 | ||||
| -rw-r--r-- | modules/notifications/Notification.qml | 45 |
2 files changed, 47 insertions, 0 deletions
diff --git a/config/NotifsConfig.qml b/config/NotifsConfig.qml index 1b5a852..66949f3 100644 --- a/config/NotifsConfig.qml +++ b/config/NotifsConfig.qml @@ -5,6 +5,8 @@ import QtQuick Singleton { readonly property int defaultExpireTimeout: 3000 + readonly property real clearThreshold: 0.3 + readonly property int expandThreshold: 30 readonly property Sizes sizes: Sizes {} component Sizes: QtObject { diff --git a/modules/notifications/Notification.qml b/modules/notifications/Notification.qml index a3fa171..c8a83ea 100644 --- a/modules/notifications/Notification.qml +++ b/modules/notifications/Notification.qml @@ -20,8 +20,48 @@ StyledRect { color: Colours.palette.m3surfaceContainer radius: Appearance.rounding.normal implicitWidth: NotifsConfig.sizes.width + implicitHeight: inner.height + + MouseArea { + property int startY + + anchors.fill: parent + hoverEnabled: true + preventStealing: true + + onEntered: root.modelData.timer.stop() + onExited: root.modelData.timer.start() + + drag.target: parent + drag.axis: Drag.XAxis + + onPressed: event => startY = event.y + onReleased: event => { + if (Math.abs(root.x) < NotifsConfig.sizes.width * NotifsConfig.clearThreshold) + root.x = 0; + else + root.modelData.popup = false; + } + onPositionChanged: event => { + if (pressed) { + const diffY = event.y - startY; + if (Math.abs(diffY) > NotifsConfig.expandThreshold) + root.expanded = diffY > 0; + } + } + } + + Behavior on x { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.emphasizedDecel + } + } Item { + id: inner + anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top @@ -160,6 +200,11 @@ StyledRect { text: root.expanded ? "expand_less" : "expand_more" font.pointSize: Appearance.font.size.smaller } + + MouseArea { + anchors.fill: parent + onClicked: root.expanded = !root.expanded + } } StyledText { |