From bc7cc4032801642c5ce675c9a78db949eb8982a7 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Wed, 13 Nov 2024 14:08:55 +0200 Subject: Kxkb: Add delay to applying settings after keyboard hardware somehow changes Signed-off-by: Mavridis Philippe --- kxkb/kxkb.cpp | 29 ++++++----------------------- kxkb/kxkb.h | 4 +--- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/kxkb/kxkb.cpp b/kxkb/kxkb.cpp index 320b55f40..01df09add 100644 --- a/kxkb/kxkb.cpp +++ b/kxkb/kxkb.cpp @@ -31,6 +31,7 @@ DESCRIPTION #include #include #include +#include #include #include @@ -87,9 +88,9 @@ KXKBApp::KXKBApp(bool allowStyles, bool GUIenabled) 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*))); + 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() @@ -190,29 +191,11 @@ void KXKBApp::initTray() m_tray->show(); } -void KXKBApp::hardwareAdded(TDEGenericDevice *dev) +void KXKBApp::hardwareChanged(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(); + TQTimer::singleShot(500, this, TQ_SLOT(applySettings())); } } diff --git a/kxkb/kxkb.h b/kxkb/kxkb.h index 5708efd48..fe07f049e 100644 --- a/kxkb/kxkb.h +++ b/kxkb/kxkb.h @@ -79,9 +79,7 @@ protected slots: void showLayoutNotification(); void showErrorNotification(TQString layout); - void hardwareAdded(TDEGenericDevice *dev); - void hardwareRemoved(TDEGenericDevice *dev); - void hardwareUpdated(TDEGenericDevice *dev); + void hardwareChanged(TDEGenericDevice *dev); void applySettings(); -- cgit v1.2.1