1+ pragma ComponentBehavior : Bound
2+
13import QtQuick
24import QtQuick.Layouts
35import Quickshell
6+ import Quickshell.Services.Notifications
47import Quickshell.Widgets
58import org.kde.kirigami
69import "../utils/."
@@ -16,14 +19,17 @@ WrapperMouseArea {
1619 property string summary: " "
1720 property string body: " "
1821 property string icon: " "
22+ property list< NotificationAction> actions: []
1923 property int indexPopup: - 1
2024 property int indexAll: - 1
2125 property bool hasDismiss: true
2226 property real iconSize: 48
2327 property bool expanded: false
2428
2529 onClicked : mouse => {
26- if (mouse .button == Qt .RightButton ) {
30+ if (mouse .button == Qt .LeftButton && actions != []) {
31+ actions[0 ].invoke ();
32+ } else if (mouse .button == Qt .RightButton ) {
2733 if (indexAll != - 1 )
2834 NotificationState .notifDismissByAll (indexAll);
2935 else if (indexPopup != - 1 )
@@ -79,9 +85,9 @@ WrapperMouseArea {
7985 id: contentLayout
8086
8187 Layout .fillWidth : true
82- Layout .margins : 15
83- Layout .leftMargin : coverItem .visible ? 0 : 15
84- spacing: 5
88+ Layout .margins : 8
89+ Layout .leftMargin : coverItem .visible ? 0 : 8
90+ spacing: 4
8591
8692 Text {
8793 Layout .maximumWidth : contentLayout .width - buttonLayout .width
@@ -95,9 +101,50 @@ WrapperMouseArea {
95101 Layout .fillHeight : true
96102 elide: Text .ElideRight
97103 wrapMode: Text .Wrap
98- maximumLineCount: root .expanded ? 5 : 1
104+ maximumLineCount: root .expanded ? 5 : ( root . actions . length > 1 ? 1 : 2 )
99105 text: root .body
100106 }
107+
108+ RowLayout {
109+ visible: root .actions .length > 1
110+
111+ Layout .fillWidth : true
112+ implicitHeight: actionRepeater .implicitHeight
113+
114+ Repeater {
115+ id: actionRepeater
116+ model: root .actions .slice (1 )
117+
118+ WrapperMouseArea {
119+ id: actionButtonMA
120+ required property NotificationAction modelData
121+
122+ hoverEnabled: true
123+ implicitHeight: actionButton .implicitHeight
124+ Layout .fillWidth : true
125+
126+ onPressed : () => {
127+ modelData .invoke ();
128+ }
129+
130+ Rectangle {
131+ id: actionButton
132+
133+ radius: 16
134+ color: actionButtonMA .containsMouse ? Colors .buttonDisabledHover : Colors .buttonDisabled
135+ implicitHeight: buttonText .implicitHeight
136+ Layout .fillWidth : true
137+
138+ Text {
139+ id: buttonText
140+
141+ anchors .centerIn : parent
142+ text: actionButtonMA .modelData .text
143+ }
144+ }
145+ }
146+ }
147+ }
101148 }
102149 }
103150
@@ -108,14 +155,14 @@ WrapperMouseArea {
108155 anchors {
109156 top: parent .top
110157 right: parent .right
111- topMargin: 13
112- rightMargin: 12
158+ topMargin: 8
159+ rightMargin: 8
113160 }
114161
115162 WrapperMouseArea {
116163 id: expandButton
117164
118- visible: bodyText .truncated
165+ visible: bodyText .text . length > ( root . actions . length > 1 ? 50 : 100 )
119166
120167 property string sourceIcon: " go-down-symbolic"
121168
@@ -130,7 +177,7 @@ WrapperMouseArea {
130177
131178 Rectangle {
132179 radius: 16
133- color: expandButton .containsMouse ? Colors .bgBar : Colors .bgBlur
180+ color: expandButton .containsMouse ? Colors .buttonDisabledHover : Colors .buttonDisabled
134181 implicitWidth: 16
135182 implicitHeight: 16
136183
@@ -140,7 +187,7 @@ WrapperMouseArea {
140187 implicitHeight: parent .implicitHeight - 4
141188 implicitWidth: parent .implicitHeight - 4
142189 isMask: true
143- color: ' white '
190+ color: Colors . foreground
144191 }
145192 }
146193 }
@@ -161,7 +208,7 @@ WrapperMouseArea {
161208
162209 Rectangle {
163210 radius: 16
164- color: closeButton .containsMouse ? Qt . lighter ( Qt . lighter ( Qt . lighter ( Colors .bgBlur ))) : Qt . lighter ( Qt . lighter ( Colors .bgBlur ))
211+ color: closeButton .containsMouse ? Colors .buttonDisabledHover : Colors .buttonDisabled
165212 implicitWidth: 16
166213 implicitHeight: 16
167214
@@ -171,7 +218,7 @@ WrapperMouseArea {
171218 implicitHeight: parent .implicitHeight - 4
172219 implicitWidth: parent .implicitHeight - 4
173220 isMask: true
174- color: ' white '
221+ color: Colors . foreground
175222 }
176223 }
177224 }
0 commit comments