summaryrefslogtreecommitdiffstats
path: root/kcontrol/hwmanager/hwmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kcontrol/hwmanager/hwmanager.cpp')
-rw-r--r--kcontrol/hwmanager/hwmanager.cpp67
1 files changed, 33 insertions, 34 deletions
diff --git a/kcontrol/hwmanager/hwmanager.cpp b/kcontrol/hwmanager/hwmanager.cpp
index 3258453d0..97251cb89 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>
@@ -71,10 +72,13 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis
systemconfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdehw/hwmanagerrc" ));
TDEAboutData *about =
- new TDEAboutData(I18N_NOOP("kcmhwmanager"), I18N_NOOP("TDE Device Manager\n\nCan be used to get all kind of informations about your devices on your system, shows which drivers are used by them and allows to change device settings."),
- 0, 0, TDEAboutData::License_GPL,
- I18N_NOOP("(c) 2012 Timothy Pearson\n(c) 2019 The Trinity Desktop Project"));
-
+ new TDEAboutData(I18N_NOOP("kcmhwmanager"), I18N_NOOP("TDE Device Manager"), 0,
+ I18N_NOOP("Device Manager\n\n"
+ "Can be used to get all kind of informations about your devices on your system,\n"
+ "shows which drivers are used by them and allows to change device settings."),
+ TDEAboutData::License_GPL,
+ I18N_NOOP("(c) 2012 Timothy Pearson\n"
+ "(c) 2019 The Trinity Desktop Project"));
about->addAuthor("Timothy Pearson", 0, "kb9vqf@pearsoncomputing.net");
setAboutData( about );
@@ -83,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();
@@ -103,6 +108,7 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis
TDEHWManager::~TDEHWManager()
{
+ TDEGlobal::hardwareDevices()->setTriggerlessHardwareUpdatesEnabled(false);
delete config;
delete systemconfig;
}
@@ -127,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
@@ -149,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);
@@ -165,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);
@@ -194,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);
@@ -210,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);