diff options
author | Mavridis Philippe <[email protected]> | 2024-11-13 00:07:36 +0200 |
---|---|---|
committer | Mavridis Philippe <[email protected]> | 2025-01-12 13:28:25 +0200 |
commit | cff4d8a2d93be2bff2c3de617008f1c0c28cd59a (patch) | |
tree | eba2f8863a78fe7eb124ee5b1ae279f80776ce9d /kxkb/kxkb.cpp | |
parent | 883676477b7b1368c14f9bcd49d135407cc6b456 (diff) | |
download | tdebase-cff4d8a2d93be2bff2c3de617008f1c0c28cd59a.tar.gz tdebase-cff4d8a2d93be2bff2c3de617008f1c0c28cd59a.zip |
Kxkb: reapply Xkb settings when a keyboard device changes state
Signed-off-by: Mavridis Philippe <[email protected]>
Diffstat (limited to 'kxkb/kxkb.cpp')
-rw-r--r-- | kxkb/kxkb.cpp | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/kxkb/kxkb.cpp b/kxkb/kxkb.cpp index a6435eb58..8d0fbc517 100644 --- a/kxkb/kxkb.cpp +++ b/kxkb/kxkb.cpp @@ -34,6 +34,7 @@ DESCRIPTION #include <tdeaboutdata.h> #include <tdecmdlineargs.h> +#include <tdehardwaredevices.h> #include <tdeglobal.h> #include <kglobalaccel.h> #include <tdelocale.h> @@ -84,6 +85,11 @@ KXKBApp::KXKBApp(bool allowStyles, bool GUIenabled) connect( this, TQ_SIGNAL(settingsChanged(int)), TQ_SLOT(slotSettingsChanged(int)) ); addKipcEventMask( KIPC::SettingsChanged ); + + TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); + connect(hwdevices, TQ_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQ_SLOT(hardwareAdded(TDEGenericDevice*))); + connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(hardwareRemoved(TDEGenericDevice*))); + connect(hwdevices, TQ_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQ_SLOT(hardwareUpdated(TDEGenericDevice*))); } KXKBApp::~KXKBApp() @@ -107,10 +113,7 @@ int KXKBApp::newInstance() bool KXKBApp::settingsRead() { kxkbConfig.load(KxkbConfig::LOAD_ALL); - XkbOptions options = kxkbConfig.getKXkbOptions(); - if (!m_extension->setXkbOptions(options)) { - kdWarning() << "Setting XKB options failed!" << endl; - } + applySettings(); if ( kxkbConfig.m_useKxkb == false ) { kapp->quit(); @@ -165,6 +168,14 @@ bool KXKBApp::settingsRead() return true; } +void KXKBApp::applySettings() +{ + XkbOptions options = kxkbConfig.getKXkbOptions(); + if (!m_extension->setXkbOptions(options)) { + kdWarning() << "Setting XKB options failed!" << endl; + } +} + void KXKBApp::initTray() { if (!m_tray) @@ -179,6 +190,32 @@ void KXKBApp::initTray() m_tray->show(); } +void KXKBApp::hardwareAdded(TDEGenericDevice *dev) +{ + if (dev->type() == TDEGenericDeviceType::Keyboard) + { + kdDebug() << "keyboard attached: " << dev->friendlyName() << endl; + applySettings(); + } +} +void KXKBApp::hardwareRemoved(TDEGenericDevice *dev) +{ + if (dev->type() == TDEGenericDeviceType::Keyboard) + { + kdDebug() << "keyboard removed: " << dev->friendlyName() << endl; + applySettings(); + } +} + +void KXKBApp::hardwareUpdated(TDEGenericDevice *dev) +{ + if (dev->type() == TDEGenericDeviceType::Keyboard) + { + kdDebug() << "keyboard updated: " << dev->friendlyName() << endl; + applySettings(); + } +} + // kdcop bool KXKBApp::setLayout(const TQString& layoutPair) { |