mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-14 17:52:10 -04:00
notifications: initial refactory of popups
This commit is contained in:
@@ -10,13 +10,28 @@ import qs.Widgets
|
|||||||
PanelWindow {
|
PanelWindow {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
visible: NotificationService.groupedPopups.length > 0
|
required property var notificationData // Individual notification wrapper
|
||||||
|
required property string notificationId
|
||||||
|
readonly property bool isPopup: notificationData.popup
|
||||||
|
readonly property int expireTimeout: notificationData.notification.expireTimeout
|
||||||
|
|
||||||
|
property int verticalOffset: 0
|
||||||
|
property bool initialAnimation: true
|
||||||
|
property bool fadingOut: false
|
||||||
|
property bool slideOut: false
|
||||||
|
property bool entering: true
|
||||||
|
|
||||||
|
signal entered()
|
||||||
|
signal exitFinished()
|
||||||
|
|
||||||
|
visible: isPopup || fadingOut || slideOut
|
||||||
WlrLayershell.layer: WlrLayershell.Overlay
|
WlrLayershell.layer: WlrLayershell.Overlay
|
||||||
WlrLayershell.exclusiveZone: -1
|
WlrLayershell.exclusiveZone: -1
|
||||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
implicitWidth: 400
|
implicitWidth: 400
|
||||||
implicitHeight: Math.min(Screen.height * 0.6, Math.max(400, (notificationsList.contentHeight || 0) + 32))
|
implicitHeight: 116 // Individual notifications have fixed height
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: true
|
top: true
|
||||||
@@ -24,67 +39,98 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
margins {
|
margins {
|
||||||
top: Theme.barHeight
|
top: Theme.barHeight + 16 + verticalOffset
|
||||||
right: 12
|
right: 12
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Behavior on verticalOffset {
|
||||||
anchors.top: parent.top
|
NumberAnimation {
|
||||||
anchors.right: parent.right
|
duration: Anims.durMed
|
||||||
anchors.topMargin: 16
|
easing.type: Easing.BezierSpline
|
||||||
anchors.rightMargin: 16
|
easing.bezierCurve: Anims.emphasized
|
||||||
anchors.bottomMargin: 16
|
}
|
||||||
width: 380
|
}
|
||||||
height: Math.min(Screen.height * 0.6 - 32, Math.max(368, (notificationsList.contentHeight || 0) + 32))
|
|
||||||
color: "transparent"
|
|
||||||
radius: 12
|
|
||||||
clip: true
|
|
||||||
|
|
||||||
ScrollView {
|
Timer {
|
||||||
anchors.fill: parent
|
id: enterDelay
|
||||||
clip: true
|
interval: Anims.durMed // must match the entrance duration
|
||||||
|
repeat: false
|
||||||
Column {
|
onTriggered: notificationData.timer.start()
|
||||||
id: notificationsList
|
}
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
spacing: 12
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: NotificationService.groupedPopups
|
|
||||||
|
|
||||||
delegate: Rectangle {
|
|
||||||
required property var modelData
|
|
||||||
readonly property bool expanded: NotificationService.expandedGroups[modelData.key] || false
|
|
||||||
readonly property string groupKey: modelData.key
|
|
||||||
readonly property bool isPopup: modelData.latestNotification.popup
|
|
||||||
readonly property int expireTimeout: modelData.latestNotification.notification.expireTimeout
|
|
||||||
property string stableGroupKey: ""
|
|
||||||
property var currentLatestNotification: modelData.latestNotification
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
stableGroupKey = modelData.key;
|
initialAnimation = false; // kicks the right→left slide-in
|
||||||
|
enterDelay.start(); // start TTL after entrance
|
||||||
}
|
}
|
||||||
width: parent.width
|
|
||||||
height: {
|
Connections {
|
||||||
if (expanded && modelData.count >= 1) {
|
target: notificationData
|
||||||
const baseHeight = (116 * modelData.count) + (12 * (modelData.count - 1));
|
function onPopupChanged() {
|
||||||
const bottomMargin = modelData.count === 1 ? 70 : (modelData.count < 3 ? 50 : -28);
|
if (!notificationData.popup) {
|
||||||
return baseHeight + bottomMargin;
|
if (notificationData.removedByLimit) {
|
||||||
|
slideOut = true;
|
||||||
|
} else {
|
||||||
|
fadingOut = true;
|
||||||
}
|
}
|
||||||
return 116;
|
// When a notification is no longer a popup, we want to remove it from the visible list
|
||||||
|
// so that other notifications can move into its place.
|
||||||
|
NotificationService.removeFromVisibleNotifications(notificationData);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 4
|
||||||
radius: Theme.cornerRadiusLarge
|
radius: Theme.cornerRadiusLarge
|
||||||
color: Theme.popupBackground()
|
color: Theme.popupBackground()
|
||||||
border.color: modelData.latestNotification.urgency === 2 ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3) : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
border.color: notificationData.urgency === 2 ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3) : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
||||||
border.width: modelData.latestNotification.urgency === 2 ? 2 : 1
|
border.width: notificationData.urgency === 2 ? 2 : 1
|
||||||
clip: true
|
clip: true
|
||||||
onCurrentLatestNotificationChanged: {
|
opacity: (fadingOut || slideOut) ? 0 : 1
|
||||||
if (isPopup && !cardHoverArea.containsMouse)
|
scale: slideOut ? 0.98 : 1.0
|
||||||
dismissTimer.restart();
|
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 180
|
||||||
|
easing.type: Easing.BezierSpline
|
||||||
|
easing.bezierCurve: Anims.emphasized
|
||||||
|
onRunningChanged: if (!running && opacity === 0) root.visible = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Behavior on scale {
|
||||||
|
NumberAnimation { duration: 160; easing.type: Easing.OutCubic }
|
||||||
|
}
|
||||||
|
|
||||||
|
transform: Translate {
|
||||||
|
x: {
|
||||||
|
if (initialAnimation) return 400; // start off-screen right
|
||||||
|
if (slideOut) return 64; // gentle nudge on exit (was 400)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Behavior on x {
|
||||||
|
enabled: initialAnimation || slideOut
|
||||||
|
NumberAnimation {
|
||||||
|
id: xAnim
|
||||||
|
duration: Anims.durMed
|
||||||
|
easing.type: Easing.BezierSpline
|
||||||
|
easing.bezierCurve: slideOut ? Anims.emphasized : Anims.emphasizedDecel
|
||||||
|
onRunningChanged: {
|
||||||
|
if (!running) {
|
||||||
|
if (!slideOut) { // entrance finished
|
||||||
|
entering = false;
|
||||||
|
entered();
|
||||||
|
} else { // exit finished
|
||||||
|
exitFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shadow layers
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: -3
|
anchors.margins: -3
|
||||||
@@ -114,10 +160,11 @@ PanelWindow {
|
|||||||
z: -1
|
z: -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Critical notification accent
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: parent.radius
|
radius: parent.radius
|
||||||
visible: modelData.latestNotification.urgency === 2
|
visible: notificationData.urgency === 2
|
||||||
opacity: 1
|
opacity: 1
|
||||||
|
|
||||||
gradient: Gradient {
|
gradient: Gradient {
|
||||||
@@ -137,14 +184,11 @@ PanelWindow {
|
|||||||
position: 0.021
|
position: 0.021
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: collapsedContent
|
id: notificationContent
|
||||||
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
@@ -152,13 +196,11 @@ PanelWindow {
|
|||||||
anchors.leftMargin: 16
|
anchors.leftMargin: 16
|
||||||
anchors.rightMargin: 16
|
anchors.rightMargin: 16
|
||||||
height: 86
|
height: 86
|
||||||
visible: !expanded
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: iconContainer
|
id: iconContainer
|
||||||
|
readonly property bool hasNotificationImage: notificationData.image && notificationData.image !== ""
|
||||||
readonly property bool hasNotificationImage: modelData.latestNotification.image && modelData.latestNotification.image !== ""
|
readonly property bool appIconIsImage: notificationData.appIcon && (notificationData.appIcon.startsWith("file://") || notificationData.appIcon.startsWith("http://") || notificationData.appIcon.startsWith("https://"))
|
||||||
readonly property bool appIconIsImage: modelData.latestNotification.appIcon && (modelData.latestNotification.appIcon.startsWith("file://") || modelData.latestNotification.appIcon.startsWith("http://") || modelData.latestNotification.appIcon.startsWith("https://"))
|
|
||||||
|
|
||||||
width: 55
|
width: 55
|
||||||
height: 55
|
height: 55
|
||||||
@@ -174,13 +216,12 @@ PanelWindow {
|
|||||||
anchors.margins: 2
|
anchors.margins: 2
|
||||||
source: {
|
source: {
|
||||||
if (parent.hasNotificationImage)
|
if (parent.hasNotificationImage)
|
||||||
return modelData.latestNotification.cleanImage;
|
return notificationData.cleanImage;
|
||||||
|
|
||||||
if (modelData.latestNotification.appIcon) {
|
if (notificationData.appIcon) {
|
||||||
const appIcon = modelData.latestNotification.appIcon;
|
const appIcon = notificationData.appIcon;
|
||||||
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://"))
|
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://"))
|
||||||
return appIcon;
|
return appIcon;
|
||||||
|
|
||||||
return Quickshell.iconPath(appIcon, "");
|
return Quickshell.iconPath(appIcon, "");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@@ -190,73 +231,40 @@ PanelWindow {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
visible: !parent.hasNotificationImage && (!modelData.latestNotification.appIcon || modelData.latestNotification.appIcon === "")
|
visible: !parent.hasNotificationImage && (!notificationData.appIcon || notificationData.appIcon === "")
|
||||||
text: {
|
text: {
|
||||||
const appName = modelData.appName || "?";
|
const appName = notificationData.appName || "?";
|
||||||
return appName.charAt(0).toUpperCase();
|
return appName.charAt(0).toUpperCase();
|
||||||
}
|
}
|
||||||
font.pixelSize: 20
|
font.pixelSize: 20
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
color: Theme.primaryText
|
color: Theme.primaryText
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
width: 18
|
|
||||||
height: 18
|
|
||||||
radius: 9
|
|
||||||
color: Theme.primary
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.topMargin: -2
|
|
||||||
anchors.rightMargin: -2
|
|
||||||
visible: modelData.count > 1
|
|
||||||
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: modelData.count > 99 ? "99+" : modelData.count.toString()
|
|
||||||
color: Theme.primaryText
|
|
||||||
font.pixelSize: 9
|
|
||||||
font.weight: Font.Bold
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: textContainer
|
id: textContainer
|
||||||
|
|
||||||
anchors.left: iconContainer.right
|
anchors.left: iconContainer.right
|
||||||
anchors.leftMargin: 12
|
anchors.leftMargin: 12
|
||||||
anchors.right: controlsContainer.left
|
anchors.right: closeButton.left
|
||||||
anchors.rightMargin: 0
|
anchors.rightMargin: 8
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: 8
|
anchors.bottomMargin: 8
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
opacity: 1
|
|
||||||
border.color: "transparent"
|
|
||||||
border.width: 0
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: parent.width
|
|
||||||
height: parent.height
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.topMargin: 2
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: textContent
|
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: {
|
text: {
|
||||||
if (modelData.latestNotification.timeStr.length > 0)
|
if (notificationData.timeStr.length > 0)
|
||||||
return modelData.appName + " • " + modelData.latestNotification.timeStr;
|
return notificationData.appName + " • " + notificationData.timeStr;
|
||||||
else
|
else
|
||||||
return modelData.appName;
|
return notificationData.appName;
|
||||||
}
|
}
|
||||||
color: Theme.surfaceVariantText
|
color: Theme.surfaceVariantText
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
@@ -266,7 +274,7 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: modelData.latestNotification.summary
|
text: notificationData.summary
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
@@ -279,11 +287,11 @@ PanelWindow {
|
|||||||
Text {
|
Text {
|
||||||
property bool hasUrls: {
|
property bool hasUrls: {
|
||||||
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
||||||
return urlRegex.test(modelData.latestNotification.body);
|
return urlRegex.test(notificationData.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
text: {
|
text: {
|
||||||
let bodyText = modelData.latestNotification.body;
|
let bodyText = notificationData.body;
|
||||||
if (bodyText.length > 105)
|
if (bodyText.length > 105)
|
||||||
bodyText = bodyText.substring(0, 102) + "...";
|
bodyText = bodyText.substring(0, 102) + "...";
|
||||||
|
|
||||||
@@ -294,7 +302,7 @@ PanelWindow {
|
|||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
width: parent.width
|
width: parent.width
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
maximumLineCount: modelData.count > 1 ? 1 : 2
|
maximumLineCount: 2
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
visible: text.length > 0
|
visible: text.length > 0
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
@@ -302,35 +310,11 @@ PanelWindow {
|
|||||||
Qt.openUrlExternally(link);
|
Qt.openUrlExternally(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: controlsContainer
|
|
||||||
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: 0
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.topMargin: 0
|
|
||||||
width: modelData.count > 1 ? 40 : 20
|
|
||||||
height: 24
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.top: parent.top
|
|
||||||
visible: modelData.count > 1
|
|
||||||
iconName: expanded ? "expand_less" : "expand_more"
|
|
||||||
iconSize: 14
|
|
||||||
buttonSize: 20
|
|
||||||
z: 15
|
|
||||||
onClicked: NotificationService.toggleGroupExpansion(modelData.key)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DankActionButton {
|
DankActionButton {
|
||||||
|
id: closeButton
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
iconName: "close"
|
iconName: "close"
|
||||||
@@ -338,501 +322,29 @@ PanelWindow {
|
|||||||
buttonSize: 20
|
buttonSize: 20
|
||||||
z: 15
|
z: 15
|
||||||
onClicked: {
|
onClicked: {
|
||||||
for (const notif of modelData.notifications) {
|
notificationData.popup = false;
|
||||||
notif.popup = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: 16
|
|
||||||
visible: expanded
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: expandedColumn
|
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
spacing: 10
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: parent.width
|
|
||||||
height: 32
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
spacing: 8
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: modelData.appName
|
|
||||||
color: Theme.surfaceText
|
|
||||||
font.pixelSize: Theme.fontSizeLarge
|
|
||||||
font.weight: Font.Bold
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
width: 20
|
|
||||||
height: 20
|
|
||||||
radius: 10
|
|
||||||
color: Theme.primary
|
|
||||||
visible: modelData.count > 1
|
|
||||||
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: modelData.count.toString()
|
|
||||||
color: Theme.primaryText
|
|
||||||
font.pixelSize: 10
|
|
||||||
font.weight: Font.Bold
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: expandedControls
|
|
||||||
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
width: 56
|
|
||||||
height: 24
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.fill: parent
|
|
||||||
spacing: 8
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
iconName: "expand_less"
|
|
||||||
iconSize: 14
|
|
||||||
buttonSize: 20
|
|
||||||
z: 15
|
|
||||||
onClicked: NotificationService.toggleGroupExpansion(modelData.key)
|
|
||||||
}
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
iconName: "close"
|
|
||||||
iconSize: 14
|
|
||||||
buttonSize: 20
|
|
||||||
z: 15
|
|
||||||
onClicked: {
|
|
||||||
for (const notif of modelData.notifications) {
|
|
||||||
notif.popup = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
width: parent.width
|
|
||||||
height: Math.min(400, modelData.notifications.length * 90) // Fixed height constraint for inner scroll
|
|
||||||
radius: Theme.cornerRadiusLarge
|
|
||||||
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.1)
|
|
||||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05)
|
|
||||||
border.width: 1
|
|
||||||
clip: true
|
|
||||||
|
|
||||||
ScrollView {
|
|
||||||
anchors.fill: parent
|
|
||||||
clip: true
|
|
||||||
|
|
||||||
Column {
|
|
||||||
width: parent.width
|
|
||||||
spacing: 16
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: modelData.notifications
|
|
||||||
|
|
||||||
delegate: Rectangle {
|
|
||||||
required property var modelData
|
|
||||||
readonly property bool messageExpanded: NotificationService.expandedMessages[modelData.notification.id] || false
|
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
height: messageExpanded ? Math.min(120, 50 + (bodyText.contentHeight || 0)) : 80
|
|
||||||
radius: Theme.cornerRadiusLarge
|
|
||||||
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.2)
|
|
||||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05)
|
|
||||||
border.width: 1
|
|
||||||
|
|
||||||
Item {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: 12
|
|
||||||
|
|
||||||
// Small icon for individual message
|
|
||||||
Rectangle {
|
|
||||||
id: messageIcon
|
|
||||||
|
|
||||||
readonly property bool hasNotificationImage: modelData.image && modelData.image !== ""
|
|
||||||
readonly property bool appIconIsImage: modelData.appIcon && (modelData.appIcon.startsWith("file://") || modelData.appIcon.startsWith("http://") || modelData.appIcon.startsWith("https://"))
|
|
||||||
|
|
||||||
width: 32
|
|
||||||
height: 32
|
|
||||||
radius: 16
|
|
||||||
color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1)
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.top: parent.top
|
|
||||||
|
|
||||||
IconImage {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: 2
|
|
||||||
source: {
|
|
||||||
// Priority 1: Use notification image if available
|
|
||||||
if (parent.hasNotificationImage)
|
|
||||||
return modelData.cleanImage;
|
|
||||||
|
|
||||||
// Priority 2: Use appIcon - handle URLs directly, use iconPath for icon names
|
|
||||||
if (modelData.appIcon) {
|
|
||||||
const appIcon = modelData.appIcon;
|
|
||||||
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://"))
|
|
||||||
return appIcon;
|
|
||||||
|
|
||||||
return Quickshell.iconPath(appIcon, "");
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
visible: status === Image.Ready
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
visible: !parent.hasNotificationImage && (!modelData.appIcon || modelData.appIcon === "")
|
|
||||||
text: {
|
|
||||||
const appName = modelData.appName || "?";
|
|
||||||
return appName.charAt(0).toUpperCase();
|
|
||||||
}
|
|
||||||
font.pixelSize: 14
|
|
||||||
font.weight: Font.Bold
|
|
||||||
color: Theme.primaryText
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message content
|
|
||||||
Column {
|
|
||||||
anchors.left: messageIcon.right
|
|
||||||
anchors.leftMargin: 12
|
|
||||||
anchors.right: messageControls.left
|
|
||||||
anchors.rightMargin: 0
|
|
||||||
anchors.top: parent.top
|
|
||||||
spacing: 4
|
|
||||||
|
|
||||||
// App Title • Timestamp line
|
|
||||||
Text {
|
|
||||||
width: parent.width
|
|
||||||
text: {
|
|
||||||
const appName = modelData.appName || "";
|
|
||||||
const timeStr = modelData.timeStr || "";
|
|
||||||
if (timeStr.length > 0)
|
|
||||||
return appName + " • " + timeStr;
|
|
||||||
else
|
|
||||||
return appName;
|
|
||||||
}
|
|
||||||
color: Theme.surfaceVariantText
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
font.weight: Font.Medium
|
|
||||||
elide: Text.ElideRight
|
|
||||||
maximumLineCount: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Summary line (if exists)
|
|
||||||
Text {
|
|
||||||
width: parent.width
|
|
||||||
text: modelData.summary || ""
|
|
||||||
color: Theme.surfaceText
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
font.weight: Font.Medium
|
|
||||||
elide: Text.ElideRight
|
|
||||||
maximumLineCount: 1
|
|
||||||
visible: text.length > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Body text with expand capability
|
|
||||||
Text {
|
|
||||||
id: bodyText
|
|
||||||
|
|
||||||
property bool hasUrls: {
|
|
||||||
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
||||||
return urlRegex.test(modelData.body || "");
|
|
||||||
}
|
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
text: {
|
|
||||||
let bodyText = modelData.body || "";
|
|
||||||
if (messageExpanded)
|
|
||||||
bodyText = bodyText.length > 500 ? bodyText.substring(0, 497) + "..." : bodyText;
|
|
||||||
else
|
|
||||||
bodyText = bodyText.length > 80 ? bodyText.substring(0, 77) + "..." : bodyText;
|
|
||||||
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
||||||
return bodyText.replace(urlRegex, '<a href="$1" style="color: ' + Theme.primary + '; text-decoration: underline;">$1</a>');
|
|
||||||
}
|
|
||||||
color: Theme.surfaceVariantText
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
elide: messageExpanded ? Text.ElideNone : Text.ElideRight
|
|
||||||
maximumLineCount: messageExpanded ? -1 : 2
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
visible: text.length > 0
|
|
||||||
textFormat: Text.RichText
|
|
||||||
onLinkActivated: function(link) {
|
|
||||||
Qt.openUrlExternally(link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message controls (expand and close buttons)
|
|
||||||
Row {
|
|
||||||
id: messageControls
|
|
||||||
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: parent.top
|
|
||||||
spacing: 4
|
|
||||||
|
|
||||||
// Expand/collapse button for individual message
|
|
||||||
DankActionButton {
|
|
||||||
visible: (modelData.body || "").length > 80
|
|
||||||
iconName: messageExpanded ? "expand_less" : "expand_more"
|
|
||||||
iconSize: 12
|
|
||||||
buttonSize: 20
|
|
||||||
z: 15
|
|
||||||
onClicked: NotificationService.toggleMessageExpansion(modelData.notification.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close button for individual message
|
|
||||||
DankActionButton {
|
|
||||||
iconName: "close"
|
|
||||||
iconSize: 12
|
|
||||||
buttonSize: 20
|
|
||||||
z: 15
|
|
||||||
onClicked: NotificationService.dismissNotification(modelData)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on height {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Theme.shortDuration
|
|
||||||
easing.type: Theme.standardEasing
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main hover area for persistence and click handling
|
// Main hover area for persistence and click handling
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: cardHoverArea
|
id: cardHoverArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
propagateComposedEvents: true
|
propagateComposedEvents: true
|
||||||
z: 0
|
z: 0
|
||||||
onEntered: {
|
onEntered: {
|
||||||
dismissTimer.stop();
|
notificationData.timer.stop();
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
if (modelData.latestNotification.popup)
|
if (notificationData.popup)
|
||||||
dismissTimer.restart();
|
notificationData.timer.restart();
|
||||||
|
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
for (const notif of modelData.notifications) {
|
notificationData.popup = false;
|
||||||
notif.popup = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action buttons positioned at bottom-left of notification card
|
|
||||||
Row {
|
|
||||||
anchors.right: dismissButton.left
|
|
||||||
anchors.rightMargin: 8
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.bottomMargin: 8
|
|
||||||
spacing: 4
|
|
||||||
z: 10
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: modelData.latestNotification.actions || []
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
property bool isHovered: false
|
|
||||||
|
|
||||||
width: Math.min(actionText.contentWidth + 12, 70)
|
|
||||||
height: 24
|
|
||||||
radius: 4
|
|
||||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: actionText
|
|
||||||
|
|
||||||
text: modelData.text || ""
|
|
||||||
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
font.weight: Font.Medium
|
|
||||||
anchors.centerIn: parent
|
|
||||||
elide: Text.ElideRight
|
|
||||||
width: Math.min(contentWidth, parent.width - 8)
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onEntered: {
|
|
||||||
parent.isHovered = true;
|
|
||||||
dismissTimer.stop();
|
|
||||||
}
|
|
||||||
onExited: {
|
|
||||||
parent.isHovered = false;
|
|
||||||
if (modelData.latestNotification.popup && !cardHoverArea.containsMouse)
|
|
||||||
dismissTimer.restart();
|
|
||||||
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
if (modelData && modelData.invoke)
|
|
||||||
modelData.invoke();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dismiss button positioned at bottom-right of notification card
|
|
||||||
Rectangle {
|
|
||||||
id: dismissButton
|
|
||||||
|
|
||||||
property bool isHovered: false
|
|
||||||
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: 16
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.bottomMargin: 8
|
|
||||||
width: dismissText.width + 16
|
|
||||||
height: dismissText.height + 8
|
|
||||||
radius: 6
|
|
||||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
|
||||||
z: 10
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: dismissText
|
|
||||||
|
|
||||||
text: "Dismiss"
|
|
||||||
color: dismissButton.isHovered ? Theme.primary : Theme.surfaceVariantText
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
font.weight: Font.Medium
|
|
||||||
anchors.centerIn: parent
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: popupDismissArea
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
z: 11
|
|
||||||
onEntered: {
|
|
||||||
dismissButton.isHovered = true;
|
|
||||||
dismissTimer.stop();
|
|
||||||
}
|
|
||||||
onExited: {
|
|
||||||
dismissButton.isHovered = false;
|
|
||||||
if (modelData.latestNotification.popup && !cardHoverArea.containsMouse)
|
|
||||||
dismissTimer.restart();
|
|
||||||
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
NotificationService.dismissGroup(modelData.key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: dismissTimer
|
|
||||||
|
|
||||||
running: isPopup
|
|
||||||
interval: 5000 // Fixed 5-second timer for all notifications
|
|
||||||
onTriggered: {
|
|
||||||
// Move to notification center (don't dismiss completely)
|
|
||||||
const groupKey = stableGroupKey || modelData.key;
|
|
||||||
modelData.latestNotification.popup = false;
|
|
||||||
// Clear expansion state when hiding from popup
|
|
||||||
NotificationService.clearGroupExpansionState(groupKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
transform: Translate {
|
|
||||||
x: root.visible ? 0 : 400
|
|
||||||
|
|
||||||
Behavior on x {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: 350
|
|
||||||
easing.type: Easing.OutCubic
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: 300
|
|
||||||
easing.type: Easing.OutCubic
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on height {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Theme.shortDuration
|
|
||||||
easing.type: Theme.standardEasing
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Theme.mediumDuration
|
|
||||||
easing.type: Theme.emphasizedEasing
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
115
Modules/Notifications/NotificationPopupManager.qml
Normal file
115
Modules/Notifications/NotificationPopupManager.qml
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import QtQuick
|
||||||
|
import qs.Common
|
||||||
|
import qs.Services
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property list<var> popupInstances: []
|
||||||
|
property int baseNotificationHeight: 130 // Height of a single notification + margins
|
||||||
|
property bool dismissalInProgress: false
|
||||||
|
property int maxTargetNotifications: 3 // Target number of notifications to maintain
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: dismissalTimer
|
||||||
|
interval: 500 // Half second delay between dismissals
|
||||||
|
onTriggered: dismissNextOldest()
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: dismissalDelayTimer
|
||||||
|
interval: 1 // Start immediately
|
||||||
|
onTriggered: startSequentialDismissal()
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: popupComponent
|
||||||
|
NotificationPopup {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: NotificationService
|
||||||
|
function onNotificationQueueChanged() {
|
||||||
|
syncPopupsWithQueue();
|
||||||
|
repositionAll();
|
||||||
|
}
|
||||||
|
function onVisibleNotificationsChanged() {
|
||||||
|
repositionAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function syncPopupsWithQueue() {
|
||||||
|
const queue = NotificationService.notificationQueue.filter(n => n && n.popup);
|
||||||
|
|
||||||
|
// Clean up destroyed popups first
|
||||||
|
popupInstances = popupInstances.filter(p => p && p.notificationId);
|
||||||
|
|
||||||
|
// DON'T aggressively destroy popups - let them handle their own lifecycle
|
||||||
|
// Only remove popups that are actually destroyed/invalid
|
||||||
|
// The popup will destroy itself when notificationData.popup becomes false
|
||||||
|
|
||||||
|
// Only create NEW notifications, don't touch existing ones AT ALL
|
||||||
|
for (const notif of queue) {
|
||||||
|
const existingPopup = popupInstances.find(p => p.notificationId === notif.notification.id);
|
||||||
|
if (existingPopup) {
|
||||||
|
// CRITICAL: Do absolutely NOTHING to existing popups
|
||||||
|
// Don't change their verticalOffset, don't touch any properties
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate position for NEW notification only - at the bottom of ACTIVE stack
|
||||||
|
const currentActive = popupInstances.filter(p => p && p.notificationData && p.notificationData.popup).length;
|
||||||
|
const popup = popupComponent.createObject(root, {
|
||||||
|
notificationData: notif,
|
||||||
|
notificationId: notif.notification.id,
|
||||||
|
verticalOffset: currentActive * baseNotificationHeight // ✅ bottom of active stack
|
||||||
|
});
|
||||||
|
|
||||||
|
if (popup) {
|
||||||
|
popupInstances.push(popup);
|
||||||
|
|
||||||
|
// Pin it until entrance finishes, then maybe start overflow
|
||||||
|
popup.entered.connect(function() {
|
||||||
|
repositionAll(); // it's now "stable"; allow vertical compaction
|
||||||
|
maybeStartOverflow(); // defer overflow until after slot N is fully occupied
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Overflow dismissal handled in Connections now
|
||||||
|
}
|
||||||
|
|
||||||
|
function repositionAll() {
|
||||||
|
// Only compact stable (non-entering) active popups
|
||||||
|
const stable = popupInstances.filter(p => p && p.notificationData && p.notificationData.popup && !p.entering);
|
||||||
|
for (let i = 0; i < stable.length; ++i)
|
||||||
|
stable[i].verticalOffset = i * baseNotificationHeight;
|
||||||
|
|
||||||
|
// Newcomers keep their creation-time offset (slot N) until `entered()`
|
||||||
|
}
|
||||||
|
|
||||||
|
function maybeStartOverflow() {
|
||||||
|
const active = popupInstances.filter(p => p && p.notificationData && p.notificationData.popup);
|
||||||
|
if (active.length > maxTargetNotifications && !dismissalInProgress)
|
||||||
|
startSequentialDismissal();
|
||||||
|
}
|
||||||
|
|
||||||
|
function startSequentialDismissal() {
|
||||||
|
if (dismissalInProgress) return; // Don't start multiple dismissals
|
||||||
|
|
||||||
|
dismissalInProgress = true;
|
||||||
|
dismissNextOldest();
|
||||||
|
}
|
||||||
|
|
||||||
|
function dismissNextOldest() {
|
||||||
|
const active = popupInstances.filter(p => p && p.notificationData.popup);
|
||||||
|
if (active.length <= maxTargetNotifications) { dismissalInProgress = false; return; }
|
||||||
|
const oldest = active[0];
|
||||||
|
if (oldest) {
|
||||||
|
oldest.notificationData.removedByLimit = true;
|
||||||
|
oldest.notificationData.popup = false; // triggers slide-out in popup
|
||||||
|
dismissalTimer.restart(); // your existing 500ms is fine
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,20 @@ Singleton {
|
|||||||
readonly property list<NotifWrapper> allWrappers: []
|
readonly property list<NotifWrapper> allWrappers: []
|
||||||
readonly property list<NotifWrapper> popups: allWrappers.filter(n => n.popup)
|
readonly property list<NotifWrapper> popups: allWrappers.filter(n => n.popup)
|
||||||
|
|
||||||
|
property list<NotifWrapper> notificationQueue: []
|
||||||
|
property list<NotifWrapper> visibleNotifications: []
|
||||||
|
property int maxVisibleNotifications: 3
|
||||||
|
property bool addGateBusy: false
|
||||||
|
property int enterAnimMs: 400
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: addGate
|
||||||
|
interval: enterAnimMs + 50
|
||||||
|
running: false
|
||||||
|
repeat: false
|
||||||
|
onTriggered: { addGateBusy = false; processQueue(); }
|
||||||
|
}
|
||||||
|
|
||||||
// Android 16-style grouped notifications
|
// Android 16-style grouped notifications
|
||||||
readonly property var groupedNotifications: getGroupedNotifications()
|
readonly property var groupedNotifications: getGroupedNotifications()
|
||||||
readonly property var groupedPopups: getGroupedPopups()
|
readonly property var groupedPopups: getGroupedPopups()
|
||||||
@@ -39,29 +53,22 @@ Singleton {
|
|||||||
inlineReplySupported: true
|
inlineReplySupported: true
|
||||||
|
|
||||||
onNotification: notif => {
|
onNotification: notif => {
|
||||||
console.log("=== RAW NOTIFICATION DATA ===");
|
|
||||||
console.log("appName:", notif.appName);
|
|
||||||
console.log("summary:", notif.summary);
|
|
||||||
console.log("body:", notif.body);
|
|
||||||
console.log("appIcon:", notif.appIcon);
|
|
||||||
console.log("image:", notif.image);
|
|
||||||
console.log("urgency:", notif.urgency);
|
|
||||||
console.log("hasInlineReply:", notif.hasInlineReply);
|
|
||||||
console.log("=============================");
|
|
||||||
|
|
||||||
notif.tracked = true;
|
notif.tracked = true;
|
||||||
|
|
||||||
const wrapper = notifComponent.createObject(root, {
|
const wrapper = notifComponent.createObject(root, {
|
||||||
popup: true, // Always show as popup initially
|
popup: !root.popupsDisabled,
|
||||||
notification: notif
|
notification: notif
|
||||||
});
|
});
|
||||||
|
|
||||||
if (wrapper) {
|
if (wrapper) {
|
||||||
const groupKey = getGroupKey(wrapper);
|
|
||||||
|
|
||||||
root.allWrappers.push(wrapper);
|
root.allWrappers.push(wrapper);
|
||||||
root.notifications.push(wrapper);
|
root.notifications.push(wrapper);
|
||||||
addToPersistentStorage(wrapper);
|
addToPersistentStorage(wrapper);
|
||||||
|
|
||||||
|
if (!root.popupsDisabled) {
|
||||||
|
notificationQueue = [...notificationQueue, wrapper];
|
||||||
|
processQueue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,15 +77,20 @@ Singleton {
|
|||||||
id: wrapper
|
id: wrapper
|
||||||
|
|
||||||
property bool popup: false
|
property bool popup: false
|
||||||
|
property bool removedByLimit: false
|
||||||
|
|
||||||
Component.onCompleted: {
|
onPopupChanged: {
|
||||||
popup = !root.popupsDisabled;
|
if (!popup) {
|
||||||
|
removeFromVisibleNotifications(wrapper);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't override popup in onCompleted - it's set correctly during creation
|
||||||
|
|
||||||
readonly property Timer timer: Timer {
|
readonly property Timer timer: Timer {
|
||||||
interval: 5000
|
interval: 5000
|
||||||
repeat: false
|
repeat: false
|
||||||
running: wrapper.popup
|
running: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
wrapper.popup = false;
|
wrapper.popup = false;
|
||||||
}
|
}
|
||||||
@@ -185,12 +197,38 @@ Singleton {
|
|||||||
function disablePopups(disable) {
|
function disablePopups(disable) {
|
||||||
popupsDisabled = disable;
|
popupsDisabled = disable;
|
||||||
if (disable) {
|
if (disable) {
|
||||||
|
notificationQueue = [];
|
||||||
|
visibleNotifications = [];
|
||||||
for (const notif of root.allWrappers) {
|
for (const notif of root.allWrappers) {
|
||||||
notif.popup = false;
|
notif.popup = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processQueue() {
|
||||||
|
if (addGateBusy) return;
|
||||||
|
if (popupsDisabled) return;
|
||||||
|
if (notificationQueue.length === 0) return;
|
||||||
|
|
||||||
|
const [next, ...rest] = notificationQueue;
|
||||||
|
notificationQueue = rest;
|
||||||
|
|
||||||
|
visibleNotifications = [...visibleNotifications, next];
|
||||||
|
next.popup = true;
|
||||||
|
|
||||||
|
addGateBusy = true;
|
||||||
|
addGate.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeFromVisibleNotifications(wrapper) {
|
||||||
|
const i = visibleNotifications.findIndex(n => n === wrapper);
|
||||||
|
if (i !== -1) {
|
||||||
|
const v = [...visibleNotifications]; v.splice(i, 1);
|
||||||
|
visibleNotifications = v;
|
||||||
|
processQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Android 16-style notification grouping functions
|
// Android 16-style notification grouping functions
|
||||||
function getGroupKey(wrapper) {
|
function getGroupKey(wrapper) {
|
||||||
@@ -264,11 +302,6 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Object.values(groups).sort((a, b) => {
|
return Object.values(groups).sort((a, b) => {
|
||||||
const aUrgency = a.latestNotification.urgency || 0;
|
|
||||||
const bUrgency = b.latestNotification.urgency || 0;
|
|
||||||
if (aUrgency !== bUrgency) {
|
|
||||||
return bUrgency - aUrgency;
|
|
||||||
}
|
|
||||||
return b.latestNotification.time.getTime() - a.latestNotification.time.getTime();
|
return b.latestNotification.time.getTime() - a.latestNotification.time.getTime();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user