@@ -14,21 +14,23 @@ WrapperMouseArea {
1414
1515 acceptedButtons: Qt .AllButtons
1616
17- property string appIcon: " "
18- property string app: " "
19- property string summary: " "
20- property string body: " "
21- property string icon: " "
22- property list< NotificationAction> actions: []
17+ property Notification n
18+ property string image: (n .image == " " && n .appIcon != " " ) ? n .appIcon : n .image
19+ property bool hasAppIcon: ! (n .image == " " && n .appIcon != " " )
2320 property int indexPopup: - 1
2421 property int indexAll: - 1
25- property bool hasDismiss: true
2622 property real iconSize: 48
2723 property bool expanded: false
2824
25+ function getImage (image : string ): string {
26+ if (image .search (/ :\/\/ / ) != - 1 )
27+ return Qt .resolvedUrl (image);
28+ return Quickshell .iconPath (image);
29+ }
30+
2931 onClicked : mouse => {
30- if (mouse .button == Qt .LeftButton && actions != []) {
31- actions[0 ].invoke ();
32+ if (mouse .button == Qt .LeftButton && root . n . actions != []) {
33+ root . n . actions [0 ].invoke ();
3234 } else if (mouse .button == Qt .RightButton ) {
3335 if (indexAll != - 1 )
3436 NotificationState .notifDismissByAll (indexAll);
@@ -59,23 +61,41 @@ WrapperMouseArea {
5961 Item {
6062 id: coverItem
6163
62- visible: root .icon != " "
64+ visible: root .image != " "
6365
6466 Layout .alignment : Qt .AlignTop
6567 implicitWidth: root .iconSize
6668 implicitHeight: root .iconSize
67- Layout .margins : 8
69+ Layout .margins : 12
6870 Layout .rightMargin : 0
6971
7072 ClippingWrapperRectangle {
71- visible: root .icon != " "
7273 anchors .centerIn : parent
7374 radius: 8
7475 color: " transparent"
7576
7677 IconImage {
7778 implicitSize: coverItem .height
78- source: Quickshell .iconPath (root .icon )
79+ source: root .getImage (root .image )
80+ }
81+ }
82+
83+ ClippingWrapperRectangle {
84+ visible: root .hasAppIcon
85+
86+ anchors {
87+ horizontalCenter: coverItem .right
88+ verticalCenter: coverItem .bottom
89+ horizontalCenterOffset: - 4
90+ verticalCenterOffset: - 4
91+ }
92+
93+ radius: 2
94+ color: " transparent"
95+
96+ IconImage {
97+ implicitSize: 16
98+ source: root .getImage (root .n .appIcon )
7999 }
80100 }
81101 }
@@ -84,44 +104,36 @@ WrapperMouseArea {
84104 id: contentLayout
85105
86106 Layout .fillWidth : true
87- Layout .fillHeight : true
88- Layout .margins : 8
89- Layout .leftMargin : coverItem .visible ? 0 : 8
107+ Layout .margins : 12
108+ Layout .leftMargin : coverItem .visible ? 4 : 12
90109 spacing: 4
91110
92- // HACK: gives the illusion that 2-row text is centered (when bodyText is only one
93- // row, and no action buttons are present)
94- Item {
95- Layout .fillHeight : true
96- }
97-
98111 Text {
99112 Layout .maximumWidth : contentLayout .width - buttonLayout .width
100- text: root .summary
113+ text: root .n . summary
101114 elide: Text .ElideRight
102115 font .weight : Font .Bold
103116 }
104117
105118 Text {
106119 id: bodyText
107120 Layout .fillWidth : true
108- Layout .fillHeight : true
109121 elide: Text .ElideRight
110122 wrapMode: Text .Wrap
111123 font .weight : Font .Medium
112- maximumLineCount: root .expanded ? 5 : (root .actions .length > 1 ? 1 : 2 )
113- text: root .body
124+ maximumLineCount: root .expanded ? 5 : (root .n . actions .length > 1 ? 1 : 2 )
125+ text: root .n . body
114126 }
115127
116128 RowLayout {
117- visible: root .actions .length > 1
129+ visible: root .n . actions .length > 1
118130
119131 Layout .fillWidth : true
120132 implicitHeight: actionRepeater .implicitHeight
121133
122134 Repeater {
123135 id: actionRepeater
124- model: root .actions .slice (1 )
136+ model: root .n . actions .slice (1 )
125137
126138 WrapperMouseArea {
127139 id: actionButtonMA
@@ -170,7 +182,7 @@ WrapperMouseArea {
170182 WrapperMouseArea {
171183 id: expandButton
172184
173- visible: bodyText .text .length > (root .actions .length > 1 ? 50 : 100 )
185+ visible: bodyText .text .length > (root .n . actions .length > 1 ? 50 : 100 )
174186
175187 property string sourceIcon: root .expanded ? " go-up-symbolic" : " go-down-symbolic"
176188
0 commit comments