summaryrefslogtreecommitdiffstats
path: root/kxkb/kxkb.cpp
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2023-12-21 19:35:28 +0200
committerMavridis Philippe <mavridisf@gmail.com>2023-12-25 16:38:10 +0200
commit7c724a49212a9ffdf42381d99648f15457867787 (patch)
treedcd3a0f16c58858979650c6d9dc7a5ec42849e1a /kxkb/kxkb.cpp
parent9647d4c7ff182c1fadffb9c6218bc00132fe682e (diff)
downloadtdebase-7c724a49212a9ffdf42381d99648f15457867787.tar.gz
tdebase-7c724a49212a9ffdf42381d99648f15457867787.zip
KXkb: add keyboard layout notification
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'kxkb/kxkb.cpp')
-rw-r--r--kxkb/kxkb.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/kxkb/kxkb.cpp b/kxkb/kxkb.cpp
index 1ecbd2470..f38263645 100644
--- a/kxkb/kxkb.cpp
+++ b/kxkb/kxkb.cpp
@@ -47,6 +47,9 @@ DESCRIPTION
#include <tdepopupmenu.h>
#include <kdebug.h>
#include <tdeconfig.h>
+#include <knotifyclient.h>
+#include <dcopclient.h>
+#include <dcopref.h>
#include "x11helper.h"
#include "kxkb.h"
@@ -205,9 +208,10 @@ bool KXKBApp::setLayout(const LayoutUnit& layoutUnit)
bool res = m_extension->setGroup(group);
if (res) {
m_currentLayout = layoutUnit;
+ maybeShowLayoutNotification();
}
- if (m_tray) {
+ if (m_tray) {
if (res) {
m_tray->setCurrentLayout(layoutUnit);
} else {
@@ -281,6 +285,44 @@ void KXKBApp::slotGroupChanged(uint group)
}
m_currentLayout = kxkbConfig.m_layouts[group];
m_tray->setCurrentLayout(m_currentLayout);
+ maybeShowLayoutNotification();
+}
+
+void KXKBApp::maybeShowLayoutNotification() {
+ if (!kxkbConfig.m_enableNotify) return;
+
+ TQString layoutName(m_rules->getLayoutName(m_currentLayout));
+ bool useKMilo = kxkbConfig.m_notifyUseKMilo;
+ bool notificationSent = false;
+
+ // Query KDED whether KMiloD is loaded
+ if (useKMilo) {
+ QCStringList modules;
+ TQCString replyType;
+ TQByteArray replyData;
+ if (kapp->dcopClient()->call("kded", "kded", "loadedModules()",
+ TQByteArray(), replyType, replyData))
+ {
+ if (replyType == "QCStringList") {
+ TQDataStream reply(replyData, IO_ReadOnly);
+ reply >> modules;
+
+ if (!modules.contains("kmilod")) {
+ useKMilo = false;
+ }
+ }
+ }
+ }
+
+ if (useKMilo) {
+ DCOPRef kmilo("kded", "kmilod");
+ if (kmilo.send("displayText(TQString,TQPixmap)", layoutName, kapp->miniIcon()))
+ notificationSent = true;
+ }
+
+ if (!notificationSent) {
+ KNotifyClient::event(m_tray->winId(), "LayoutChange", layoutName);
+ }
}
// TODO: we also have to handle deleted windows