forked from Shinonome/dots-hyprland
waffles: notif center: drag to dismiss
This commit is contained in:
@@ -100,7 +100,7 @@ ListView {
|
|||||||
to: 1,
|
to: 1,
|
||||||
}),
|
}),
|
||||||
] : []
|
] : []
|
||||||
}
|
}
|
||||||
|
|
||||||
move: Transition {
|
move: Transition {
|
||||||
animations: root.animateMovement ? [
|
animations: root.animateMovement ? [
|
||||||
|
|||||||
@@ -7,6 +7,20 @@ ListView {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
boundsBehavior: Flickable.DragOverBounds
|
boundsBehavior: Flickable.DragOverBounds
|
||||||
|
|
||||||
ScrollBar.vertical: WScrollBar {}
|
ScrollBar.vertical: WScrollBar {}
|
||||||
|
|
||||||
|
displaced: Transition {
|
||||||
|
animations: [Looks.transition.enter.createObject(this, {
|
||||||
|
property: "y"
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
remove: Transition {
|
||||||
|
ParallelAnimation {
|
||||||
|
NumberAnimation { property: "opacity"; to: 0; duration: 1000 }
|
||||||
|
NumberAnimation { properties: "x,y"; to: 100; duration: 1000 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -53,10 +53,9 @@ BodyRectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledListView {
|
WListView {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
animateAppearance: false
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
model: Notifications.appNameList
|
model: Notifications.appNameList
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import qs.modules.common
|
||||||
|
import qs.modules.common.widgets
|
||||||
|
import qs.modules.common.functions
|
||||||
|
import qs.modules.waffle.looks
|
||||||
|
|
||||||
|
SequentialAnimation {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
required property var target
|
||||||
|
|
||||||
|
PropertyAction {
|
||||||
|
target: root.target
|
||||||
|
property: "ListView.delayRemove"
|
||||||
|
value: true
|
||||||
|
}
|
||||||
|
NumberAnimation {
|
||||||
|
target: root.target
|
||||||
|
property: "x"
|
||||||
|
to: root.target.width
|
||||||
|
duration: 250
|
||||||
|
easing.type: Easing.BezierSpline
|
||||||
|
easing.bezierCurve: Looks.transition.easing.bezierCurve.easeIn
|
||||||
|
}
|
||||||
|
PropertyAction {
|
||||||
|
target: root.target
|
||||||
|
property: "ListView.delayRemove"
|
||||||
|
value: false
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
-10
@@ -1,3 +1,4 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
@@ -18,10 +19,44 @@ MouseArea {
|
|||||||
implicitWidth: contentLayout.implicitWidth
|
implicitWidth: contentLayout.implicitWidth
|
||||||
implicitHeight: contentLayout.implicitHeight
|
implicitHeight: contentLayout.implicitHeight
|
||||||
|
|
||||||
|
function dismissAll() {
|
||||||
|
root.notifications.forEach(notif => {
|
||||||
|
Qt.callLater(() => {
|
||||||
|
Notifications.discardNotification(notif.notificationId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
removeAnimation.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
WNotificationDismissAnim {
|
||||||
|
id: removeAnimation
|
||||||
|
target: root
|
||||||
|
}
|
||||||
|
|
||||||
|
property real dragDismissThreshold: 100
|
||||||
|
drag {
|
||||||
|
axis: Drag.XAxis
|
||||||
|
target: contentLayout
|
||||||
|
minimumX: 0
|
||||||
|
onActiveChanged: {
|
||||||
|
if (drag.active)
|
||||||
|
return;
|
||||||
|
if (contentLayout.x > root.dragDismissThreshold) {
|
||||||
|
root.dismissAll();
|
||||||
|
} else {
|
||||||
|
contentLayout.x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: contentLayout
|
id: contentLayout
|
||||||
anchors.fill: parent
|
|
||||||
spacing: 4
|
spacing: 4
|
||||||
|
width: root.width
|
||||||
|
|
||||||
|
Behavior on x {
|
||||||
|
animation: Looks.transition.enter.createObject(this)
|
||||||
|
}
|
||||||
|
|
||||||
GroupHeader {
|
GroupHeader {
|
||||||
id: notifHeader
|
id: notifHeader
|
||||||
@@ -29,7 +64,9 @@ MouseArea {
|
|||||||
Layout.margins: 11
|
Layout.margins: 11
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
WListView {
|
||||||
|
Layout.leftMargin: -Math.min(35, contentLayout.x)
|
||||||
|
Layout.rightMargin: -Layout.leftMargin
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
implicitWidth: notifHeader.implicitWidth
|
implicitWidth: notifHeader.implicitWidth
|
||||||
implicitHeight: contentHeight
|
implicitHeight: contentHeight
|
||||||
@@ -40,14 +77,20 @@ MouseArea {
|
|||||||
objectProp: "notificationId"
|
objectProp: "notificationId"
|
||||||
}
|
}
|
||||||
delegate: WSingleNotification {
|
delegate: WSingleNotification {
|
||||||
|
id: singleNotif
|
||||||
required property int index
|
required property int index
|
||||||
required property var modelData
|
required property var modelData
|
||||||
|
|
||||||
width: ListView.view.width
|
width: ListView.view.width
|
||||||
notification: modelData
|
notification: modelData
|
||||||
|
|
||||||
groupExpandControlMessage: {
|
groupExpandControlMessage: {
|
||||||
if (root.notifications.length <= 1) return "";
|
if (root.notifications.length <= 1)
|
||||||
if (!root.expanded) return Translation.tr("+%1 notifications").arg(root.notifications.length - 1);
|
return "";
|
||||||
if (index === root.notifications.length - 1) return Translation.tr("See fewer");
|
if (!root.expanded)
|
||||||
|
return Translation.tr("+%1 notifications").arg(root.notifications.length - 1);
|
||||||
|
if (index === root.notifications.length - 1)
|
||||||
|
return Translation.tr("See fewer");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
onGroupExpandToggle: {
|
onGroupExpandToggle: {
|
||||||
@@ -94,11 +137,7 @@ MouseArea {
|
|||||||
Layout.rightMargin: 3
|
Layout.rightMargin: 3
|
||||||
icon.name: "dismiss"
|
icon.name: "dismiss"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.notifications.forEach(notif => {
|
root.dismissAll();
|
||||||
Qt.callLater(() => {
|
|
||||||
Notifications.discardNotification(notif.notificationId);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-6
@@ -18,6 +18,18 @@ MouseArea {
|
|||||||
signal groupExpandToggle
|
signal groupExpandToggle
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
|
function dismiss() {
|
||||||
|
Qt.callLater(() => {
|
||||||
|
Notifications.discardNotification(root.notification?.notificationId);
|
||||||
|
});
|
||||||
|
removeAnimation.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
WNotificationDismissAnim {
|
||||||
|
id: removeAnimation
|
||||||
|
target: root
|
||||||
|
}
|
||||||
|
|
||||||
implicitHeight: contentItem.implicitHeight
|
implicitHeight: contentItem.implicitHeight
|
||||||
implicitWidth: contentItem.implicitWidth
|
implicitWidth: contentItem.implicitWidth
|
||||||
|
|
||||||
@@ -25,9 +37,25 @@ MouseArea {
|
|||||||
animation: Looks.transition.enter.createObject(this)
|
animation: Looks.transition.enter.createObject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property real dragDismissThreshold: 100
|
||||||
|
drag {
|
||||||
|
axis: Drag.XAxis
|
||||||
|
target: contentItem
|
||||||
|
minimumX: 0
|
||||||
|
onActiveChanged: {
|
||||||
|
if (drag.active)
|
||||||
|
return;
|
||||||
|
if (contentItem.x > root.dragDismissThreshold) {
|
||||||
|
root.dismiss();
|
||||||
|
} else {
|
||||||
|
contentItem.x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: contentItem
|
id: contentItem
|
||||||
anchors.fill: parent
|
width: parent.width
|
||||||
color: Looks.colors.bgPanelBody
|
color: Looks.colors.bgPanelBody
|
||||||
radius: Looks.radius.medium
|
radius: Looks.radius.medium
|
||||||
property real padding: 12
|
property real padding: 12
|
||||||
@@ -36,6 +64,10 @@ MouseArea {
|
|||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: ColorUtils.applyAlpha(Looks.colors.ambientShadow, 0.1)
|
border.color: ColorUtils.applyAlpha(Looks.colors.ambientShadow, 0.1)
|
||||||
|
|
||||||
|
Behavior on x {
|
||||||
|
animation: Looks.transition.enter.createObject(this)
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: notificationContent
|
id: notificationContent
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -128,11 +160,7 @@ MouseArea {
|
|||||||
opacity: root.containsMouse ? 1 : 0
|
opacity: root.containsMouse ? 1 : 0
|
||||||
icon.name: "dismiss"
|
icon.name: "dismiss"
|
||||||
implicitSize: 12
|
implicitSize: 12
|
||||||
onClicked: {
|
onClicked: root.dismiss()
|
||||||
Qt.callLater(() => {
|
|
||||||
Notifications.discardNotification(root.notification?.notificationId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user