feat: add clear all button for notifications
This commit is contained in:
parent
9aa6046cdd
commit
3fb7f739e2
4 changed files with 64 additions and 37 deletions
|
@ -31,6 +31,13 @@ Singleton {
|
|||
|
||||
property alias list: server.trackedNotifications
|
||||
|
||||
function clearAll() {
|
||||
const len = server.trackedNotifications.values.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
list.values[0].dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
signal incomingRemoved(id: int)
|
||||
signal incomingAdded(id: Notification)
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ Singleton {
|
|||
return day ? "weather-few-clouds" : "weather-few-clouds-night";
|
||||
case "122":
|
||||
return "weather-overcast";
|
||||
case "176":
|
||||
case "296":
|
||||
return day ? "weather-showers-scattered" : "weather-showers-scattered-night";
|
||||
default:
|
||||
|
|
|
@ -1,53 +1,71 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import "../../provider"
|
||||
import "../../base"
|
||||
|
||||
ColumnLayout {
|
||||
Layout.preferredHeight: 1000
|
||||
|
||||
ListView {
|
||||
id: popupcol
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 1000
|
||||
spacing: 10
|
||||
|
||||
width: parent.width
|
||||
Component.onCompleted: () => {}
|
||||
|
||||
model: Notifications.list
|
||||
|
||||
delegate: NotificationToast {
|
||||
id: toast
|
||||
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
notif: modelData
|
||||
width: ListView.view.width
|
||||
|
||||
onClose: {
|
||||
toast.notif.dismiss();
|
||||
BButton {
|
||||
width: 30
|
||||
height: 30
|
||||
onClicked: () => {
|
||||
Notifications.clearAll();
|
||||
}
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
|
||||
addDisplaced: Transition {
|
||||
NumberAnimation {
|
||||
properties: "x,y"
|
||||
duration: 100
|
||||
}
|
||||
}
|
||||
remove: Transition {
|
||||
PropertyAction {
|
||||
property: "ListView.delayRemove"
|
||||
value: true
|
||||
}
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
to: 0
|
||||
duration: 200
|
||||
ListView {
|
||||
id: popupcol
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
spacing: 10
|
||||
width: parent.width
|
||||
|
||||
model: Notifications.list
|
||||
|
||||
delegate: NotificationToast {
|
||||
id: toast
|
||||
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
notif: modelData
|
||||
width: ListView.view.width
|
||||
|
||||
onClose: {
|
||||
toast.notif.dismiss();
|
||||
}
|
||||
}
|
||||
PropertyAction {
|
||||
property: "ListView.delayRemove"
|
||||
value: true
|
||||
|
||||
addDisplaced: Transition {
|
||||
NumberAnimation {
|
||||
properties: "x,y"
|
||||
duration: 100
|
||||
}
|
||||
}
|
||||
remove: Transition {
|
||||
PropertyAction {
|
||||
property: "ListView.delayRemove"
|
||||
value: true
|
||||
}
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
to: 0
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
PropertyAction {
|
||||
property: "ListView.delayRemove"
|
||||
value: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ MouseArea {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
id: actions
|
||||
width: parent.width
|
||||
|
|
Loading…
Add table
Reference in a new issue