diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp index 0d1207e0a..cde5e3bcb 100644 --- a/tdecore/tdehw/tdehardwaredevices.cpp +++ b/tdecore/tdehw/tdehardwaredevices.cpp @@ -3073,6 +3073,7 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist valuesdir.setFilter(TQDir::All); TQString nodename; double bdevice_capacity = 0; + double bdevice_voltage = 0; int bdevice_time_to_empty = 0; int bdevice_time_to_full = 0; bool bdevice_has_energy = false; @@ -3082,9 +3083,20 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist if (dirlist) { TQFileInfoListIterator valuesdirit(*dirlist); TQFileInfo *dirfi; + // Get the voltage as first... + TQFile file( valuesnodename + "voltage_now" ); + if ( file.open( IO_ReadOnly ) ) { + TQTextStream stream( &file ); + TQString line; + line = stream.readLine(); + bdevice_voltage = line.toDouble()/1000000.0; + bdevice->internalSetVoltage(bdevice_voltage); + file.close(); + } + // ...and then the other values while ( (dirfi = valuesdirit.current()) != 0 ) { nodename = dirfi->fileName(); - TQFile file( valuesnodename + nodename ); + file.setName( valuesnodename + nodename ); if ( file.open( IO_ReadOnly ) ) { TQTextStream stream( &file ); TQString line; @@ -3095,25 +3107,50 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist else if (nodename == "capacity") { bdevice_capacity = line.toDouble(); } - else if (nodename == "charge_full" || nodename == "energy_full") { + else if (nodename == "charge_full") { bdevice->internalSetMaximumEnergy(line.toDouble()/1000000.0); } - else if (nodename == "charge_full_design" || nodename == "energy_full_design") { + else if (nodename == "energy_full") { + if (bdevice_voltage > 0) { + // Convert from mWh do Ah + bdevice->internalSetMaximumEnergy(line.toDouble()/1000000.0/bdevice_voltage); + } + } + else if (nodename == "charge_full_design") { bdevice->internalSetMaximumDesignEnergy(line.toDouble()/1000000.0); } - else if (nodename == "charge_now" || nodename == "energy_now") { + else if (nodename == "energy_full_design") { + if (bdevice_voltage > 0) { + // Convert from mWh do Ah + bdevice->internalSetMaximumDesignEnergy(line.toDouble()/1000000.0/bdevice_voltage); + } + } + else if (nodename == "charge_now") { bdevice->internalSetEnergy(line.toDouble()/1000000.0); bdevice_has_energy = true; } + else if (nodename == "energy_now") { + if (bdevice_voltage > 0) { + // Convert from mWh do Ah + bdevice->internalSetEnergy(line.toDouble()/1000000.0/bdevice_voltage); + bdevice_has_energy = true; + } + } else if (nodename == "manufacturer") { bdevice->internalSetVendorName(line.stripWhiteSpace()); } else if (nodename == "model_name") { bdevice->internalSetVendorModel(line.stripWhiteSpace()); } - else if (nodename == "power_now" || nodename == "current_now") { + else if (nodename == "current_now") { bdevice->internalSetDischargeRate(line.toDouble()/1000000.0); } + else if (nodename == "power_now") { + if (bdevice_voltage > 0) { + // Convert from mW do A + bdevice->internalSetDischargeRate(line.toDouble()/1000000.0/bdevice_voltage); + } + } else if (nodename == "present") { bdevice->internalSetInstalled(line.toInt()); } @@ -3139,9 +3176,6 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist else if (nodename == "voltage_min_design") { bdevice->internalSetMinimumVoltage(line.toDouble()/1000000.0); } - else if (nodename == "voltage_now") { - bdevice->internalSetVoltage(line.toDouble()/1000000.0); - } file.close(); } ++valuesdirit;