1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 21:45:38 -05:00

notifications: improve notification center

This commit is contained in:
bbedward
2025-07-25 16:52:58 -04:00
parent 98ddc2805b
commit e14afcefd4
11 changed files with 619 additions and 1203 deletions

View File

@@ -11,48 +11,62 @@ Rectangle {
property var notificationGroup
property bool expanded: NotificationService.expandedGroups[notificationGroup?.key] || false
property bool descriptionExpanded: false
width: parent.width
height: {
if (expanded && notificationGroup && notificationGroup.count >= 1) {
const baseHeight = (116 * notificationGroup.count) + (12 * (notificationGroup.count - 1));
const bottomMargin = notificationGroup.count === 1 ? 65 : (notificationGroup.count <= 3 ? 30 : -30);
return baseHeight + bottomMargin;
if (expanded) {
return expandedContent.height + 28;
}
return 116;
const baseHeight = 116;
if (descriptionExpanded && descriptionText.hasMoreText) {
const twoLineHeight = descriptionText.font.pixelSize * 1.2 * 2;
const extraHeight = descriptionText.contentHeight - twoLineHeight;
return baseHeight + extraHeight;
}
return baseHeight;
}
radius: Theme.cornerRadiusLarge
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.1)
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3)
border.color: notificationGroup?.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.05)
border.width: notificationGroup?.latestNotification?.urgency === 2 ? 2 : 1
clip: true
Rectangle {
width: 4
height: parent.height - 16
anchors.left: parent.left
anchors.leftMargin: 2
anchors.verticalCenter: parent.verticalCenter
radius: 2
color: Theme.primary
anchors.fill: parent
radius: parent.radius
visible: notificationGroup?.latestNotification?.urgency === 2
gradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
position: 0.0
color: Theme.primary
}
GradientStop {
position: 0.02
color: Theme.primary
}
GradientStop {
position: 0.021
color: "transparent"
}
}
opacity: 1.0
}
Item {
id: collapsedContent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 12
anchors.leftMargin: 16
anchors.rightMargin: 16
anchors.rightMargin: 56
height: 92
visible: !expanded
Rectangle {
id: iconContainer
readonly property bool hasNotificationImage: notificationGroup?.latestNotification?.image && notificationGroup.latestNotification.image !== ""
width: 55
@@ -70,12 +84,10 @@ Rectangle {
source: {
if (parent.hasNotificationImage)
return notificationGroup.latestNotification.cleanImage;
if (notificationGroup?.latestNotification?.appIcon) {
const appIcon = notificationGroup.latestNotification.appIcon;
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://"))
return appIcon;
return Quickshell.iconPath(appIcon, "");
}
return "";
@@ -121,7 +133,7 @@ Rectangle {
anchors.left: iconContainer.right
anchors.leftMargin: 12
anchors.right: controlsContainer.left
anchors.right: parent.right
anchors.rightMargin: 0
anchors.top: parent.top
anchors.bottom: parent.bottom
@@ -132,7 +144,7 @@ Rectangle {
width: parent.width
height: parent.height
anchors.top: parent.top
anchors.topMargin: 2
anchors.topMargin: -4
Column {
width: parent.width
@@ -166,95 +178,42 @@ Rectangle {
}
Text {
text: {
let bodyText = notificationGroup?.latestNotification?.body || "";
const urlRegex = /(https?:\/\/[^\s]+)/g;
return bodyText.replace(urlRegex, '<a href="$1" style="color: ' + Theme.primary + '; text-decoration: underline;">$1</a>');
}
id: descriptionText
property string fullText: notificationGroup?.latestNotification?.body || ""
property bool hasMoreText: false
text: fullText
color: Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
width: parent.width
elide: Text.ElideRight
maximumLineCount: (notificationGroup?.count || 0) > 1 ? 2 : 3
maximumLineCount: descriptionExpanded ? -1 : 2
wrapMode: Text.WordWrap
visible: text.length > 0
textFormat: Text.RichText
onLinkActivated: function(link) {
Qt.openUrlExternally(link);
textFormat: Text.PlainText
onContentHeightChanged: {
const singleLineHeight = font.pixelSize * 1.2;
const twoLineHeight = singleLineHeight * 2;
hasMoreText = descriptionText.contentHeight > twoLineHeight;
}
MouseArea {
anchors.fill: parent
cursorShape: parent.hasMoreText ? Qt.PointingHandCursor : Qt.ArrowCursor
enabled: parent.hasMoreText
onClicked: {
descriptionExpanded = !descriptionExpanded;
}
}
}
}
}
}
Item {
id: controlsContainer
anchors.right: parent.right
anchors.rightMargin: 0
anchors.top: parent.top
anchors.topMargin: 0
width: (notificationGroup?.count || 0) > 1 ? 40 : 20
height: 24
Rectangle {
anchors.left: parent.left
anchors.top: parent.top
width: 20
height: 20
radius: 10
color: expandArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
visible: (notificationGroup?.count || 0) > 1
DankIcon {
anchors.centerIn: parent
name: expanded ? "expand_less" : "expand_more"
size: 14
color: Theme.surfaceText
}
MouseArea {
id: expandArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.toggleGroupExpansion(notificationGroup?.key || "")
}
}
Rectangle {
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"
DankIcon {
name: "close"
size: 14
color: parent.isHovered ? Theme.primary : Theme.surfaceText
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: parent.isHovered = true
onExited: parent.isHovered = false
onClicked: NotificationService.dismissGroup(notificationGroup?.key || "")
}
}
}
}
Column {
id: expandedContent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
@@ -271,6 +230,8 @@ Rectangle {
Row {
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 56
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingS
@@ -280,6 +241,8 @@ Rectangle {
font.pixelSize: Theme.fontSizeLarge
font.weight: Font.Bold
anchors.verticalCenter: parent.verticalCenter
elide: Text.ElideRight
maximumLineCount: 1
}
Rectangle {
@@ -300,61 +263,6 @@ Rectangle {
}
}
Item {
width: 48
height: 24
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 2
Rectangle {
width: 20
height: 20
radius: 10
anchors.left: parent.left
color: collapseArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankIcon {
anchors.centerIn: parent
name: "expand_less"
size: 14
color: Theme.surfaceText
}
MouseArea {
id: collapseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.toggleGroupExpansion(notificationGroup?.key || "")
}
}
Rectangle {
width: 20
height: 20
radius: 10
anchors.right: parent.right
color: dismissAllArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankIcon {
anchors.centerIn: parent
name: "close"
size: 14
color: Theme.surfaceText
}
MouseArea {
id: dismissAllArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.dismissGroup(notificationGroup?.key || "")
}
}
}
}
Column {
@@ -369,15 +277,33 @@ Rectangle {
readonly property bool messageExpanded: NotificationService.expandedMessages[modelData?.notification?.id] || false
width: parent.width
height: messageExpanded ? Math.min(120, 50 + (bodyText.contentHeight || 0)) : 80
height: {
const baseHeight = 120;
if (messageExpanded) {
const twoLineHeight = bodyText.font.pixelSize * 1.2 * 2;
if (bodyText.implicitHeight > twoLineHeight + 2) {
const extraHeight = bodyText.implicitHeight - twoLineHeight;
return baseHeight + extraHeight;
}
}
return baseHeight;
}
radius: Theme.cornerRadiusLarge
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.2)
color: "transparent"
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05)
border.width: 1
Behavior on height {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
Item {
anchors.fill: parent
anchors.margins: 12
anchors.bottomMargin: 18
Rectangle {
id: messageIcon
@@ -388,7 +314,7 @@ Rectangle {
height: 32
radius: 16
anchors.left: parent.left
anchors.top: parent.top
anchors.verticalCenter: parent.verticalCenter
color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1)
border.color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
border.width: 1
@@ -428,26 +354,21 @@ Rectangle {
Column {
anchors.left: messageIcon.right
anchors.leftMargin: 12
anchors.right: messageControls.left
anchors.rightMargin: 0
anchors.right: parent.right
anchors.rightMargin: 12
anchors.top: parent.top
spacing: 4
anchors.topMargin: -2
spacing: 2
Text {
width: parent.width
text: {
const appName = modelData?.appName || "";
const timeStr = modelData?.timeStr || "";
if (timeStr.length > 0)
return appName + " • " + timeStr;
else
return appName;
}
text: modelData?.timeStr || ""
color: Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
elide: Text.ElideRight
maximumLineCount: 1
visible: text.length > 0
}
Text {
@@ -463,85 +384,94 @@ Rectangle {
Text {
id: bodyText
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>');
}
text: modelData?.body || ""
color: Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
width: parent.width
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);
}
}
}
Row {
id: messageControls
anchors.right: parent.right
anchors.rightMargin: -6
anchors.top: parent.top
spacing: 4
Rectangle {
width: 20
height: 20
radius: 10
color: expandMessageArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
visible: (modelData?.body || "").length > 80
DankIcon {
anchors.centerIn: parent
name: {
const messageExpanded = NotificationService.expandedMessages[modelData?.notification?.id] || false;
return messageExpanded ? "expand_less" : "expand_more";
textFormat: Text.PlainText
MouseArea {
anchors.fill: parent
cursorShape: parent.truncated ? Qt.PointingHandCursor : Qt.ArrowCursor
enabled: parent.truncated || messageExpanded
onClicked: {
NotificationService.toggleMessageExpansion(modelData?.notification?.id || "");
}
size: 12
color: Theme.surfaceText
}
MouseArea {
id: expandMessageArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.toggleMessageExpansion(modelData?.notification?.id || "")
}
}
Rectangle {
width: 20
height: 20
radius: 10
color: closeMessageArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
Row {
anchors.right: parent.right
spacing: 8
anchors.topMargin: 4
anchors.bottomMargin: 6
DankIcon {
anchors.centerIn: parent
name: "close"
size: 12
color: closeMessageArea.containsMouse ? Theme.primary : Theme.surfaceText
Repeater {
model: modelData?.actions || []
Rectangle {
property bool isHovered: false
width: Math.max(actionText.implicitWidth + 12, 50)
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
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: parent.isHovered = true
onExited: parent.isHovered = false
onClicked: {
if (modelData && modelData.invoke) {
modelData.invoke();
}
}
}
}
}
MouseArea {
id: closeMessageArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.dismissNotification(modelData)
Rectangle {
property bool isHovered: false
width: Math.max(dismissText.implicitWidth + 12, 50)
height: 24
radius: 4
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
Text {
id: dismissText
text: "Dismiss"
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: parent.isHovered = true
onExited: parent.isHovered = false
onClicked: NotificationService.dismissNotification(modelData)
}
}
}
}
@@ -551,49 +481,46 @@ Rectangle {
}
}
Rectangle {
property bool isHovered: false
Row {
visible: !expanded
anchors.right: dismissButton.left
anchors.rightMargin: 4
anchors.rightMargin: 8
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
width: viewText.width + 16
height: viewText.height + 8
radius: 6
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
Text {
id: viewText
text: "View"
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: parent.isHovered = true
onExited: parent.isHovered = false
onClicked: {
if (notificationGroup?.latestNotification?.actions) {
for (const action of notificationGroup.latestNotification.actions) {
if (action.text && action.text.toLowerCase() === "view") {
if (action.invoke) {
action.invoke();
return;
}
spacing: 8
Repeater {
model: notificationGroup?.latestNotification?.actions || []
Rectangle {
property bool isHovered: false
width: Math.max(actionText.implicitWidth + 12, 50)
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
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: parent.isHovered = true
onExited: parent.isHovered = false
onClicked: {
if (modelData && modelData.invoke) {
modelData.invoke();
}
}
if (notificationGroup.latestNotification.actions.length > 0) {
const firstAction = notificationGroup.latestNotification.actions[0];
if (firstAction.invoke)
firstAction.invoke();
}
}
}
}
@@ -604,6 +531,7 @@ Rectangle {
property bool isHovered: false
visible: !expanded
anchors.right: parent.right
anchors.rightMargin: 16
anchors.bottom: parent.bottom
@@ -640,16 +568,39 @@ Rectangle {
z: -1
}
Behavior on height {
SequentialAnimation {
PauseAnimation {
duration: 25
}
Item {
id: fixedControls
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: 12
anchors.rightMargin: 16
width: 40
height: 24
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
DankActionButton {
anchors.left: parent.left
anchors.top: parent.top
visible: (notificationGroup?.count || 0) > 1
iconName: expanded ? "expand_less" : "expand_more"
iconSize: 14
buttonSize: 20
onClicked: NotificationService.toggleGroupExpansion(notificationGroup?.key || "")
}
DankActionButton {
anchors.right: parent.right
anchors.top: parent.top
iconName: "close"
iconSize: 14
buttonSize: 20
onClicked: NotificationService.dismissGroup(notificationGroup?.key || "")
}
}
Behavior on height {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
}

View File

@@ -14,8 +14,11 @@ PanelWindow {
property bool notificationHistoryVisible: false
visible: notificationHistoryVisible
onNotificationHistoryVisibleChanged: {
NotificationService.disablePopups(notificationHistoryVisible);
}
implicitWidth: 400
implicitHeight: Math.min(Screen.height * 0.6, Math.max(580, 720))
implicitHeight: Math.min(Screen.height * 0.8, 400)
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.exclusiveZone: -1
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
@@ -36,8 +39,22 @@ PanelWindow {
}
Rectangle {
id: mainRect
function calculateHeight() {
let baseHeight = Theme.spacingL * 2;
baseHeight += notificationHeader.height;
baseHeight += Theme.spacingM;
let listHeight = notificationList.listContentHeight;
if (NotificationService.groupedNotifications.length === 0)
listHeight = 200;
baseHeight += Math.min(listHeight, 600);
return Math.max(300, baseHeight);
}
width: 400
height: Math.min(Screen.height * 0.6, Math.max(580, 720))
height: calculateHeight()
x: Screen.width - width - Theme.spacingL
y: Theme.barHeight + Theme.spacingXS
color: Theme.popupBackground()
@@ -45,103 +62,7 @@ PanelWindow {
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
border.width: 1
opacity: notificationHistoryVisible ? 1 : 0
Rectangle {
anchors.fill: parent
anchors.margins: -3
color: "transparent"
radius: parent.radius + 3
border.color: Qt.rgba(0, 0, 0, 0.05)
border.width: 1
z: -3
}
Rectangle {
anchors.fill: parent
anchors.margins: -2
color: "transparent"
radius: parent.radius + 2
border.color: Qt.rgba(0, 0, 0, 0.08)
border.width: 1
z: -2
}
Rectangle {
anchors.fill: parent
color: "transparent"
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
border.width: 1
radius: parent.radius
z: -1
}
transform: [
Scale {
id: scaleTransform
origin.x: 400
origin.y: 0
xScale: notificationHistoryVisible ? 1 : 0.95
yScale: notificationHistoryVisible ? 1 : 0.8
},
Translate {
id: translateTransform
x: notificationHistoryVisible ? 0 : 15
y: notificationHistoryVisible ? 0 : -30
}
]
states: [
State {
name: "visible"
when: notificationHistoryVisible
PropertyChanges {
target: scaleTransform
xScale: 1
yScale: 1
}
PropertyChanges {
target: translateTransform
x: 0
y: 0
}
},
State {
name: "hidden"
when: !notificationHistoryVisible
PropertyChanges {
target: scaleTransform
xScale: 0.95
yScale: 0.8
}
PropertyChanges {
target: translateTransform
x: 15
y: -30
}
}
]
transitions: [
Transition {
from: "*"
to: "*"
ParallelAnimation {
NumberAnimation {
targets: [scaleTransform, translateTransform]
properties: "xScale,yScale,x,y"
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
}
]
scale: notificationHistoryVisible ? 1 : 0.9
MouseArea {
anchors.fill: parent
@@ -150,27 +71,71 @@ PanelWindow {
}
Column {
id: contentColumn
anchors.fill: parent
anchors.margins: Theme.spacingL
spacing: Theme.spacingM
NotificationHeader {}
NotificationList {}
NotificationHeader {
id: notificationHeader
}
NotificationList {
id: notificationList
width: parent.width
height: parent.height - notificationHeader.height - contentColumn.spacing
}
}
Connections {
function onNotificationsChanged() {
mainRect.height = mainRect.calculateHeight();
}
function onGroupedNotificationsChanged() {
mainRect.height = mainRect.calculateHeight();
}
function onExpandedGroupsChanged() {
mainRect.height = mainRect.calculateHeight();
}
function onExpandedMessagesChanged() {
mainRect.height = mainRect.calculateHeight();
}
target: NotificationService
}
Behavior on height {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
Behavior on opacity {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
duration: Anims.durMed
easing.type: Easing.BezierSpline
easing.bezierCurve: Anims.emphasized
}
}
Behavior on scale {
NumberAnimation {
duration: Anims.durMed
easing.type: Easing.BezierSpline
easing.bezierCurve: Anims.emphasized
}
}
}
}
}

View File

@@ -5,14 +5,14 @@ import qs.Widgets
Item {
id: root
width: parent.width
height: 200
visible: NotificationService.notifications.length === 0
Column {
anchors.centerIn: parent
spacing: Theme.spacingM
spacing: Theme.spacingXS
width: parent.width * 0.8
DankIcon {
@@ -24,21 +24,13 @@ Item {
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: "No notifications"
text: "Nothing to see here"
font.pixelSize: Theme.fontSizeLarge
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.3)
font.weight: Font.Medium
horizontalAlignment: Text.AlignHCenter
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: "Notifications will appear here"
font.pixelSize: Theme.fontSizeMedium
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.4)
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
width: parent.width
}
}
}
}

View File

@@ -6,7 +6,7 @@ import qs.Widgets
Item {
id: root
width: parent.width
height: 32
@@ -48,11 +48,12 @@ Item {
font.weight: Font.Medium
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
id: clearArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
@@ -64,6 +65,7 @@ Item {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
Behavior on border.color {
@@ -71,6 +73,9 @@ Item {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
}
}

View File

@@ -3,89 +3,116 @@ import QtQuick.Controls
import qs.Common
import qs.Services
ScrollView {
ListView {
id: root
property alias count: root.count
readonly property real listContentHeight: root.contentHeight
readonly property bool atYBeginning: root.contentY === 0
property real stableY: 0
property bool isUserScrolling: false
width: parent.width
height: parent.height - 140
height: parent.height
clip: true
contentWidth: -1
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AsNeeded
model: NotificationService.groupedNotifications
spacing: Theme.spacingL
interactive: true
boundsBehavior: Flickable.StopAtBounds
flickDeceleration: 1500
maximumFlickVelocity: 2000
cacheBuffer: 1000
onMovementStarted: isUserScrolling = true
onMovementEnded: {
isUserScrolling = false;
if (contentY > 40)
stableY = contentY;
ListView {
id: notificationsList
}
onContentYChanged: {
if (!isUserScrolling && visible && parent.visible && stableY > 40 && Math.abs(contentY - stableY) > 10)
contentY = stableY;
model: NotificationService.groupedNotifications
spacing: Theme.spacingL
interactive: true
boundsBehavior: Flickable.StopAtBounds
flickDeceleration: 1500
maximumFlickVelocity: 2000
}
NotificationEmptyState {
visible: root.count === 0
anchors.centerIn: parent
}
add: Transition {
enabled: !root.isUserScrolling
ParallelAnimation {
NumberAnimation {
properties: "opacity"
from: 0
to: 1
duration: root.isUserScrolling ? 0 : Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
NumberAnimation {
properties: "height"
from: 0
duration: root.isUserScrolling ? 0 : Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
}
remove: Transition {
SequentialAnimation {
PauseAnimation {
duration: 50
}
add: Transition {
ParallelAnimation {
NumberAnimation {
properties: "opacity"
from: 0
to: 1
to: 0
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
NumberAnimation {
properties: "height"
from: 0
properties: "height,anchors.topMargin,anchors.bottomMargin"
to: 0
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
}
remove: Transition {
SequentialAnimation {
PauseAnimation {
duration: 50
}
ParallelAnimation {
NumberAnimation {
properties: "opacity"
to: 0
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
NumberAnimation {
properties: "height,anchors.topMargin,anchors.bottomMargin"
to: 0
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
}
}
displaced: Transition {
NumberAnimation {
properties: "y"
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
move: Transition {
NumberAnimation {
properties: "y"
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
delegate: NotificationCard {
notificationGroup: modelData
}
}
NotificationEmptyState {}
}
displaced: Transition {
enabled: !root.isUserScrolling
NumberAnimation {
properties: "y"
duration: 0
}
}
move: Transition {
enabled: !root.isUserScrolling
NumberAnimation {
properties: "y"
duration: (root.atYBeginning && !root.isUserScrolling) ? Theme.mediumDuration : 0
easing.type: Theme.emphasizedEasing
}
}
delegate: NotificationCard {
notificationGroup: modelData
}
}

View File

@@ -60,7 +60,6 @@ PanelWindow {
readonly property bool isPopup: modelData.latestNotification.popup
readonly property int expireTimeout: modelData.latestNotification.notification.expireTimeout
property string stableGroupKey: ""
// Watch for changes to latest notification (new message joins group)
property var currentLatestNotification: modelData.latestNotification
Component.onCompleted: {
@@ -70,7 +69,6 @@ PanelWindow {
height: {
if (expanded && modelData.count >= 1) {
const baseHeight = (116 * modelData.count) + (12 * (modelData.count - 1));
// Add extra bottom margin for View/Dismiss buttons when there are fewer than 3 messages
const bottomMargin = modelData.count === 1 ? 70 : (modelData.count < 3 ? 50 : -28);
return baseHeight + bottomMargin;
}
@@ -81,8 +79,12 @@ PanelWindow {
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
clip: true
// Material 3 elevation with multiple layers
onCurrentLatestNotificationChanged: {
if (isPopup && !cardHoverArea.containsMouse)
dismissTimer.restart();
}
Rectangle {
anchors.fill: parent
anchors.margins: -3
@@ -92,7 +94,7 @@ PanelWindow {
border.width: 1
z: -3
}
Rectangle {
anchors.fill: parent
anchors.margins: -2
@@ -102,7 +104,7 @@ PanelWindow {
border.width: 1
z: -2
}
Rectangle {
anchors.fill: parent
color: "transparent"
@@ -111,24 +113,35 @@ PanelWindow {
radius: parent.radius
z: -1
}
onCurrentLatestNotificationChanged: {
if (isPopup && !cardHoverArea.containsMouse)
dismissTimer.restart();
}
Rectangle {
width: 4
height: parent.height - 16
anchors.left: parent.left
anchors.leftMargin: 2
anchors.verticalCenter: parent.verticalCenter
radius: 2
color: Theme.primary
anchors.fill: parent
radius: parent.radius
visible: modelData.latestNotification.urgency === 2
opacity: 1
gradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
position: 0
color: Theme.primary
}
GradientStop {
position: 0.02
color: Theme.primary
}
GradientStop {
position: 0.021
color: "transparent"
}
}
}
// Collapsed view - show only latest notification
Item {
id: collapsedContent
@@ -160,11 +173,9 @@ PanelWindow {
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://"))
@@ -272,9 +283,7 @@ PanelWindow {
}
text: {
// Auto-detect and make URLs clickable, with truncation for popups
let bodyText = modelData.latestNotification.body;
// Truncate to 108 characters max for popup notifications
if (bodyText.length > 105)
bodyText = bodyText.substring(0, 102) + "...";
@@ -307,89 +316,42 @@ PanelWindow {
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
width: modelData.count > 1 ? 40 : 20
height: 24
// Expand button - always takes up space but only visible when needed
Rectangle {
id: collapsedExpandButton
DankActionButton {
anchors.left: parent.left
anchors.top: parent.top
width: 20
height: 20
radius: 10
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: expanded ? "expand_less" : "expand_more"
size: 14
color: Theme.surfaceText
}
MouseArea {
id: expandArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.toggleGroupExpansion(modelData.key)
}
iconName: expanded ? "expand_less" : "expand_more"
iconSize: 14
buttonSize: 20
z: 15
onClicked: NotificationService.toggleGroupExpansion(modelData.key)
}
// Close button - always positioned at the right edge
Rectangle {
id: closeButton
property bool isHovered: false
DankActionButton {
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;
dismissTimer.stop();
iconName: "close"
iconSize: 14
buttonSize: 20
z: 15
onClicked: {
if (modelData.latestNotification.notification.transient) {
NotificationService.dismissGroup(modelData.key);
} else {
for (const notif of modelData.notifications) {
notif.popup = false;
}
}
onExited: {
closeButton.isHovered = false;
if (modelData.latestNotification.popup && !cardHoverArea.containsMouse)
dismissTimer.restart();
}
onClicked: NotificationService.dismissGroup(modelData.key)
}
}
}
}
// Expanded view - show all notifications in group
Item {
anchors.fill: parent
anchors.margins: 16
@@ -401,7 +363,6 @@ PanelWindow {
width: parent.width
spacing: 10
// Header with app name and count
Item {
width: parent.width
height: 32
@@ -449,52 +410,28 @@ PanelWindow {
anchors.fill: parent
spacing: 8
Rectangle {
width: 20
height: 20
radius: 10
color: expandedExpandArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankIcon {
anchors.centerIn: parent
name: "expand_less"
size: 14
color: Theme.surfaceText
}
MouseArea {
id: expandedExpandArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.toggleGroupExpansion(modelData.key)
}
DankActionButton {
iconName: "expand_less"
iconSize: 14
buttonSize: 20
z: 15
onClicked: NotificationService.toggleGroupExpansion(modelData.key)
}
Rectangle {
width: 20
height: 20
radius: 10
color: expandedCloseArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankIcon {
anchors.centerIn: parent
name: "close"
size: 14
color: expandedCloseArea.containsMouse ? Theme.primary : Theme.surfaceText
DankActionButton {
iconName: "close"
iconSize: 14
buttonSize: 20
z: 15
onClicked: {
if (modelData.latestNotification.notification.transient) {
NotificationService.dismissGroup(modelData.key);
} else {
for (const notif of modelData.notifications) {
notif.popup = false;
}
}
}
MouseArea {
id: expandedCloseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.dismissGroup(modelData.key)
}
}
}
@@ -503,7 +440,6 @@ PanelWindow {
}
// Scrollable list of individual notifications
Rectangle {
width: parent.width
height: Math.min(400, modelData.notifications.length * 90) // Fixed height constraint for inner scroll
@@ -669,56 +605,22 @@ PanelWindow {
spacing: 4
// Expand/collapse button for individual message
Rectangle {
id: expandButton
width: 20
height: 20
radius: 10
color: expandMessageArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankActionButton {
visible: (modelData.body || "").length > 80
DankIcon {
anchors.centerIn: parent
name: messageExpanded ? "expand_less" : "expand_more"
size: 12
color: Theme.surfaceText
}
MouseArea {
id: expandMessageArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.toggleMessageExpansion(modelData.notification.id)
}
iconName: messageExpanded ? "expand_less" : "expand_more"
iconSize: 12
buttonSize: 20
z: 15
onClicked: NotificationService.toggleMessageExpansion(modelData.notification.id)
}
// Close button for individual message
Rectangle {
width: 20
height: 20
radius: 10
color: closeMessageArea.containsMouse ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.08) : "transparent"
DankIcon {
anchors.centerIn: parent
name: "close"
size: 12
color: closeMessageArea.containsMouse ? Theme.primary : Theme.surfaceText
}
MouseArea {
id: closeMessageArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: NotificationService.dismissNotification(modelData)
}
DankActionButton {
iconName: "close"
iconSize: 12
buttonSize: 20
z: 15
onClicked: NotificationService.dismissNotification(modelData)
}
}
@@ -747,13 +649,13 @@ PanelWindow {
}
// Main hover area for persistence
// Main hover area for persistence and click handling
MouseArea {
id: cardHoverArea
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
acceptedButtons: Qt.LeftButton
propagateComposedEvents: true
z: 0
onEntered: {
@@ -764,71 +666,72 @@ PanelWindow {
dismissTimer.restart();
}
onClicked: {
if (modelData.latestNotification.notification.transient) {
NotificationService.dismissGroup(modelData.key);
} else {
for (const notif of modelData.notifications) {
notif.popup = false;
}
}
}
}
// View button positioned at bottom-right of notification card
Rectangle {
id: viewButton
property bool isHovered: false
// Action buttons positioned at bottom-left of notification card
Row {
anchors.right: dismissButton.left
anchors.rightMargin: 4
anchors.rightMargin: 8
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
width: viewText.width + 16
height: viewText.height + 8
radius: 6
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
spacing: 4
z: 10
Text {
id: viewText
Repeater {
model: modelData.latestNotification.actions || []
text: "View"
color: viewButton.isHovered ? Theme.primary : Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
anchors.centerIn: parent
}
Rectangle {
property bool isHovered: false
MouseArea {
id: viewArea
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"
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
z: 11
onEntered: {
viewButton.isHovered = true;
dismissTimer.stop();
}
onExited: {
viewButton.isHovered = false;
if (modelData.latestNotification.popup && !cardHoverArea.containsMouse)
dismissTimer.restart();
Text {
id: actionText
}
onClicked: {
// Handle navigation to source message
if (modelData.latestNotification.actions) {
for (const action of modelData.latestNotification.actions) {
if (action.text && action.text.toLowerCase() === "view") {
if (action.invoke) {
action.invoke();
return ;
}
}
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();
}
// If no View action, try the first available action
if (modelData.latestNotification.actions.length > 0) {
const firstAction = modelData.latestNotification.actions[0];
if (firstAction.invoke)
firstAction.invoke();
onExited: {
parent.isHovered = false;
if (modelData.latestNotification.popup && !cardHoverArea.containsMouse)
dismissTimer.restart();
}
onClicked: {
if (modelData && modelData.invoke)
modelData.invoke();
}
}
}
}
}
@@ -877,12 +780,7 @@ PanelWindow {
}
onClicked: {
// Move to notification center (don't close)
const groupKey = stableGroupKey || modelData.key;
console.log("Manually hiding notification group from popup:", groupKey);
modelData.latestNotification.popup = false;
// Clear expansion state when manually hiding from popup
NotificationService.clearGroupExpansionState(groupKey);
NotificationService.dismissGroup(modelData.key);
}
}
@@ -896,7 +794,6 @@ PanelWindow {
onTriggered: {
// Move to notification center (don't dismiss completely)
const groupKey = stableGroupKey || modelData.key;
console.log("Auto-hiding notification group from popup:", groupKey);
modelData.latestNotification.popup = false;
// Clear expansion state when hiding from popup
NotificationService.clearGroupExpansionState(groupKey);

View File

@@ -323,7 +323,6 @@ PanelWindow {
if (controlCenterPopout.controlCenterVisible) {
if (NetworkService.wifiEnabled)
NetworkService.scanWifi();
}
}
}
@@ -334,4 +333,4 @@ PanelWindow {
}
}
}