summaryrefslogtreecommitdiffstats
path: root/kxkb/kxkb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kxkb/kxkb.cpp')
-rw-r--r--kxkb/kxkb.cpp45
1 files changed, 41 insertions, 4 deletions
diff --git a/kxkb/kxkb.cpp b/kxkb/kxkb.cpp
index 3d04824ad..92b12472b 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)
{