summaryrefslogtreecommitdiff
path: root/modules/sidebar/NotifDock.qml
diff options
context:
space:
mode:
Diffstat (limited to 'modules/sidebar/NotifDock.qml')
-rw-r--r--modules/sidebar/NotifDock.qml134
1 files changed, 15 insertions, 119 deletions
diff --git a/modules/sidebar/NotifDock.qml b/modules/sidebar/NotifDock.qml
index 0a6eeaa..e3267c3 100644
--- a/modules/sidebar/NotifDock.qml
+++ b/modules/sidebar/NotifDock.qml
@@ -89,133 +89,23 @@ Item {
}
}
- StyledListView {
+ StyledFlickable {
id: view
anchors.fill: parent
- spacing: Appearance.spacing.small
-
- model: ScriptModel {
- values: {
- const list = Notifs.list.filter(n => !n.closed).sort((a, b) => b.time - a.time).map(n => [n.appName, null]);
- return [...new Map(list).keys()];
- }
- }
+ flickableDirection: Flickable.VerticalFlick
+ contentWidth: width
+ contentHeight: notifList.implicitHeight
StyledScrollBar.vertical: StyledScrollBar {
flickable: view
}
- 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
+ NotifDockList {
+ id: notifList
- 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 {
- Anim {
- property: "opacity"
- from: 0
- to: 1
- }
- Anim {
- property: "scale"
- from: 0
- to: 1
- duration: Appearance.anim.durations.expressiveDefaultSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
- }
- }
-
- remove: Transition {
- Anim {
- property: "opacity"
- to: 0
- }
- Anim {
- property: "scale"
- to: 0.6
- }
- }
-
- move: Transition {
- Anim {
- properties: "opacity,scale"
- to: 1
- }
- Anim {
- property: "y"
- duration: Appearance.anim.durations.expressiveDefaultSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
- }
- }
-
- displaced: Transition {
- Anim {
- properties: "opacity,scale"
- to: 1
- }
- Anim {
- property: "y"
- duration: Appearance.anim.durations.expressiveDefaultSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
- }
+ props: root.props
}
}
}
@@ -226,8 +116,14 @@ Item {
repeat: true
interval: 50
onTriggered: {
- if (root.notifCount > 0)
- Notifs.list.find(n => !n.closed).close();
+ let next = null;
+ for (let i = 0; i < notifList.repeater.count; i++) {
+ next = notifList.repeater.itemAt(i);
+ if (!next?.closed)
+ break;
+ }
+ if (next)
+ next.closeAll();
else
stop();
}