Fix NotificationHistory

This commit is contained in:
Ly-sec 2025-08-15 23:41:10 +02:00
parent 7e7b7b0192
commit b371cb92c1

View file

@ -63,18 +63,19 @@ NLoader {
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
Rectangle { Rectangle {
id: notificationRect id: notificationRect
color: Colors.mSurfaceVariant color: Colors.mSurfaceVariant
radius: Style.radiusMedium * scaling radius: Style.radiusMedium * scaling
border.color: Colors.mOutlineVariant border.color: Colors.mOutlineVariant
border.width: Math.max(1, Style.borderMedium * scaling) border.width: Math.max(1, Style.borderMedium * scaling)
width: 400 * scaling width: 400 * scaling
height: 500 * scaling height: 500 * scaling
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: Style.marginTiny * scaling anchors.topMargin: Style.marginTiny * scaling
anchors.rightMargin: Style.marginTiny * scaling anchors.rightMargin: Style.marginTiny * scaling
clip: true
// Animation properties // Animation properties
property real scaleValue: 0.8 property real scaleValue: 0.8
@ -152,7 +153,7 @@ NLoader {
Layout.fillHeight: true Layout.fillHeight: true
model: NotificationService.historyModel model: NotificationService.historyModel
spacing: Style.marginMedium * scaling spacing: Style.marginMedium * scaling
clip: false clip: true
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
delegate: Rectangle { delegate: Rectangle {
@ -181,7 +182,7 @@ NLoader {
font.weight: Font.Medium font.weight: Font.Medium
color: notificationMouseArea.containsMouse ? Colors.mSurface : Colors.mOnSurface color: notificationMouseArea.containsMouse ? Colors.mSurface : Colors.mOnSurface
wrapMode: Text.Wrap wrapMode: Text.Wrap
width: parent.width - 30 width: parent.width - 60
maximumLineCount: 2 maximumLineCount: 2
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -191,7 +192,7 @@ NLoader {
font.pointSize: Style.fontSizeSmall * scaling font.pointSize: Style.fontSizeSmall * scaling
color: notificationMouseArea.containsMouse ? Colors.mSurface : Colors.mOnSurface color: notificationMouseArea.containsMouse ? Colors.mSurface : Colors.mOnSurface
wrapMode: Text.Wrap wrapMode: Text.Wrap
width: parent.width - 30 width: parent.width - 60
maximumLineCount: 3 maximumLineCount: 3
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -202,17 +203,27 @@ NLoader {
color: notificationMouseArea.containsMouse ? Colors.mSurface : Colors.mOnSurface color: notificationMouseArea.containsMouse ? Colors.mSurface : Colors.mOnSurface
} }
} }
// Trash icon button
NIconButton {
icon: "delete"
sizeMultiplier: 0.7
tooltipText: "Delete notification"
color: notificationMouseArea.containsMouse ? Colors.mSurface : Colors.mOnSurfaceVariant
onClicked: {
console.log("[NotificationHistory] Removing notification:", summary)
NotificationService.historyModel.remove(index)
NotificationService.saveHistory()
}
}
} }
MouseArea { MouseArea {
id: notificationMouseArea id: notificationMouseArea
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: 50 * scaling
hoverEnabled: true hoverEnabled: true
onClicked: { // Remove the onClicked handler since we now have a dedicated delete button
console.log("[NotificationHistory] Removing notification:", summary)
NotificationService.historyModel.remove(index)
NotificationService.saveHistory()
}
} }
} }