diff options
-rw-r--r-- | kxkb/CMakeLists.txt | 2 | ||||
-rw-r--r-- | kxkb/kxkb.cpp | 28 | ||||
-rw-r--r-- | kxkb/kxkb.h | 5 |
3 files changed, 30 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 9d3af0dec..9c30ac440 100644 --- a/kxkb/kxkb.cpp +++ b/kxkb/kxkb.cpp @@ -31,9 +31,11 @@ DESCRIPTION #include <tqfile.h> #include <tqstringlist.h> #include <tqimage.h> +#include <tqtimer.h> #include <tdeaboutdata.h> #include <tdecmdlineargs.h> +#include <tdehardwaredevices.h> #include <tdeglobal.h> #include <kglobalaccel.h> #include <tdelocale.h> @@ -84,6 +86,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(hardwareChanged(TDEGenericDevice*))); + connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(hardwareChanged(TDEGenericDevice*))); + connect(hwdevices, TQ_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQ_SLOT(hardwareChanged(TDEGenericDevice*))); } KXKBApp::~KXKBApp() @@ -107,10 +114,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 +169,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 +191,14 @@ void KXKBApp::initTray() m_tray->show(); } +void KXKBApp::hardwareChanged(TDEGenericDevice *dev) +{ + if (dev->type() == TDEGenericDeviceType::Keyboard) + { + TQTimer::singleShot(500, this, TQ_SLOT(applySettings())); + } +} + // kdcop bool KXKBApp::setLayout(const TQString& layoutPair) { diff --git a/kxkb/kxkb.h b/kxkb/kxkb.h index 5de482b9d..441844583 100644 --- a/kxkb/kxkb.h +++ b/kxkb/kxkb.h @@ -32,6 +32,7 @@ DESCRIPTION #include <tqptrqueue.h> #include <tdeuniqueapplication.h> +#include <tdegenericdevice.h> #include "kxkbtraywindow.h" #include "kxkbconfig.h" @@ -78,6 +79,10 @@ protected slots: void showLayoutNotification(); void showErrorNotification(TQString layout); + void hardwareChanged(TDEGenericDevice *dev); + + void applySettings(); + protected: // Read settings, and apply them. bool settingsRead(); |