From 2ffa44200eba513d4e3332917511b40250b416a7 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 17 Feb 2023 11:30:31 +0900 Subject: hwmanager: avoid unnecessary update of device names on status change. This relates to issue TDE/tde#110. Signed-off-by: Michele Calgaro --- kcontrol/hwmanager/hwmanager.cpp | 36 +++++++++++++++--------------------- kcontrol/hwmanager/hwmanager.h | 6 +++--- 2 files changed, 18 insertions(+), 24 deletions(-) (limited to 'kcontrol/hwmanager') diff --git a/kcontrol/hwmanager/hwmanager.cpp b/kcontrol/hwmanager/hwmanager.cpp index 265901003..f5b0206c3 100644 --- a/kcontrol/hwmanager/hwmanager.cpp +++ b/kcontrol/hwmanager/hwmanager.cpp @@ -87,6 +87,8 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis base->deviceFilter->setListView(base->deviceTree); + deviceUpdateScheduled = false; + setRootOnlyMsg(i18n("Device settings are system wide, and therefore require administrator access
To alter the system's device settings, click on the \"Administrator Mode\" button below.")); setUseRootOnlyMsg(true); @@ -96,9 +98,8 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis connect(base->showByConnection, TQT_SIGNAL(clicked()), TQT_SLOT(changed())); connect(base->showByConnection, TQT_SIGNAL(clicked()), TQT_SLOT(populateTreeView())); - connect(hwdevices, TQT_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQT_SLOT(populateTreeView())); - connect(hwdevices, TQT_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQT_SLOT(populateTreeView())); - connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(deviceChanged(TDEGenericDevice*))); + connect(hwdevices, TQT_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQT_SLOT(scheduleDeviceUpdate())); + connect(hwdevices, TQT_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQT_SLOT(scheduleDeviceUpdate())); load(); @@ -132,8 +133,19 @@ void TDEHWManager::defaults() load( true ); } +void TDEHWManager::scheduleDeviceUpdate() +{ + if (!deviceUpdateScheduled) + { + deviceUpdateScheduled = true; + TQTimer::singleShot(1000, this, TQT_SLOT(populateTreeView())); + } +} + void TDEHWManager::populateTreeView() { + deviceUpdateScheduled = false; + bool show_by_connection = base->showByConnection->isChecked(); // Figure out which device, if any, was selected @@ -215,24 +227,6 @@ void TDEHWManager::populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_con } } -void TDEHWManager::deviceChanged(TDEGenericDevice* device) { - TQListViewItemIterator it(base->deviceTree); - while (it.current()) { - DeviceIconItem* item = dynamic_cast(it.current()); - if (item) { - TDEGenericDevice* candidate = item->device(); - if (candidate) { - if (candidate->systemPath() == device->systemPath()) { - if (item->text(0) != device->detailedFriendlyName()) { - item->setText(0, device->detailedFriendlyName()); - } - } - } - } - ++it; - } -} - void TDEHWManager::cryptographicCardPinRequested(TQString prompt, TDECryptographicCardDevice* cdevice) { TQString password; int result = KPasswordDialog::getPassword(password, prompt); diff --git a/kcontrol/hwmanager/hwmanager.h b/kcontrol/hwmanager/hwmanager.h index abc05fa54..6d8105d07 100644 --- a/kcontrol/hwmanager/hwmanager.h +++ b/kcontrol/hwmanager/hwmanager.h @@ -58,15 +58,15 @@ public: k_dcop: private slots: + void cryptographicCardPinRequested(TQString prompt, TDECryptographicCardDevice* cdevice); void populateTreeView(); void populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_connection, TQString selected_syspath); - void deviceChanged(TDEGenericDevice*); - void cryptographicCardPinRequested(TQString prompt, TDECryptographicCardDevice* cdevice); + void scheduleDeviceUpdate(); private: TDEHWManagerBase *base; - TDEConfig *config; + bool deviceUpdateScheduled; }; #endif -- cgit v1.2.1