@@ -31,6 +31,8 @@ class KMessageWidgetPrivate
3131 QFrame *content = nullptr ;
3232 QLabel *iconLabel = nullptr ;
3333 QLabel *textLabel = nullptr ;
34+ QLabel *titleLabel = nullptr ;
35+ QLabel *titelIcon = nullptr ;
3436 QToolButton *closeButton = nullptr ;
3537 QTimeLine *timeLine = nullptr ;
3638 QIcon icon;
@@ -49,6 +51,9 @@ class KMessageWidgetPrivate
4951 void slotTimeLineFinished ();
5052
5153 [[nodiscard]] int bestContentHeight () const ;
54+
55+ private:
56+ void applyNMCStylesheets () const ;
5257};
5358
5459void KMessageWidgetPrivate::init (KMessageWidget *q_ptr)
@@ -73,11 +78,24 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
7378 iconLabel->hide ();
7479
7580 textLabel = new QLabel (content);
76- textLabel->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
81+ textLabel->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
82+ textLabel->setFixedWidth (500 );
7783 textLabel->setTextInteractionFlags (Qt::TextBrowserInteraction);
7884 QObject::connect (textLabel, &QLabel::linkActivated, q, &KMessageWidget::linkActivated);
7985 QObject::connect (textLabel, &QLabel::linkHovered, q, &KMessageWidget::linkHovered);
8086
87+ // Titel-Label konfigurieren
88+ titleLabel = new QLabel (content);
89+ titleLabel->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Fixed);
90+ titleLabel->setText (QCoreApplication::translate (" " , " E2E_ENCRYPTION" ));
91+ titleLabel->setStyleSheet (" font-size: 13px; font-weight: 600;" );
92+
93+ // Icon-Label konfigurieren
94+ titelIcon = new QLabel (content);
95+ titelIcon->setFixedSize (24 , 24 );
96+ titelIcon->setPixmap (QIcon (QStringLiteral (" :/client/theme/NMCIcons/cloud-security.svg" )).pixmap (24 , 24 ));
97+ titelIcon->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
98+
8199 auto *closeAction = new QAction (q);
82100 closeAction->setText (KMessageWidget::tr (" &Close" ));
83101 closeAction->setToolTip (KMessageWidget::tr (" Close message" ));
@@ -86,8 +104,6 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
86104 QObject::connect (closeAction, &QAction::triggered, q, &KMessageWidget::animatedHide);
87105
88106 closeButton = new QToolButton (content);
89- closeButton->setAutoRaise (true );
90- closeButton->setDefaultAction (closeAction);
91107
92108 q->setMessageType (KMessageWidget::Information);
93109}
@@ -104,37 +120,53 @@ void KMessageWidgetPrivate::createLayout()
104120 Q_FOREACH (QAction *action, q->actions ()) {
105121 auto *button = new QToolButton (content);
106122 button->setDefaultAction (action);
107- button->setToolButtonStyle (Qt::ToolButtonTextBesideIcon );
123+ button->setToolButtonStyle (Qt::ToolButtonTextOnly );
108124 buttons.append (button);
109125 }
110126
111127 // AutoRaise reduces visual clutter, but we don't want to turn it on if
112128 // there are other buttons, otherwise the close button will look different
113129 // from the others.
114- closeButton->setAutoRaise (buttons.isEmpty ());
130+ // closeButton->setAutoRaise(buttons.isEmpty());
115131
116- if (wordWrap) {
132+ // NMC customization: make sure we always enter the first case
133+ if (true ) {
117134 auto *layout = new QGridLayout (content);
118- // Set alignment to make sure icon does not move down if text wraps
119- layout->addWidget (iconLabel, 0 , 0 , 1 , 1 , Qt::AlignHCenter | Qt::AlignTop);
120- layout->addWidget (textLabel, 0 , 1 );
135+ layout->setContentsMargins (8 , 4 , 8 , 4 );
136+ layout->setSpacing (0 );
137+ content->setFixedHeight (84 );
138+
139+ auto *titleLayout = new QHBoxLayout ();
140+ titleLayout->setSpacing (8 );
141+ titleLayout->setContentsMargins (0 , 0 , 0 , 0 );
142+ titleLayout->addWidget (titleLabel);
143+ titleLayout->addWidget (titelIcon);
144+
145+ layout->addLayout (titleLayout, 0 , 0 , 1 , 1 , Qt::AlignLeft | Qt::AlignVCenter);
146+
147+ textLabel->setWordWrap (true );
148+ layout->addWidget (textLabel, 1 , 0 );
149+
150+ auto *spacerItem = new QSpacerItem (1 , 1 , QSizePolicy::Fixed, QSizePolicy::Expanding);
151+ layout->addItem (spacerItem, 2 , 0 );
121152
122153 if (buttons.isEmpty ()) {
123154 // Use top-vertical alignment like the icon does.
124- layout->addWidget (closeButton, 0 , 2 , 1 , 1 , Qt::AlignHCenter | Qt::AlignTop);
155+ // layout->addWidget(closeButton, 0, 2, 1, 1, Qt::AlignHCenter | Qt::AlignTop);
125156 } else {
126157 // Use an additional layout in row 1 for the buttons.
127- auto *buttonLayout = new QHBoxLayout;
128- buttonLayout->addStretch ();
158+ auto *buttonLayout = new QVBoxLayout;
159+ buttonLayout->setContentsMargins (0 , 0 , 0 , 0 );
160+ buttonLayout->setSpacing (4 );
129161 Q_FOREACH (QToolButton *button, buttons) {
130162 // For some reason, calling show() is necessary if wordwrap is true,
131163 // otherwise the buttons do not show up. It is not needed if
132164 // wordwrap is false.
133165 button->show ();
134166 buttonLayout->addWidget (button);
135167 }
136- buttonLayout-> addWidget (closeButton );
137- layout-> addItem (buttonLayout, 1 , 0 , 1 , 2 );
168+ layout-> addItem (buttonLayout, 0 , 1 , 3 , 1 , Qt::AlignRight );
169+ applyNMCStylesheets ( );
138170 }
139171 } else {
140172 auto *layout = new QHBoxLayout (content);
@@ -144,8 +176,6 @@ void KMessageWidgetPrivate::createLayout()
144176 for (QToolButton *button : std::as_const (buttons)) {
145177 layout->addWidget (button);
146178 }
147-
148- layout->addWidget (closeButton);
149179 };
150180
151181 if (q->isVisible ()) {
@@ -163,10 +193,10 @@ void KMessageWidgetPrivate::applyStyleSheet()
163193 // The following RGB color values come from the "default" scheme in kcolorscheme.cpp
164194 switch (messageType) {
165195 case KMessageWidget::Positive:
166- bgBaseColor.setRgb (39 , 174 , 96 ); // Window: ForegroundPositive
196+ bgBaseColor.setRgb (204 , 250 , 225 ); // Window: ForegroundPositive
167197 break ;
168198 case KMessageWidget::Information:
169- bgBaseColor.setRgb (61 , 174 , 233 ); // Window: ForegroundActive
199+ bgBaseColor.setRgb (211 , 215 , 249 ); // Window: ForegroundActive
170200 break ;
171201 case KMessageWidget::Warning:
172202 bgBaseColor.setRgb (246 , 116 , 0 ); // Window: ForegroundNeutral
@@ -175,13 +205,11 @@ void KMessageWidgetPrivate::applyStyleSheet()
175205 bgBaseColor.setRgb (218 , 68 , 83 ); // Window: ForegroundNegative
176206 break ;
177207 }
178- const qreal bgBaseColorAlpha = 0.2 ;
208+ const qreal bgBaseColorAlpha = 1.0 ;
179209 bgBaseColor.setAlphaF (bgBaseColorAlpha);
180210
181211 const QPalette palette = QGuiApplication::palette ();
182212 const QColor windowColor = palette.window ().color ();
183- const QColor textColor = palette.text ().color ();
184- const QColor border = bgBaseColor;
185213
186214 // Generate a final background color from overlaying bgBaseColor over windowColor
187215 const int newRed = qRound (bgBaseColor.red () * bgBaseColorAlpha) + qRound (windowColor.red () * (1 - bgBaseColorAlpha));
@@ -197,14 +225,15 @@ void KMessageWidgetPrivate::applyStyleSheet()
197225 " border: 2px solid %2;"
198226 " margin: %3px;"
199227 " }"
200- " .QLabel { color: %4 ; }"
228+ " .QLabel { color: black ; }"
201229 )
202230 .arg (bgFinalColor.name ())
203- .arg (border .name ())
231+ .arg (bgFinalColor .name ())
204232 // DefaultFrameWidth returns the size of the external margin + border width. We know our border is 1px, so we subtract this from the frame normal QStyle FrameWidth to get our margin
205233 .arg (q->style ()->pixelMetric (QStyle::PM_DefaultFrameWidth, nullptr , q) - 1 )
206- .arg (textColor.name ())
207234 );
235+
236+ applyNMCStylesheets ();
208237}
209238
210239void KMessageWidgetPrivate::updateLayout ()
@@ -258,6 +287,36 @@ int KMessageWidgetPrivate::bestContentHeight() const
258287 return height;
259288}
260289
290+ void KMessageWidgetPrivate::applyNMCStylesheets () const
291+ {
292+ // Set button color and size
293+ if (!buttons.empty ()) {
294+ const QString stylesheet = QStringLiteral (
295+ " QToolButton{width: 180px; height: 32px; border-radius: 4px; font-size: %1px; color: %2; background-color: %3;} "
296+ " QToolButton:hover { background-color: %4;}"
297+ );
298+
299+ switch (messageType) {
300+ case KMessageWidget::Positive:
301+ for (QToolButton *button : buttons) {
302+ button->setStyleSheet (stylesheet.arg (" 13" , " white" , " #00b367" , " #00a461" ));
303+ }
304+ break ;
305+ case KMessageWidget::Information:
306+ for (QToolButton *button : buttons) {
307+ button->setStyleSheet (stylesheet.arg (" 13" , " white" , " #216bff" , " #0819bd" ));
308+ }
309+ break ;
310+ case KMessageWidget::Warning:
311+ // Optional: Add styling here if needed
312+ break ;
313+ case KMessageWidget::Error:
314+ // Optional: Add styling here if needed
315+ break ;
316+ }
317+ }
318+ }
319+
261320// ---------------------------------------------------------------------
262321// KMessageWidget
263322// ---------------------------------------------------------------------
@@ -383,7 +442,8 @@ bool KMessageWidget::isCloseButtonVisible() const
383442
384443void KMessageWidget::setCloseButtonVisible (bool show)
385444{
386- d->closeButton ->setVisible (show);
445+ Q_UNUSED (show)
446+ d->closeButton ->setVisible (false );
387447 updateGeometry ();
388448}
389449
0 commit comments