diff options
Diffstat (limited to 'kcontrol/hwmanager/hwmanager.cpp')
-rw-r--r-- | kcontrol/hwmanager/hwmanager.cpp | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/kcontrol/hwmanager/hwmanager.cpp b/kcontrol/hwmanager/hwmanager.cpp index ecfed649a..662844ec3 100644 --- a/kcontrol/hwmanager/hwmanager.cpp +++ b/kcontrol/hwmanager/hwmanager.cpp @@ -23,6 +23,7 @@ #include <tqlayout.h> #include <tqlineedit.h> #include <tqpushbutton.h> +#include <tqtimer.h> #include <dcopclient.h> @@ -43,7 +44,7 @@ #include <unistd.h> #include <kpassdlg.h> -#include <ksimpleconfig.h> +#include <tdesimpleconfig.h> #include <string> #include <stdio.h> #include <tqstring.h> @@ -58,8 +59,8 @@ using namespace std; typedef KGenericFactory<TDEHWManager, TQWidget> TDEHWManagerFactory; K_EXPORT_COMPONENT_FACTORY( kcm_hwmanager, TDEHWManagerFactory("kcmhwmanager") ) -KSimpleConfig *config; -KSimpleConfig *systemconfig; +TDESimpleConfig *config; +TDESimpleConfig *systemconfig; /**** TDEHWManager ****/ @@ -67,8 +68,8 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis : TDECModule(TDEHWManagerFactory::instance(), parent, name) { TQVBoxLayout *layout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint()); - config = new KSimpleConfig( TQString::fromLatin1( "hwmanagerrc" )); - systemconfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdehw/hwmanagerrc" )); + config = new TDESimpleConfig( TQString::fromLatin1( "hwmanagerrc" )); + systemconfig = new TDESimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdehw/hwmanagerrc" )); TDEAboutData *about = new TDEAboutData(I18N_NOOP("kcmhwmanager"), I18N_NOOP("TDE Device Manager"), 0, @@ -86,18 +87,19 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis base->deviceFilter->setListView(base->deviceTree); + deviceUpdateScheduled = false; + setRootOnlyMsg(i18n("<b>Device settings are system wide, and therefore require administrator access</b><br>To alter the system's device settings, click on the \"Administrator Mode\" button below.")); setUseRootOnlyMsg(true); TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); hwdevices->setTriggerlessHardwareUpdatesEnabled(true); - connect(base->showByConnection, TQT_SIGNAL(clicked()), TQT_SLOT(changed())); - connect(base->showByConnection, TQT_SIGNAL(clicked()), TQT_SLOT(populateTreeView())); + connect(base->showByConnection, TQ_SIGNAL(clicked()), TQ_SLOT(changed())); + connect(base->showByConnection, TQ_SIGNAL(clicked()), TQ_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, TQ_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQ_SLOT(scheduleDeviceUpdate())); + connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(scheduleDeviceUpdate())); load(); @@ -106,6 +108,7 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis TDEHWManager::~TDEHWManager() { + TDEGlobal::hardwareDevices()->setTriggerlessHardwareUpdatesEnabled(false); delete config; delete systemconfig; } @@ -130,8 +133,19 @@ void TDEHWManager::defaults() load( true ); } +void TDEHWManager::scheduleDeviceUpdate() +{ + if (!deviceUpdateScheduled) + { + deviceUpdateScheduled = true; + TQTimer::singleShot(1000, this, TQ_SLOT(populateTreeView())); + } +} + void TDEHWManager::populateTreeView() { + deviceUpdateScheduled = false; + bool show_by_connection = base->showByConnection->isChecked(); // Figure out which device, if any, was selected @@ -152,11 +166,11 @@ void TDEHWManager::populateTreeView() for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { if (hwdevice->type() == TDEGenericDeviceType::CryptographicCard) { TDECryptographicCardDevice* cdevice = static_cast<TDECryptographicCardDevice*>(hwdevice); - connect(cdevice, SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*))); + connect(cdevice, TQ_SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*))); cdevice->enableCardMonitoring(true); cdevice->enablePINEntryCallbacks(true); } - DeviceIconItem* item = new DeviceIconItem(base->deviceTree, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); + DeviceIconItem* item = new DeviceIconItem(base->deviceTree, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice->uniqueID()); if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { base->deviceTree->ensureItemVisible(item); base->deviceTree->setSelected(item, true); @@ -168,17 +182,17 @@ void TDEHWManager::populateTreeView() TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); for (int i=0;i<=TDEGenericDeviceType::Last;i++) { if (i != TDEGenericDeviceType::Root) { - DeviceIconItem* rootitem = new DeviceIconItem(base->deviceTree, hwdevices->getFriendlyDeviceTypeStringFromType((TDEGenericDeviceType::TDEGenericDeviceType)i), hwdevices->getDeviceTypeIconFromType((TDEGenericDeviceType::TDEGenericDeviceType)i, base->deviceTree->iconSize()), 0); + DeviceIconItem* rootitem = new DeviceIconItem(base->deviceTree, hwdevices->getFriendlyDeviceTypeStringFromType((TDEGenericDeviceType::TDEGenericDeviceType)i), hwdevices->getDeviceTypeIconFromType((TDEGenericDeviceType::TDEGenericDeviceType)i, base->deviceTree->iconSize()), TQString::null); TDEGenericDevice *hwdevice; TDEGenericHardwareList hwlist = hwdevices->listByDeviceClass((TDEGenericDeviceType::TDEGenericDeviceType)i); for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { if (hwdevice->type() == TDEGenericDeviceType::CryptographicCard) { TDECryptographicCardDevice* cdevice = static_cast<TDECryptographicCardDevice*>(hwdevice); - connect(cdevice, SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*))); + connect(cdevice, TQ_SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*))); cdevice->enableCardMonitoring(true); cdevice->enablePINEntryCallbacks(true); } - DeviceIconItem* item = new DeviceIconItem(rootitem, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); + DeviceIconItem* item = new DeviceIconItem(rootitem, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice->uniqueID()); if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { base->deviceTree->ensureItemVisible(item); base->deviceTree->setSelected(item, true); @@ -197,12 +211,12 @@ void TDEHWManager::populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_con for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { if (hwdevice->type() == TDEGenericDeviceType::CryptographicCard) { TDECryptographicCardDevice* cdevice = static_cast<TDECryptographicCardDevice*>(hwdevice); - connect(cdevice, SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*))); + connect(cdevice, TQ_SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*))); cdevice->enableCardMonitoring(true); cdevice->enablePINEntryCallbacks(true); } if (hwdevice->parentDevice() == parent->device()) { - DeviceIconItem* item = new DeviceIconItem(parent, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); + DeviceIconItem* item = new DeviceIconItem(parent, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice->uniqueID()); if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { base->deviceTree->ensureItemVisible(item); base->deviceTree->setSelected(item, true); @@ -213,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<DeviceIconItem*>(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); |