**animations**
oops
This commit is contained in:
+162
-125
@@ -1,167 +1,204 @@
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
import QtQuick.Layouts
|
||||
import QtQuick
|
||||
import Quickshell.Services.Notifications
|
||||
import qs.Config
|
||||
import qs.Daemons
|
||||
import qs.Helpers
|
||||
|
||||
PanelWindow {
|
||||
id: root
|
||||
color: "transparent"
|
||||
screen: root.bar.screen
|
||||
anchors {
|
||||
top: true
|
||||
right: true
|
||||
left: true
|
||||
bottom: true
|
||||
}
|
||||
mask: Region { item: backgroundRect }
|
||||
mask: Region { regions: root.notifRegions }
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
required property Notification notif
|
||||
required property int centerX
|
||||
required property list<int> notifIndex
|
||||
property int index: notifIndex.indexOf(notif.id)
|
||||
property alias y: backgroundRect.y
|
||||
property alias notifHeight: backgroundRect.implicitHeight
|
||||
signal notifDestroy()
|
||||
property list<Region> notifRegions: []
|
||||
required property bool centerShown
|
||||
required property PanelWindow bar
|
||||
visible: Hyprland.monitorFor(screen).focused
|
||||
|
||||
Component.onCompleted: {
|
||||
openAnim.start();
|
||||
console.log(root.index);
|
||||
console.log(NotifServer.list.filter( n => n.popup ).length + " notification popups loaded.");
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timeout
|
||||
interval: 5000
|
||||
onTriggered: {
|
||||
closeAnim.start();
|
||||
ListView {
|
||||
id: notifListView
|
||||
model: ScriptModel {
|
||||
values: NotifServer.list.filter( n => n.popup )
|
||||
}
|
||||
}
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
x: root.centerShown ? root.bar.width - width - 420 : root.bar.width - width - 20
|
||||
z: 0
|
||||
anchors.topMargin: 54
|
||||
width: 400
|
||||
spacing: 10
|
||||
|
||||
NumberAnimation {
|
||||
id: openAnim
|
||||
target: backgroundRect
|
||||
property: "x"
|
||||
from: root.centerX
|
||||
to: root.centerX - backgroundRect.implicitWidth - 20
|
||||
duration: 200
|
||||
easing.type: Easing.InOutQuad
|
||||
onStopped: { timeout.start(); }
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: closeAnim
|
||||
target: backgroundRect
|
||||
property: "x"
|
||||
from: root.centerX - backgroundRect.implicitWidth - 20
|
||||
to: root.centerX
|
||||
duration: 200
|
||||
easing.type: Easing.InOutQuad
|
||||
onStopped: {
|
||||
root.destroy();
|
||||
root.notifDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: backgroundRect
|
||||
implicitWidth: 400
|
||||
implicitHeight: contentLayout.childrenRect.height + 16
|
||||
x: root.centerX - implicitWidth - 20
|
||||
y: !root.notifList[ root.index - 1 ] ? 34 + 20 : root.notifList[ root.index - 1 ].y + root.notifList[ root.index - 1 ].notifHeight + 10
|
||||
color: Config.baseBgColor
|
||||
border.color: "#555555"
|
||||
radius: 8
|
||||
|
||||
Behavior on y {
|
||||
Behavior on x {
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
duration: MaterialEasing.expressiveEffectsTime
|
||||
easing.bezierCurve: MaterialEasing.expressiveEffects
|
||||
}
|
||||
}
|
||||
|
||||
displaced: Transition {
|
||||
NumberAnimation {
|
||||
property: "y"
|
||||
duration: 100
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: contentLayout
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.margins: 10
|
||||
spacing: 8
|
||||
RowLayout {
|
||||
spacing: 12
|
||||
IconImage {
|
||||
source: root.notif.image
|
||||
Layout.preferredWidth: 48
|
||||
Layout.preferredHeight: 48
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignLeft
|
||||
visible: root.notif.image !== ""
|
||||
remove: Transition {
|
||||
id: hideTransition
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
from: 1
|
||||
to: 0
|
||||
duration: 200
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.leftMargin: 0
|
||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
||||
|
||||
Text {
|
||||
text: root.notif.appName
|
||||
color: "white"
|
||||
font.bold: true
|
||||
font.pointSize: 14
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Text {
|
||||
text: root.notif.summary
|
||||
color: "white"
|
||||
font.pointSize: 12
|
||||
font.bold: true
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
property: "x"
|
||||
to: hideTransition.ViewTransition.destination.x + 200
|
||||
duration: 200
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: root.notif.body
|
||||
color: "#dddddd"
|
||||
font.pointSize: 14
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: 4
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.rightMargin: 6
|
||||
anchors.topMargin: 6
|
||||
width: 18
|
||||
height: 18
|
||||
color: closeArea.containsMouse ? "#FF6077" : "transparent"
|
||||
radius: 9
|
||||
add: Transition {
|
||||
id: showTransition
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 1
|
||||
duration: 200
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "✕"
|
||||
color: closeArea.containsMouse ? "white" : "#888888"
|
||||
font.pointSize: 12
|
||||
NumberAnimation {
|
||||
property: "x"
|
||||
from: showTransition.ViewTransition.destination.x + 200
|
||||
to: showTransition.ViewTransition.destination.x
|
||||
duration: 200
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component NotifRegion: Region { }
|
||||
|
||||
Component {
|
||||
id: notifRegion
|
||||
NotifRegion {}
|
||||
}
|
||||
|
||||
delegate: Rectangle {
|
||||
id: backgroundRect
|
||||
required property NotifServer.Notif modelData
|
||||
implicitWidth: 400
|
||||
implicitHeight: contentLayout.childrenRect.height + 16
|
||||
color: Config.baseBgColor
|
||||
border.color: "#555555"
|
||||
radius: 8
|
||||
|
||||
Component.onCompleted: {
|
||||
root.notifRegions.push( notifRegion.createObject(root, { item: backgroundRect }));
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: closeArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
root.notif.dismiss();
|
||||
root.visible = false;
|
||||
Column {
|
||||
id: contentLayout
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.margins: 10
|
||||
spacing: 8
|
||||
RowLayout {
|
||||
spacing: 12
|
||||
IconImage {
|
||||
source: backgroundRect.modelData.image
|
||||
Layout.preferredWidth: 48
|
||||
Layout.preferredHeight: 48
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignLeft
|
||||
visible: backgroundRect.modelData.image !== ""
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.leftMargin: 0
|
||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
||||
|
||||
Text {
|
||||
text: backgroundRect.modelData.appName
|
||||
color: "white"
|
||||
font.bold: true
|
||||
font.pointSize: 14
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Text {
|
||||
text: backgroundRect.modelData.summary
|
||||
color: "white"
|
||||
font.pointSize: 12
|
||||
font.bold: true
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: backgroundRect.modelData.body
|
||||
color: "#dddddd"
|
||||
font.pointSize: 14
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: 4
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.rightMargin: 6
|
||||
anchors.topMargin: 6
|
||||
width: 18
|
||||
height: 18
|
||||
color: closeArea.containsMouse ? "#FF6077" : "transparent"
|
||||
radius: 9
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "✕"
|
||||
color: closeArea.containsMouse ? "white" : "#888888"
|
||||
font.pointSize: 12
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: closeArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
backgroundRect.modelData.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user