From 20fc5cd8695425d504c071449f6d38ae3da29511 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 8 Apr 2012 21:30:22 -0500 Subject: Add sensors tab --- kcontrol/hwmanager/devicepropsdlg.cpp | 53 ++++++++++++++++++++++++ kcontrol/hwmanager/devicepropsdlgbase.ui | 69 ++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) (limited to 'kcontrol/hwmanager') diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp index 1283d2e44..af16249ba 100644 --- a/kcontrol/hwmanager/devicepropsdlg.cpp +++ b/kcontrol/hwmanager/devicepropsdlg.cpp @@ -51,6 +51,9 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge if (m_device->type() != TDEGenericDeviceType::CPU) { base->tabBarWidget->removePage(base->tabCPU); } + if ((m_device->type() != TDEGenericDeviceType::OtherSensor) && (m_device->type() != TDEGenericDeviceType::ThermalSensor)) { + base->tabBarWidget->removePage(base->tabSensor); + } TQGridLayout *mainGrid = new TQGridLayout(plainPage(), 1, 1, 0, spacingHint()); mainGrid->setRowStretch(1, 1); @@ -92,6 +95,7 @@ void DevicePropertiesDialog::populateDeviceInformation() { base->labelSubsytemType->setText(m_device->subsystem()); base->labelDeviceDriver->setText((m_device->deviceDriver().isNull())?i18n(""):m_device->deviceDriver()); base->labelDeviceClass->setText((m_device->PCIClass().isNull())?i18n(""):m_device->PCIClass()); + base->labelModalias->setText((m_device->moduleAlias().isNull())?i18n(""):m_device->moduleAlias()); if (m_device->subsystem() == "pci") { base->labelBusID->setText(m_device->busID()); base->labelBusID->show(); @@ -174,7 +178,56 @@ void DevicePropertiesDialog::populateDeviceInformation() { else { base->labelDependentCPUs->setText(i18n("")); } + } + + if ((m_device->type() == TDEGenericDeviceType::OtherSensor) || (m_device->type() == TDEGenericDeviceType::ThermalSensor)) { + TDESensorDevice* sdevice = static_cast(m_device); + + // FIXME + // This is rather ugly + // It should be handled via dynamic addition/update of new TQLabel objects, but that is somewhat complex + TQString sensorLabels = ""; + TQString sensorDataPoints = ""; + TDESensorClusterMap map = sdevice->values(); + TDESensorClusterMap::Iterator it; + for ( it = map.begin(); it != map.end(); ++it ) { + TQString sensorlabel = it.key(); + TQString sensordatastring; + TDESensorCluster values = it.data(); + + if (!values.label.isNull()) { + sensorlabel = values.label; + } + if (sensorlabel.isNull()) { + sensorlabel = i18n(""); + } + + if (values.minimum > 0) { + sensordatastring += TQString("Minimum Value: %1, ").arg(values.minimum); + } + sensordatastring += TQString("Current Value: %1, ").arg(values.current); + if (values.maximum > 0) { + sensordatastring += TQString("Maximum Value: %1, ").arg(values.maximum); + } + if (values.warning > 0) { + sensordatastring += TQString("Warning Value: %1, ").arg(values.warning); + } + if (values.critical > 0) { + sensordatastring += TQString("Critical Value: %1, ").arg(values.critical); + } + + if (sensordatastring.endsWith(", ")) { + sensordatastring.truncate(sensordatastring.length()-2); + } + + sensorLabels += sensorlabel + "
"; + sensorDataPoints += sensordatastring + "
"; + } + sensorLabels += "
"; + sensorDataPoints += "
"; + base->labelSensorNames->setText(sensorLabels); + base->labelSensorValues->setText(sensorDataPoints); } } } diff --git a/kcontrol/hwmanager/devicepropsdlgbase.ui b/kcontrol/hwmanager/devicepropsdlgbase.ui index 4c6354785..62570223f 100644 --- a/kcontrol/hwmanager/devicepropsdlgbase.ui +++ b/kcontrol/hwmanager/devicepropsdlgbase.ui @@ -171,6 +171,19 @@ labelBusID + + + unnamed + + + Technical Details: + + + + + labelModalias + + @@ -404,6 +417,62 @@ + + + tabSensor + + + Sensor + + + + unnamed + + + + groupSensors + + + Sensor Readings + + + + unnamed + + + + labelSensorNames + + + + + + + + labelSensorValues + + + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + -- cgit v1.2.1