aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Aleksei Bavshin2023-12-26 01:44:41 -0800
committerGravatar GitHub2023-12-26 10:44:41 +0100
commit2c592667f66565c65959e262d8775c3a14ccfdfd (patch)
treed108cd1e002b971e3e3d1b27f607c88c8c4d62fd /src
parentFix build with KDE Frameworks 6 (#2585) (diff)
downloadKVIrc-2c592667f66565c65959e262d8775c3a14ccfdfd.tar.gz
KVIrc-2c592667f66565c65959e262d8775c3a14ccfdfd.tar.bz2
KVIrc-2c592667f66565c65959e262d8775c3a14ccfdfd.zip
Activation support for KDE (KF6) notifications (#2586)
Use xdg-activation tokens when available. This should work with KF6 and `xcb` and `wayland` platform backends on Plasma 6.
Diffstat (limited to 'src')
-rw-r--r--src/kvirc/kernel/KviApplication.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/kvirc/kernel/KviApplication.cpp b/src/kvirc/kernel/KviApplication.cpp
index 3811dc441..1c6d22fe0 100644
--- a/src/kvirc/kernel/KviApplication.cpp
+++ b/src/kvirc/kernel/KviApplication.cpp
@@ -126,6 +126,10 @@
#ifdef COMPILE_KDE_SUPPORT
#include <QStandardPaths>
#include <KNotification>
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+#include <KStartupInfo>
+#include <KWindowSystem>
+#endif
#endif
#ifdef COMPILE_QX11INFO_SUPPORT
@@ -811,18 +815,38 @@ void KviApplication::notifierMessage(KviWindow * pWnd, int iIconId, const QStrin
#else
KNotificationAction *action = nullptr;
+ auto activate = [this, pNotify] () {
+ if (!g_pMainWindow)
+ return;
+
+ QString szToken = pNotify->xdgActivationToken();
+ if(szToken.isEmpty())
+ return showParentFrame();
+
+ QWindow * pWindow = g_pMainWindow->windowHandle();
+ if(KWindowSystem::isPlatformX11())
+ {
+ KStartupInfo::setNewStartupId(pWindow, szToken.toUtf8());
+ }
+ else if(KWindowSystem::isPlatformWayland())
+ {
+ KWindowSystem::setCurrentXdgActivationToken(szToken);
+ }
+ KWindowSystem::activateWindow(pWindow);
+ };
+
action = pNotify->addDefaultAction(__tr2qs("View"));
- connect(action, SIGNAL(activated()), this, SLOT(showParentFrame()));
+ connect(action, &KNotificationAction::activated, this, activate);
action = pNotify->addAction(__tr2qs("View"));
- connect(action, SIGNAL(activated()), this, SLOT(showParentFrame()));
+ connect(action, &KNotificationAction::activated, this, activate);
action = pNotify->addAction(__tr2qs("Ignore"));
connect(action, SIGNAL(activated()), pNotify, SLOT(close()));
pNotify->setFlags(KNotification::CloseWhenWindowActivated|KNotification::Persistent);
pNotify->setWindow(g_pMainWindow->windowHandle());
-#endif
+#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect(pNotify, SIGNAL(ignored()), pNotify, SLOT(close()));