|
|
@ -22,12 +22,16 @@
|
|
|
|
#include <tdelocale.h>
|
|
|
|
#include <tdelocale.h>
|
|
|
|
#include <kdebug.h>
|
|
|
|
#include <kdebug.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __TDE_HAVE_TDEHWLIB
|
|
|
|
|
|
|
|
#include <tdehardwaredevices.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
BatterySrc::BatterySrc(TQWidget* inParent, TQString inUDI):
|
|
|
|
BatterySrc::BatterySrc(TQWidget* inParent, TQString inUDI):
|
|
|
|
LabelSource(inParent),
|
|
|
|
LabelSource(inParent),
|
|
|
|
mTrigger(this, 5000),
|
|
|
|
mTrigger(this, 5000),
|
|
|
|
mUDI(inUDI),
|
|
|
|
mUDI(inUDI),
|
|
|
|
mHardwareDevices(NULL){
|
|
|
|
mHardwareDevices(NULL){
|
|
|
|
|
|
|
|
#ifdef __TDE_HAVE_TDEHWLIB
|
|
|
|
mHardwareDevices = TDEGlobal::hardwareDevices();
|
|
|
|
mHardwareDevices = TDEGlobal::hardwareDevices();
|
|
|
|
TDEGenericDevice* hwdevice = mHardwareDevices->findByUniqueID(inUDI);
|
|
|
|
TDEGenericDevice* hwdevice = mHardwareDevices->findByUniqueID(inUDI);
|
|
|
|
|
|
|
|
|
|
|
@ -35,6 +39,9 @@ BatterySrc::BatterySrc(TQWidget* inParent, TQString inUDI):
|
|
|
|
TDEBatteryDevice* bdevice = static_cast<TDEBatteryDevice*>(hwdevice);
|
|
|
|
TDEBatteryDevice* bdevice = static_cast<TDEBatteryDevice*>(hwdevice);
|
|
|
|
mID = bdevice->friendlyName();
|
|
|
|
mID = bdevice->friendlyName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
mID = TQString::null;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
mName = mID;
|
|
|
|
mName = mID;
|
|
|
|
mDescription = i18n("This source displays the current state of charge of your battery.");
|
|
|
|
mDescription = i18n("This source displays the current state of charge of your battery.");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -45,7 +52,7 @@ BatterySrc::~BatterySrc(){
|
|
|
|
|
|
|
|
|
|
|
|
std::list<Source*>BatterySrc::createInstances(TQWidget* inParent){
|
|
|
|
std::list<Source*>BatterySrc::createInstances(TQWidget* inParent){
|
|
|
|
std::list<Source*> list;
|
|
|
|
std::list<Source*> list;
|
|
|
|
|
|
|
|
#ifdef __TDE_HAVE_TDEHWLIB
|
|
|
|
TDEHardwareDevices* hardwareDevices = TDEGlobal::hardwareDevices();
|
|
|
|
TDEHardwareDevices* hardwareDevices = TDEGlobal::hardwareDevices();
|
|
|
|
TDEGenericHardwareList hwlist = hardwareDevices->listAllPhysicalDevices();
|
|
|
|
TDEGenericHardwareList hwlist = hardwareDevices->listAllPhysicalDevices();
|
|
|
|
TDEGenericDevice *hwdevice;
|
|
|
|
TDEGenericDevice *hwdevice;
|
|
|
@ -54,12 +61,13 @@ std::list<Source*>BatterySrc::createInstances(TQWidget* inParent){
|
|
|
|
list.push_back(new BatterySrc(inParent, hwdevice->uniqueID()));
|
|
|
|
list.push_back(new BatterySrc(inParent, hwdevice->uniqueID()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString BatterySrc::fetchValue() {
|
|
|
|
TQString BatterySrc::fetchValue() {
|
|
|
|
TQString s = "n/a";
|
|
|
|
TQString s = "n/a";
|
|
|
|
|
|
|
|
#ifdef __TDE_HAVE_TDEHWLIB
|
|
|
|
if (mHardwareDevices != NULL) {
|
|
|
|
if (mHardwareDevices != NULL) {
|
|
|
|
TDEGenericDevice* hwdevice = mHardwareDevices->findByUniqueID(mUDI);
|
|
|
|
TDEGenericDevice* hwdevice = mHardwareDevices->findByUniqueID(mUDI);
|
|
|
|
if (hwdevice->type() != TDEGenericDeviceType::Battery) {
|
|
|
|
if (hwdevice->type() != TDEGenericDeviceType::Battery) {
|
|
|
@ -68,6 +76,7 @@ TQString BatterySrc::fetchValue() {
|
|
|
|
TDEBatteryDevice* bdevice = static_cast<TDEBatteryDevice*>(hwdevice);
|
|
|
|
TDEBatteryDevice* bdevice = static_cast<TDEBatteryDevice*>(hwdevice);
|
|
|
|
s = TQString::number(bdevice->chargePercent()) + " %";
|
|
|
|
s = TQString::number(bdevice->chargePercent()) + " %";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return s;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#include "batterysrc.moc"
|
|
|
|
#include "batterysrc.moc"
|
|
|
|