1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-08 14:35:39 -05:00

Level up notifications

This commit is contained in:
purian23
2025-07-23 00:04:16 -04:00
parent e94d2af9ae
commit 5b40396a8a
4 changed files with 1060 additions and 3266 deletions

View File

@@ -299,26 +299,19 @@ PanelWindow {
delegate: Rectangle { delegate: Rectangle {
required property var modelData required property var modelData
readonly property bool expanded: NotificationService.expandedGroups[modelData.key] || false readonly property bool expanded: NotificationService.expandedGroups[modelData.key] || false
readonly property string groupKey: modelData.key
width: ListView.view.width width: ListView.view.width
height: { height: {
if (expanded) { if (expanded && modelData.count >= 1) {
// Calculate expanded height: header (48) + spacing (16) + individual notifications const baseHeight = (116 * modelData.count) + (12 * (modelData.count - 1));
let headerHeight = 48 + Theme.spacingM; // Add extra bottom margin for expanded groups
let notificationHeight = modelData.notifications.length * (60 + Theme.spacingS); // Each notification ~60px + spacing const bottomMargin = modelData.count === 1 ? 50 : (modelData.count < 3 ? 40 : 20);
let totalExpandedHeight = headerHeight + notificationHeight + Theme.spacingL * 2; return baseHeight + bottomMargin;
return Math.max(totalExpandedHeight, 200); // Minimum expanded height
} else {
// Collapsed height: icon + content + quick reply (if any)
let collapsedHeight = 72 + Theme.spacingS * 2;
// Header height + spacing
if (modelData.latestNotification.notification.hasInlineReply)
collapsedHeight += 36 + Theme.spacingS;
return collapsedHeight + Theme.spacingL * 2;
} }
return 116;
} }
radius: Theme.cornerRadiusLarge radius: 12
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: 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.width: modelData.latestNotification.urgency === 2 ? 2 : 1 border.width: modelData.latestNotification.urgency === 2 ? 2 : 1
@@ -336,356 +329,248 @@ PanelWindow {
visible: modelData.latestNotification.urgency === 2 visible: modelData.latestNotification.urgency === 2
} }
// Collapsed view - shows app header and latest notification // Collapsed view - show latest notification using popup style
Column { Item {
id: collapsedContent id: collapsedContent
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: 14 // Reduced from Theme.spacingL (16px) by 10% anchors.topMargin: 12
anchors.bottomMargin: 14 // Reduced from Theme.spacingL (16px) by 10% anchors.leftMargin: 16
anchors.leftMargin: Theme.spacingL anchors.rightMargin: 16
anchors.rightMargin: Theme.spacingL height: 92
spacing: Theme.spacingS
visible: !expanded visible: !expanded
// App header with group info Rectangle {
Item { id: iconContainer
width: parent.width
height: 72
// App icon with proper fallback handling readonly property bool hasNotificationImage: modelData.latestNotification.image && modelData.latestNotification.image !== ""
Item { readonly property bool appIconIsImage: modelData.latestNotification.appIcon && (modelData.latestNotification.appIcon.startsWith("file://") || modelData.latestNotification.appIcon.startsWith("http://") || modelData.latestNotification.appIcon.startsWith("https://"))
id: iconContainer
width: 48 width: 55
height: 48 height: 55
anchors.left: parent.left radius: 27.5
anchors.verticalCenter: parent.verticalCenter color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1)
border.color: "transparent"
border.width: 0
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
Rectangle { IconImage {
width: 48 anchors.fill: parent
height: 48 anchors.margins: 2
radius: 24 source: {
color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) // Priority 1: Use notification image if available
border.color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3) if (parent.hasNotificationImage)
border.width: 1 return modelData.latestNotification.cleanImage;
clip: true
readonly property bool hasNotificationImage: modelData.latestNotification.image && modelData.latestNotification.image !== "" // Priority 2: Use appIcon - handle URLs directly, use iconPath for icon names
if (modelData.latestNotification.appIcon) {
const appIcon = modelData.latestNotification.appIcon;
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://"))
return appIcon;
IconImage { return Quickshell.iconPath(appIcon, "");
anchors.fill: parent
anchors.margins: 2
source: {
// Priority 1: Use notification image if available
if (parent.hasNotificationImage) {
return modelData.latestNotification.cleanImage;
}
// Priority 2: Use appIcon - handle URLs directly, use iconPath for icon names
if (modelData.latestNotification.appIcon) {
const appIcon = modelData.latestNotification.appIcon;
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://")) {
return appIcon;
}
return Quickshell.iconPath(appIcon, "");
}
return "";
}
visible: status === Image.Ready
} }
return "";
Text {
anchors.centerIn: parent
visible: !parent.hasNotificationImage && (!modelData.latestNotification.appIcon || modelData.latestNotification.appIcon === "")
text: {
const appName = modelData.appName || "?";
return appName.charAt(0).toUpperCase();
}
font.pixelSize: 20
font.weight: Font.Bold
color: Theme.primaryText
}
} }
visible: status === Image.Ready
// Count badge for multiple notifications
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
}
}
} }
// Content area with proper spacing Text {
Column { anchors.centerIn: parent
anchors.left: iconContainer.right visible: !parent.hasNotificationImage && (!modelData.latestNotification.appIcon || modelData.latestNotification.appIcon === "")
anchors.leftMargin: Theme.spacingM text: {
anchors.right: controlsContainer.left const appName = modelData.appName || "?";
anchors.rightMargin: 8 // Reduced to align text with close button return appName.charAt(0).toUpperCase();
}
font.pixelSize: 20
font.weight: Font.Bold
color: Theme.primaryText
}
Rectangle {
width: 18
height: 18
radius: 9
color: Theme.primary
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Theme.spacingS
spacing: 6 // Reduced from Theme.spacingS (8px) by 2px
// App name and timestamp
Text {
width: parent.width
text: {
if (modelData.latestNotification.timeStr.length > 0)
return modelData.appName + " • " + modelData.latestNotification.timeStr;
else
return modelData.appName;
}
color: Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
elide: Text.ElideRight
maximumLineCount: 1
}
// Latest notification title (emphasized)
Text {
text: modelData.latestNotification.summary
color: Theme.surfaceText
font.pixelSize: Theme.fontSizeMedium + 1
font.weight: Font.Medium
width: parent.width
elide: Text.ElideRight
maximumLineCount: 1
visible: text.length > 0
}
// Latest notification body
Text {
text: modelData.latestNotification.body
color: Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
width: parent.width
elide: Text.ElideRight
maximumLineCount: modelData.count > 1 ? 1 : 2
wrapMode: Text.WordWrap
visible: text.length > 0
}
}
// Controls aligned with app name and timestamp row
Item {
id: controlsContainer
width: 72
height: 32
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.topMargin: -2
anchors.topMargin: 8 anchors.rightMargin: -2
visible: modelData.count > 1
Rectangle {
width: 32
height: 32
radius: 16
anchors.left: parent.left
color: expandArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
visible: modelData.count > 1
DankIcon {
anchors.centerIn: parent
name: "expand_more"
size: 18
color: Theme.surfaceText
rotation: expanded ? 180 : 0
Behavior on rotation {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
MouseArea {
id: expandArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.toggleGroupExpansion(modelData.key)
}
Text {
anchors.centerIn: parent
text: modelData.count > 99 ? "99+" : modelData.count.toString()
color: Theme.primaryText
font.pixelSize: 9
font.weight: Font.Bold
} }
Rectangle {
width: 32
height: 32
radius: 16
anchors.right: parent.right
color: dismissArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankIcon {
anchors.centerIn: parent
name: "close"
size: 16
color: Theme.surfaceText
}
MouseArea {
id: dismissArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.dismissGroup(modelData.key)
}
}
} }
} }
// Action buttons for collapsed view Rectangle {
Row { id: textContainer
width: parent.width
spacing: Theme.spacingS
visible: modelData.latestNotification.actions && modelData.latestNotification.actions.length > 0 && !modelData.latestNotification.notification.hasInlineReply && !expanded
Repeater { anchors.left: iconContainer.right
model: modelData.latestNotification.actions ? modelData.latestNotification.actions.slice(0, 2) : [] anchors.leftMargin: 12
delegate: Rectangle { anchors.right: controlsContainer.left
width: Math.min((parent.width - (parent.spacing * (parent.children.length - 1))) / parent.children.length, 120) anchors.rightMargin: 0
height: 32 anchors.top: parent.top
radius: 16 anchors.bottom: parent.bottom
color: collapsedActionArea.containsMouse ? Theme.primary : Theme.surfaceContainer anchors.bottomMargin: 8
border.color: collapsedActionArea.containsMouse ? "transparent" : Theme.outline color: "transparent"
border.width: 1 opacity: 1
border.color: "transparent"
border.width: 0
Item {
width: parent.width
height: parent.height
anchors.top: parent.top
anchors.topMargin: 2
Column {
id: textContent
width: parent.width
spacing: 2
Text { Text {
anchors.centerIn: parent width: parent.width
text: modelData.text || "" text: {
color: collapsedActionArea.containsMouse ? Theme.primaryText : Theme.surfaceText if (modelData.latestNotification.timeStr.length > 0)
return modelData.appName + " • " + modelData.latestNotification.timeStr;
else
return modelData.appName;
}
color: Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium font.weight: Font.Medium
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1 maximumLineCount: 1
width: parent.width - 16
horizontalAlignment: Text.AlignHCenter
} }
MouseArea { Text {
id: collapsedActionArea text: modelData.latestNotification.summary
anchors.fill: parent color: Theme.surfaceText
hoverEnabled: true font.pixelSize: Theme.fontSizeMedium
cursorShape: Qt.PointingHandCursor font.weight: Font.Medium
onClicked: { width: parent.width
if (modelData.invoke) { elide: Text.ElideRight
modelData.invoke(); maximumLineCount: 1
} visible: text.length > 0
}
Text {
property bool hasUrls: {
const urlRegex = /(https?:\/\/[^\s]+)/g;
return urlRegex.test(modelData.latestNotification.body);
} }
}
Behavior on color { text: {
ColorAnimation { // Auto-detect and make URLs clickable, with truncation for center notifications
duration: Theme.shortDuration let bodyText = modelData.latestNotification.body;
easing.type: Theme.standardEasing // No truncation for notification center - show full text
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
width: parent.width
elide: Text.ElideRight
maximumLineCount: modelData.count > 1 ? 2 : 3
wrapMode: Text.WordWrap
visible: text.length > 0
textFormat: Text.RichText
onLinkActivated: function(link) {
Qt.openUrlExternally(link);
} }
} }
} }
} }
} }
// Enhanced quick reply for conversations Item {
Row { id: controlsContainer
width: parent.width
spacing: Theme.spacingS
visible: modelData.latestNotification.notification.hasInlineReply && !expanded
anchors.right: parent.right
anchors.rightMargin: 0
anchors.top: parent.top
anchors.topMargin: 0
width: modelData.count > 1 ? 40 : 20 // Dynamic width: 40px for expand+close, 20px for close only
height: 24
// Expand button - always takes up space but only visible when needed
Rectangle { Rectangle {
width: parent.width - 60 id: collapsedExpandButton
height: 36 anchors.left: parent.left
radius: 18 anchors.top: parent.top
color: Theme.surfaceContainer width: 20
border.color: quickReplyField.activeFocus ? Theme.primary : Theme.outline height: 20
border.width: 1 radius: 10
color: expandArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
TextField { visible: modelData.count > 1
id: quickReplyField
anchors.fill: parent
anchors.margins: Theme.spacingS
placeholderText: modelData.latestNotification.notification.inlineReplyPlaceholder || "Quick reply..."
color: Theme.surfaceText
font.pixelSize: Theme.fontSizeSmall
onAccepted: {
if (text.length > 0) {
modelData.latestNotification.notification.sendInlineReply(text);
text = "";
}
}
background: Item {
}
}
}
Rectangle {
width: 52
height: 36
radius: 18
color: quickReplyField.text.length > 0 ? Theme.primary : Theme.surfaceContainer
border.color: quickReplyField.text.length > 0 ? "transparent" : Theme.outline
border.width: quickReplyField.text.length > 0 ? 0 : 1
DankIcon { DankIcon {
anchors.centerIn: parent anchors.centerIn: parent
name: "send" name: expanded ? "expand_less" : "expand_more"
size: 16 size: 14
color: quickReplyField.text.length > 0 ? Theme.primaryText : Theme.surfaceVariantText color: Theme.surfaceText
} }
MouseArea { MouseArea {
id: expandArea
anchors.fill: parent anchors.fill: parent
enabled: quickReplyField.text.length > 0 hoverEnabled: true
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: NotificationService.toggleGroupExpansion(modelData.key)
modelData.latestNotification.notification.sendInlineReply(quickReplyField.text);
quickReplyField.text = "";
}
} }
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
} }
} // Close button - always positioned at the right edge
Rectangle {
id: closeButton
property bool isHovered: false
anchors.right: parent.right
anchors.top: parent.top
width: 20
height: 20
radius: 10
color: isHovered ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
z: 10
DankIcon {
id: closeIcon
name: "close"
size: 14
color: closeButton.isHovered ? Theme.primary : Theme.surfaceText
anchors.centerIn: parent
}
MouseArea {
id: dismissArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
z: 11
onEntered: {
closeButton.isHovered = true;
}
onExited: {
closeButton.isHovered = false;
}
onClicked: NotificationService.dismissGroup(modelData.key)
}
}
}
} }
// Expanded view - shows all notifications stacked // Expanded view - shows all notifications stacked
@@ -702,7 +587,7 @@ PanelWindow {
spacing: 9 // Reduced from Theme.spacingM (12px) by 1/4 spacing: 9 // Reduced from Theme.spacingM (12px) by 1/4
visible: expanded visible: expanded
// 1st tier controls with app name - optimized spacing // 1st tier controls with app name - optimized spacing
Item { Item {
width: parent.width width: parent.width
height: 40 height: 40
@@ -737,27 +622,29 @@ PanelWindow {
font.pixelSize: 10 font.pixelSize: 10
font.weight: Font.Bold font.weight: Font.Bold
} }
} }
} }
// Controls container - fixed position on right // Controls container - fixed position on right
Item { Item {
width: 72 width: 48
height: 32 height: 24
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Rectangle { Rectangle {
width: 32 width: 20
height: 32 height: 20
radius: 16 radius: 10
anchors.left: parent.left anchors.left: parent.left
color: collapseAreaTop.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent" color: collapseAreaTop.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankIcon { DankIcon {
anchors.centerIn: parent anchors.centerIn: parent
name: "expand_less" name: "expand_less"
size: 18 size: 14
color: Theme.surfaceText color: Theme.surfaceText
} }
@@ -773,16 +660,16 @@ PanelWindow {
} }
Rectangle { Rectangle {
width: 32 width: 20
height: 32 height: 20
radius: 16 radius: 10
anchors.right: parent.right anchors.right: parent.right
color: dismissAllAreaTop.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent" color: dismissAllAreaTop.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankIcon { DankIcon {
anchors.centerIn: parent anchors.centerIn: parent
name: "close" name: "close"
size: 16 size: 14
color: Theme.surfaceText color: Theme.surfaceText
} }
@@ -798,8 +685,8 @@ PanelWindow {
} }
} }
}
}
// Individual notifications // Individual notifications
Column { Column {
@@ -830,6 +717,8 @@ PanelWindow {
height: Math.max(32, contentColumn.height) height: Math.max(32, contentColumn.height)
Rectangle { Rectangle {
readonly property bool hasNotificationImage: modelData.image && modelData.image !== ""
width: 32 width: 32
height: 32 height: 32
radius: 16 radius: 16
@@ -839,26 +728,22 @@ PanelWindow {
border.color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2) border.color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
border.width: 1 border.width: 1
readonly property bool hasNotificationImage: modelData.image && modelData.image !== ""
IconImage { IconImage {
anchors.fill: parent anchors.fill: parent
anchors.margins: 1 anchors.margins: 1
source: { source: {
// Priority 1: Use notification image if available // Priority 1: Use notification image if available
if (parent.hasNotificationImage) { if (parent.hasNotificationImage)
return modelData.cleanImage; return modelData.cleanImage;
}
// Priority 2: Use appIcon - handle URLs directly, use iconPath for icon names // Priority 2: Use appIcon - handle URLs directly, use iconPath for icon names
if (modelData.appIcon) { if (modelData.appIcon) {
const appIcon = modelData.appIcon; const appIcon = modelData.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 "";
} }
visible: status === Image.Ready visible: status === Image.Ready
@@ -889,19 +774,19 @@ PanelWindow {
// Expand/collapse button for 2nd tier // Expand/collapse button for 2nd tier
Rectangle { Rectangle {
width: 24
height: 24
radius: 12
color: individualExpandArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
visible: modelData.body && modelData.body.length > 50 // Only show if body text is long enough
property bool isExpanded: NotificationService.expandedMessages[modelData.notification.id] || false property bool isExpanded: NotificationService.expandedMessages[modelData.notification.id] || false
width: 20
height: 20
radius: 10
color: individualExpandArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
visible: (modelData.body || "").length > 80 // Only show if body text is long enough
DankIcon { DankIcon {
anchors.centerIn: parent anchors.centerIn: parent
name: parent.isExpanded ? "expand_less" : "expand_more" name: parent.isExpanded ? "expand_less" : "expand_more"
size: 12 size: 12
color: Theme.surfaceVariantText color: Theme.surfaceText
} }
MouseArea { MouseArea {
@@ -912,20 +797,21 @@ PanelWindow {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.toggleMessageExpansion(modelData.notification.id) onClicked: NotificationService.toggleMessageExpansion(modelData.notification.id)
} }
} }
// Individual dismiss button // Individual dismiss button
Rectangle { Rectangle {
width: 24 width: 20
height: 24 height: 20
radius: 12 radius: 10
color: individualDismissArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent" color: individualDismissArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankIcon { DankIcon {
anchors.centerIn: parent anchors.centerIn: parent
name: "close" name: "close"
size: 12 size: 12
color: Theme.surfaceVariantText color: individualDismissArea.containsMouse ? Theme.primary : Theme.surfaceText
} }
MouseArea { MouseArea {
@@ -936,33 +822,38 @@ PanelWindow {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.dismissNotification(modelData) onClicked: NotificationService.dismissNotification(modelData)
} }
} }
} }
Column { Item {
id: contentColumn
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 44 anchors.leftMargin: 44
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 24 // Align text with close button anchors.rightMargin: 24 // Align text with close button
anchors.top: parent.top anchors.top: parent.top
spacing: 2 // Reduced from Theme.spacingXS (4px) by 2px height: contentColumn.height
property bool isMessageExpanded: NotificationService.expandedMessages[modelData.notification.id] || false Column {
id: contentColumn
property bool isMessageExpanded: NotificationService.expandedMessages[modelData.notification.id] || false
width: parent.width
spacing: 2 // Reduced from Theme.spacingXS (4px) by 2px
// Title • timestamp format // Title • timestamp format
Text { Text {
text: { text: {
const summary = modelData.summary || ""; const summary = modelData.summary || "";
const timeStr = modelData.timeStr || ""; const timeStr = modelData.timeStr || "";
if (summary && timeStr) { if (summary && timeStr)
return summary + " • " + timeStr; return summary + " • " + timeStr;
} else if (summary) { else if (summary)
return summary; return summary;
} else { else
return "Message • " + timeStr; return "Message • " + timeStr;
}
} }
color: Theme.surfaceText color: Theme.surfaceText
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
@@ -984,57 +875,28 @@ PanelWindow {
visible: text.length > 0 visible: text.length > 0
} }
// Individual action buttons // Clickable area for View action on individual message
Row { MouseArea {
width: parent.width anchors.fill: parent
spacing: Theme.spacingXS hoverEnabled: true
visible: modelData.actions && modelData.actions.length > 0 && !modelData.notification.hasInlineReply cursorShape: Qt.PointingHandCursor
onClicked: {
// Find and invoke the View action
if (modelData.actions) {
for (const action of modelData.actions) {
if (action.text && action.text.toLowerCase() === "view") {
if (action.invoke)
action.invoke();
Repeater { break;
model: modelData.actions ? modelData.actions.slice(0, 2) : []
delegate: Rectangle {
width: Math.min((parent.width - (parent.spacing * (parent.children.length - 1))) / parent.children.length, 80)
height: 24
radius: 12
color: expandedActionArea.containsMouse ? Theme.primary : Theme.surfaceContainer
border.color: expandedActionArea.containsMouse ? "transparent" : Theme.outline
border.width: 1
Text {
anchors.centerIn: parent
text: modelData.text || ""
color: expandedActionArea.containsMouse ? Theme.primaryText : Theme.surfaceText
font.pixelSize: 10
font.weight: Font.Medium
elide: Text.ElideRight
maximumLineCount: 1
width: parent.width - 8
horizontalAlignment: Text.AlignHCenter
}
MouseArea {
id: expandedActionArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
if (modelData.invoke) {
modelData.invoke();
}
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
} }
} }
} }
} }
} }
// Individual inline reply // COMMENTED OUT: Individual inline reply
/*
Row { Row {
width: parent.width width: parent.width
spacing: Theme.spacingS spacing: Theme.spacingS
@@ -1096,7 +958,9 @@ PanelWindow {
} }
} }
*/
}
} }
} }
@@ -1140,7 +1004,6 @@ PanelWindow {
Item { Item {
width: parent.width width: parent.width
height: 200 height: 200
anchors.centerIn: parent
visible: NotificationService.notifications.length === 0 visible: NotificationService.notifications.length === 0
Column { Column {

File diff suppressed because it is too large Load Diff

View File

@@ -60,6 +60,8 @@ Singleton {
}); });
if (wrapper) { if (wrapper) {
const groupKey = getGroupKey(wrapper);
console.log("New notification added to group:", groupKey, "Expansion state:", expandedGroups[groupKey] || false);
// Handle media notification replacement // Handle media notification replacement
if (wrapper.isMedia) { if (wrapper.isMedia) {
handleMediaNotification(wrapper); handleMediaNotification(wrapper);
@@ -67,19 +69,7 @@ Singleton {
root.notifications.push(wrapper); root.notifications.push(wrapper);
} }
// Auto-expand conversation groups with new messages // Don't auto-expand groups - let user control expansion state
if (wrapper.isConversation && notifications.length > 1) {
const groupKey = getGroupKey(wrapper);
const existingGroup = groupedNotifications.find(group => group.key === groupKey);
if (existingGroup && existingGroup.count > 1) {
let newExpandedGroups = {};
for (const key in expandedGroups) {
newExpandedGroups[key] = expandedGroups[key];
}
newExpandedGroups[groupKey] = true;
expandedGroups = newExpandedGroups;
}
}
// Add to persistent storage (only for non-transient notifications) // Add to persistent storage (only for non-transient notifications)
if (!notif.transient) { if (!notif.transient) {
@@ -216,18 +206,7 @@ Singleton {
readonly property Timer timer: Timer {
running: wrapper.popup
interval: {
if (wrapper.notification.expireTimeout > 0) {
return wrapper.notification.expireTimeout * 1000;
}
return NotificationSettings.getAppTimeout(wrapper.appName);
}
onTriggered: {
wrapper.popup = false;
}
}
readonly property Connections conn: Connections { readonly property Connections conn: Connections {
target: wrapper.notification.Retainable target: wrapper.notification.Retainable
@@ -235,7 +214,19 @@ Singleton {
function onDropped(): void { function onDropped(): void {
const index = root.notifications.indexOf(wrapper); const index = root.notifications.indexOf(wrapper);
if (index !== -1) { if (index !== -1) {
// Get the group key before removing the notification
const groupKey = getGroupKey(wrapper);
root.notifications.splice(index, 1); root.notifications.splice(index, 1);
// Check if this group now has no notifications left
const remainingInGroup = root.notifications.filter(n => getGroupKey(n) === groupKey);
if (remainingInGroup.length === 0) {
// Immediately clear expansion state for empty group
clearGroupExpansionState(groupKey);
}
// Clean up all expansion states
cleanupExpansionStates();
} }
} }
@@ -257,6 +248,7 @@ Singleton {
for (const notif of notificationsCopy) { for (const notif of notificationsCopy) {
notif.notification.dismiss(); notif.notification.dismiss();
} }
// Note: Expansion states will be cleaned up by onDropped as notifications are removed
} }
function dismissNotification(wrapper) { function dismissNotification(wrapper) {
@@ -411,13 +403,57 @@ Singleton {
} }
function dismissGroup(groupKey) { function dismissGroup(groupKey) {
// Use array iteration to avoid spread operator issues console.log("Completely dismissing group:", groupKey);
for (let i = notifications.length - 1; i >= 0; i--) { const group = groupedNotifications.find(g => g.key === groupKey);
const notif = notifications[i]; if (group) {
if (getGroupKey(notif) === groupKey) { for (const notif of group.notifications) {
notif.notification.dismiss(); notif.notification.dismiss();
} }
} }
// Note: Expansion state will be cleaned up by onDropped when notifications are removed
}
function clearGroupExpansionState(groupKey) {
// Immediately remove expansion state for a specific group
let newExpandedGroups = {};
for (const key in expandedGroups) {
if (key !== groupKey && expandedGroups[key]) {
newExpandedGroups[key] = true;
}
}
expandedGroups = newExpandedGroups;
console.log("Cleared expansion state for group:", groupKey);
}
function cleanupExpansionStates() {
// Get all current group keys and message IDs
const currentGroupKeys = new Set(groupedNotifications.map(g => g.key));
const currentMessageIds = new Set();
for (const group of groupedNotifications) {
for (const notif of group.notifications) {
currentMessageIds.add(notif.notification.id);
}
}
// Clean up expanded groups that no longer exist
let newExpandedGroups = {};
for (const key in expandedGroups) {
if (currentGroupKeys.has(key) && expandedGroups[key]) {
newExpandedGroups[key] = true;
}
}
expandedGroups = newExpandedGroups;
// Clean up expanded messages that no longer exist
let newExpandedMessages = {};
for (const messageId in expandedMessages) {
if (currentMessageIds.has(messageId) && expandedMessages[messageId]) {
newExpandedMessages[messageId] = true;
}
}
expandedMessages = newExpandedMessages;
} }
function toggleMessageExpansion(messageId) { function toggleMessageExpansion(messageId) {

File diff suppressed because it is too large Load Diff