Notification: add app icon support

This commit is contained in:
Ly-sec 2025-09-04 13:38:39 +02:00
parent 291cd5130d
commit 4229721774
2 changed files with 85 additions and 48 deletions

View file

@ -93,10 +93,10 @@ Variants {
model: notificationModel model: notificationModel
delegate: Rectangle { delegate: Rectangle {
width: 360 * scaling width: 360 * scaling
height: Math.max(80 * scaling, contentColumn.implicitHeight + (Style.marginM * 2 * scaling)) height: Math.max(80 * scaling, contentRow.implicitHeight + (Style.marginL * 2 * scaling))
clip: true clip: true
radius: Style.radiusM * scaling radius: Style.radiusL * scaling
border.color: Color.mPrimary border.color: Color.applyOpacity(Color.mOutline, "33")
border.width: Math.max(1, Style.borderS * scaling) border.width: Math.max(1, Style.borderS * scaling)
color: Color.mSurface color: Color.mSurface
@ -156,16 +156,24 @@ Variants {
} }
} }
Column { RowLayout {
id: contentColumn id: contentRow
anchors.fill: parent anchors.fill: parent
anchors.margins: Style.marginM * scaling anchors.margins: Style.marginL * scaling
spacing: Style.marginL * scaling
// Right: header on top, then avatar + texts
ColumnLayout {
id: textColumn
spacing: Style.marginS * scaling spacing: Style.marginS * scaling
Layout.fillWidth: true
RowLayout { RowLayout {
spacing: Style.marginS * scaling spacing: Style.marginS * scaling
id: appHeaderRow
NText { NText {
text: (model.appName || model.desktopEntry) || "Unknown App" text: `${(model.appName || model.desktopEntry)
|| "Unknown App"} · ${NotificationService.formatTimestamp(model.timestamp)}`
color: Color.mSecondary color: Color.mSecondary
font.pointSize: Style.fontSizeXS * scaling font.pointSize: Style.fontSizeXS * scaling
} }
@ -179,33 +187,58 @@ Variants {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
} }
NText {
text: NotificationService.formatTimestamp(model.timestamp)
color: Color.mOnSurface
font.pointSize: Style.fontSizeXS * scaling
} }
RowLayout {
id: bodyRow
spacing: Style.marginM * scaling
NImageCircled {
id: appAvatar
Layout.preferredWidth: 40 * scaling
Layout.preferredHeight: 40 * scaling
Layout.alignment: Qt.AlignTop
// Start avatar aligned with body (below the summary)
anchors.topMargin: textContent.childrenRect.y
imagePath: Icons.iconFromName(model.appIcon, "application-x-executable")
fallbackIcon: "apps"
borderColor: Color.transparent
borderWidth: 0
visible: imagePath && imagePath !== ""
} }
Column {
id: textContent
spacing: Style.marginS * scaling
Layout.fillWidth: true
// Ensure a concrete width so text wraps
width: (textColumn.width - (appAvatar.visible ? (appAvatar.width + Style.marginM * scaling) : 0))
NText { NText {
text: model.summary || "No summary" text: model.summary || "No summary"
font.pointSize: Style.fontSizeL * scaling font.pointSize: Style.fontSizeL * scaling
font.weight: Style.fontWeightBold font.weight: Style.fontWeightMedium
color: Color.mOnSurface color: Color.mOnSurface
wrapMode: Text.Wrap wrapMode: Text.WrapAtWordBoundaryOrAnywhere
width: 300 * scaling Layout.fillWidth: true
width: parent.width
maximumLineCount: 3 maximumLineCount: 3
elide: Text.ElideRight elide: Text.ElideRight
} }
NText { NText {
text: model.body || "" text: model.body || ""
font.pointSize: Style.fontSizeXS * scaling font.pointSize: Style.fontSizeM * scaling
color: Color.mOnSurface color: Color.mOnSurface
wrapMode: Text.Wrap wrapMode: Text.WrapAtWordBoundaryOrAnywhere
width: 300 * scaling Layout.fillWidth: true
width: parent.width
maximumLineCount: 5 maximumLineCount: 5
elide: Text.ElideRight elide: Text.ElideRight
} }
}
}
}
// Actions removed // Actions removed
} }
@ -213,7 +246,9 @@ Variants {
NIconButton { NIconButton {
icon: "close" icon: "close"
tooltipText: "Close" tooltipText: "Close"
sizeRatio: 0.8 // Compact target (~24dp) and glyph (~16dp)
sizeRatio: 0.75
fontPointSize: 16
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
anchors.margins: Style.marginS * scaling anchors.margins: Style.marginS * scaling

View file

@ -116,6 +116,8 @@ Singleton {
"summary": notification.summary, "summary": notification.summary,
"body": notification.body, "body": notification.body,
"appName": notification.appName, "appName": notification.appName,
"image": notification.image,
"appIcon": notification.appIcon,
"urgency": notification.urgency, "urgency": notification.urgency,
"timestamp": new Date() "timestamp": new Date()
}) })