From ccefad283941cbf93058bdcdb91c59231417394f Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Wed, 23 Aug 2023 02:18:39 +0200 Subject: [PATCH] Port to new KNotifications action API --- src/Vt102Emulation.cpp | 4 ++-- src/session/Session.cpp | 8 ++++---- src/session/SessionController.cpp | 8 ++++---- src/terminalDisplay/TerminalBell.cpp | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp index d2a37fba5..41a93f3b0 100644 --- a/src/Vt102Emulation.cpp +++ b/src/Vt102Emulation.cpp @@ -1143,8 +1143,8 @@ void Vt102Emulation::processSessionAttributeRequest(const int tokenSize, const u notification = KNotification::event(hasFocus ? QStringLiteral("ProcessNotification") : QStringLiteral("ProcessNotificationHidden"), params[1]); } - notification->setDefaultAction(i18n("Show session")); - connect(notification, &KNotification::defaultActivated, this, [this, notification]() { + auto action = notification->addDefaultAction(i18n("Show session")); + connect(action, &KNotificationAction::activated, this, [this, notification]() { _currentScreen->currentTerminalDisplay()->notificationClicked(notification->xdgActivationToken()); }); diff --git a/src/session/Session.cpp b/src/session/Session.cpp index 5a3bd7712..c9deffcfb 100644 --- a/src/session/Session.cpp +++ b/src/session/Session.cpp @@ -724,8 +724,8 @@ void Session::silenceTimerDone() notification->setWindow(view->windowHandle()); notification->setText(i18n("Silence in '%1' (Session '%2')", _displayTitle, _nameTitle)); - notification->setDefaultAction(i18n("Show session")); - connect(notification, &KNotification::defaultActivated, this, [view, notification]() { + auto action = notification->addDefaultAction(i18n("Show session")); + connect(action, &KNotificationAction::activated, this, [view, notification]() { view->notificationClicked(notification->xdgActivationToken()); }); if (view->sessionController()->isMonitorOnce()) { @@ -1925,8 +1925,8 @@ void Session::handleActivity() new KNotification(hasFocus() ? QStringLiteral("Activity") : QStringLiteral("ActivityHidden"), KNotification::CloseWhenWindowActivated); notification->setWindow(view->windowHandle()); notification->setText(i18n("Activity in '%1' (Session '%2')", _displayTitle, _nameTitle)); - notification->setDefaultAction(i18n("Show session")); - connect(notification, &KNotification::defaultActivated, this, [view, notification]() { + auto action = notification->addDefaultAction(i18n("Show session")); + connect(action, &KNotificationAction::activated, this, [view, notification]() { view->notificationClicked(notification->xdgActivationToken()); }); notification->sendEvent(); diff --git a/src/session/SessionController.cpp b/src/session/SessionController.cpp index 6c32578d9..33ad4c5b8 100644 --- a/src/session/SessionController.cpp +++ b/src/session/SessionController.cpp @@ -351,8 +351,8 @@ void SessionController::snapshot() KNotification::CloseWhenWindowActivated); notification->setWindow(view()->windowHandle()); notification->setText(i18n("The process '%1' has finished running in session '%2'", _previousForegroundProcessName, session()->nameTitle())); - notification->setDefaultAction(i18n("Show session")); - connect(notification, &KNotification::defaultActivated, this, [this, notification]() { + auto action = notification->addDefaultAction(i18n("Show session")); + connect(action, &KNotificationAction::activated, this, [this, notification] { view()->notificationClicked(notification->xdgActivationToken()); }); notification->sendEvent(); @@ -1798,8 +1798,8 @@ void SessionController::notifyPrompt() notification->setWindow(view()->windowHandle()); notification->setText(i18n("The shell prompt is displayed in session '%1'", session()->nameTitle())); - notification->setDefaultAction(i18n("Show session")); - connect(notification, &KNotification::defaultActivated, this, [this, notification]() { + auto action = notification->addDefaultAction(i18n("Show session")); + connect(action, &KNotificationAction::activated, this, [this, notification] { view()->notificationClicked(notification->xdgActivationToken()); }); notification->sendEvent(); diff --git a/src/terminalDisplay/TerminalBell.cpp b/src/terminalDisplay/TerminalBell.cpp index 3960e3c9c..71a18ed59 100644 --- a/src/terminalDisplay/TerminalBell.cpp +++ b/src/terminalDisplay/TerminalBell.cpp @@ -40,8 +40,8 @@ void TerminalBell::bell(TerminalDisplay *terminalDisplay, const QString &message // that use this code via KPart rely on these names for notifications. KNotification *notification = KNotification::event(terminalHasFocus ? QStringLiteral("BellVisible") : QStringLiteral("BellInvisible"), message, QPixmap()); - notification->setDefaultAction(i18n("Show session")); - connect(notification, &KNotification::defaultActivated, this, [notification, terminalDisplay]() { + auto action = notification->addDefaultAction(i18n("Show session")); + connect(action, &KNotificationAction::activated, this, [notification, terminalDisplay]() { terminalDisplay->notificationClicked(notification->xdgActivationToken()); }); } break;