diff options
-rw-r--r-- | kxkb/CMakeLists.txt | 2 | ||||
-rw-r--r-- | kxkb/kxkb.cpp | 45 | ||||
-rw-r--r-- | kxkb/kxkb.h | 7 |
3 files changed, 49 insertions, 5 deletions
diff --git a/kxkb/CMakeLists.txt b/kxkb/CMakeLists.txt index cb0d4b9db..83ca72be7 100644 --- a/kxkb/CMakeLists.txt +++ b/kxkb/CMakeLists.txt @@ -67,5 +67,5 @@ tde_add_tdeinit_executable( kxkb AUTOMOC extension.cpp x11helper.cpp rules.cpp kxkbconfig.cpp pixmap.cpp layoutmap.cpp kxkb.cpp kxkbtraywindow.cpp kxkb.skel - LINK tdeui-shared ${XKBFILE_LIBRARIES} + LINK tdeui-shared ${XKBFILE_LIBRARIES} ${TDEHW_LIBRARIES} ) 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) { diff --git a/kxkb/kxkb.h b/kxkb/kxkb.h index 143b68301..5708efd48 100644 --- a/kxkb/kxkb.h +++ b/kxkb/kxkb.h @@ -32,6 +32,7 @@ DESCRIPTION #include <tqptrqueue.h> #include <kuniqueapplication.h> +#include <tdegenericdevice.h> #include "kxkbtraywindow.h" #include "kxkbconfig.h" @@ -78,6 +79,12 @@ protected slots: void showLayoutNotification(); void showErrorNotification(TQString layout); + void hardwareAdded(TDEGenericDevice *dev); + void hardwareRemoved(TDEGenericDevice *dev); + void hardwareUpdated(TDEGenericDevice *dev); + + void applySettings(); + protected: // Read settings, and apply them. bool settingsRead(); |