diff options
Diffstat (limited to 'kcontrol/hwmanager')
-rw-r--r-- | kcontrol/hwmanager/CMakeLists.txt | 39 | ||||
-rw-r--r-- | kcontrol/hwmanager/deviceiconview.cpp | 108 | ||||
-rw-r--r-- | kcontrol/hwmanager/deviceiconview.h | 82 | ||||
-rw-r--r-- | kcontrol/hwmanager/devicepropsdlg.cpp | 831 | ||||
-rw-r--r-- | kcontrol/hwmanager/devicepropsdlg.h | 207 | ||||
-rw-r--r-- | kcontrol/hwmanager/devicepropsdlgbase.ui | 1545 | ||||
-rw-r--r-- | kcontrol/hwmanager/hwmanager.cpp | 215 | ||||
-rw-r--r-- | kcontrol/hwmanager/hwmanager.desktop | 21 | ||||
-rw-r--r-- | kcontrol/hwmanager/hwmanager.h | 72 | ||||
-rw-r--r-- | kcontrol/hwmanager/hwmanagerbase.ui | 85 |
10 files changed, 3205 insertions, 0 deletions
diff --git a/kcontrol/hwmanager/CMakeLists.txt b/kcontrol/hwmanager/CMakeLists.txt new file mode 100644 index 000000000..584eba7bc --- /dev/null +++ b/kcontrol/hwmanager/CMakeLists.txt @@ -0,0 +1,39 @@ +################################################# +# +# (C) 2012 Timothy Pearson +# kb9vqf (AT) pearsoncomputing.net +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES hwmanager.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) + + +##### kcm_iccconfig (module) #################### + +set_source_files_properties( hwmanager.cpp PROPERTIES COMPILE_FLAGS -DKDE_CONFDIR=\\"${TDE_CONFIG_DIR}\\" ) + +tde_add_kpart( kcm_hwmanager AUTOMOC + SOURCES + hwmanager.cpp deviceiconview.cpp devicepropsdlg.cpp devicepropsdlgbase.ui hwmanagerbase.ui hwmanager.skel + LINK tdeio-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/kcontrol/hwmanager/deviceiconview.cpp b/kcontrol/hwmanager/deviceiconview.cpp new file mode 100644 index 000000000..7ccb93daf --- /dev/null +++ b/kcontrol/hwmanager/deviceiconview.cpp @@ -0,0 +1,108 @@ +/* + Copyright (c) 2000 Matthias Elter <[email protected]> + Copyright (c) 2003 Daniel Molkentin <[email protected]> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + +#include <tqheader.h> +#include <tqcursor.h> + +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <kservicegroup.h> +#include <kiconloader.h> +#include <tdemessagebox.h> + +#include <kdebug.h> + +#include "deviceiconview.h" +#include "deviceiconview.moc" + +DeviceIconView::DeviceIconView(TQWidget * parent, const char * name) + : TDEListView(parent, name) +{ + setSorting(0, true); + addColumn(TQString::null); + + // Show expand/collapse widgets on root items + setRootIsDecorated(true); + + header()->hide(); + + connect(this, TQT_SIGNAL(clicked(TQListViewItem*)), this, TQT_SLOT(slotItemSelected(TQListViewItem*))); + connect(this, TQT_SIGNAL(executed(TQListViewItem*)), this, TQT_SLOT(slotItemDoubleClicked(TQListViewItem*))); +} + +void DeviceIconView::slotItemSelected(TQListViewItem* item) +{ + TQApplication::restoreOverrideCursor(); + if (!item) { + return; + } +} + +void DeviceIconView::slotItemDoubleClicked(TQListViewItem* item) +{ + TQApplication::restoreOverrideCursor(); + if (!item) { + return; + } + + DeviceIconItem* divi = dynamic_cast<DeviceIconItem*>(item); + if (!divi) { + return; + } + + if (divi->device()) { + DevicePropertiesDialog* propsDlg = new DevicePropertiesDialog(divi->device(), this); + propsDlg->exec(); + delete propsDlg; + } + else { + KMessageBox::sorry(this, "Detailed information is not available for this device", "Information Unavailable"); + } +} + +void DeviceIconView::keyPressEvent(TQKeyEvent *e) +{ + if (e->key() == Key_Return + || e->key() == Key_Enter + || e->key() == Key_Space) + { + if (currentItem()) { + slotItemSelected(currentItem()); + } + } + else { + TDEListView::keyPressEvent(e); + } +} + +TQPixmap DeviceIconView::loadIcon( const TQString &name ) +{ + TQPixmap icon = DesktopIcon( name, iconSize() ); + + if(icon.isNull()) { + icon = DesktopIcon( "misc", iconSize() ); + } + + return icon; +} + +TDEIcon::StdSizes DeviceIconView::iconSize() { + return TDEIcon::SizeSmall; +} diff --git a/kcontrol/hwmanager/deviceiconview.h b/kcontrol/hwmanager/deviceiconview.h new file mode 100644 index 000000000..913c4c9ef --- /dev/null +++ b/kcontrol/hwmanager/deviceiconview.h @@ -0,0 +1,82 @@ +/* + Copyright (c) 2012 Timothy Pearson <[email protected]> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + +#ifndef __deviceiconview_h__ +#define __deviceiconview_h__ + +#include <tdelistview.h> +#include <kiconloader.h> +#include <tdehardwaredevices.h> + +#include "devicepropsdlg.h" + +class ConfigModule; +class ConfigModuleList; + +class DeviceIconItem : public TDEListViewItem +{ +public: + DeviceIconItem(TQListViewItem *parent, const TQString& text, const TQPixmap& pm, TDEGenericDevice *d = 0) + : TDEListViewItem(parent, text) + , _tag(TQString::null) + , _device(d) + { + setPixmap(0, pm); + } + DeviceIconItem(TQListView *parent, const TQString& text, const TQPixmap& pm, TDEGenericDevice *d = 0) + : TDEListViewItem(parent, text) + , _tag(TQString::null) + , _device(d) + { + setPixmap(0, pm); + } + + void setDevice(TDEGenericDevice* d) { _device = d; } + void setTag(const TQString& t) { _tag = t; } + + TDEGenericDevice* device() { return _device; } + TQString tag() { return _tag; } + + +private: + TQString _tag; + TDEGenericDevice *_device; +}; + +class DeviceIconView : public TDEListView +{ + Q_OBJECT + +public: + DeviceIconView(TQWidget * parent = 0, const char * name = 0); + TDEIcon::StdSizes iconSize(); + +signals: + void deviceSelected(TDEGenericDevice*); + +protected slots: + void slotItemSelected(TQListViewItem*); + void slotItemDoubleClicked(TQListViewItem*); + +protected: + void keyPressEvent(TQKeyEvent *); + TQPixmap loadIcon( const TQString &name ); +}; + +#endif diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp new file mode 100644 index 000000000..12de8cea9 --- /dev/null +++ b/kcontrol/hwmanager/devicepropsdlg.cpp @@ -0,0 +1,831 @@ +/* This file is part of TDE + Copyright (C) 2012 Timothy Pearson <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#include <config.h> + +#include <tqvalidator.h> +#include <tqpushbutton.h> +#include <tqlineedit.h> +#include <tqlabel.h> +#include <tqtabwidget.h> +#include <tqgroupbox.h> +#include <tqlayout.h> +#include <tqslider.h> +#include <tqpainter.h> +#include <tqstyle.h> +#include <tqinternal_p.h> +#undef Unsorted // Required for --enable-final (tqdir.h) +#include <tqfiledialog.h> + +#include <kbuttonbox.h> +#include <kcombobox.h> +#include <tdelocale.h> +#include <tdeapplication.h> +#include <klineedit.h> +#include <kstdguiitem.h> +#include <tdemessagebox.h> + +#include "devicepropsdlg.h" + +SensorDisplayLabelsWidget::SensorDisplayLabelsWidget(TQWidget *parent) + : TQWidget(parent) +{ + m_nameLabel = new TQLabel(this); + m_valueLabel = new TQLabel(this); + + TQGridLayout *mainGrid = new TQGridLayout(this, 1, 2, 0, 1); + mainGrid->setRowStretch(1, 0); + mainGrid->addWidget(m_nameLabel, 0, 0); + mainGrid->addWidget(m_valueLabel, 0, 1); +} + +SensorDisplayLabelsWidget::~SensorDisplayLabelsWidget() +{ +} + +void SensorDisplayLabelsWidget::setSensorName(TQString name) { + m_nameLabel->setText(name); +} + +void SensorDisplayLabelsWidget::setSensorValue(TQString value) { + m_valueLabel->setText(value); +} + +bool SensorBar::setIndicator(TQString & progress_str, int progress, int totalSteps) { + Q_UNUSED(progress); + Q_UNUSED(totalSteps); + + if (progress_str != m_currentValueString) { + progress_str = m_currentValueString; + return true; + } + else { + return false; + } +} + +void SensorBar::drawContents(TQPainter *p) { + // Draw warn/crit/value bars + + TQRect bar = contentsRect(); + TQSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() ); + buffer.painter()->fillRect(bar, TQt::white); + + TQStyle::SFlags flags = TQStyle::Style_Default; + if (isEnabled()) { + flags |= TQStyle::Style_Enabled; + } + if (hasFocus()) { + flags |= TQStyle::Style_HasFocus; + } + style().drawControl(TQStyle::CE_ProgressBarGroove, buffer.painter(), this, TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarGroove, this), this ), colorGroup(), flags); + + if (m_warningLocation > 0) { + bar = contentsRect(); + bar.setX((bar.width()*((m_warningLocation*1.0)/totalSteps()))-2); + bar.setWidth(5); + bar.setHeight(3); + buffer.painter()->fillRect(bar, TQt::yellow); + bar = contentsRect(); + bar.setX((bar.width()*((m_warningLocation*1.0)/totalSteps()))-2); + bar.setWidth(5); + bar.setY(bar.height()-3); + bar.setHeight(3); + buffer.painter()->fillRect(bar, TQt::yellow); + bar = contentsRect(); + bar.setX((bar.width()*((m_warningLocation*1.0)/totalSteps()))-0); + bar.setWidth(1); + buffer.painter()->fillRect(bar, TQt::yellow); + } + + if (m_criticalLocation > 0) { + bar = contentsRect(); + bar.setX((bar.width()*((m_criticalLocation*1.0)/totalSteps()))-2); + bar.setWidth(5); + bar.setHeight(3); + buffer.painter()->fillRect(bar, TQt::red); + bar = contentsRect(); + bar.setX((bar.width()*((m_criticalLocation*1.0)/totalSteps()))-2); + bar.setWidth(5); + bar.setY(bar.height()-3); + bar.setHeight(3); + buffer.painter()->fillRect(bar, TQt::red); + bar = contentsRect(); + bar.setX((bar.width()*((m_criticalLocation*1.0)/totalSteps()))-0); + bar.setWidth(1); + buffer.painter()->fillRect(bar, TQt::red); + } + + if (m_currentLocation > 0) { + bar = contentsRect(); + bar.setX((bar.width()*((m_currentLocation*1.0)/totalSteps()))-2); + bar.setWidth(5); + bar.setHeight(3); + buffer.painter()->fillRect(bar, TQt::green); + bar = contentsRect(); + bar.setX((bar.width()*((m_currentLocation*1.0)/totalSteps()))-2); + bar.setWidth(5); + bar.setY(bar.height()-3); + bar.setHeight(3); + buffer.painter()->fillRect(bar, TQt::green); + bar = contentsRect(); + bar.setX((bar.width()*((m_currentLocation*1.0)/totalSteps()))-0); + bar.setWidth(1); + buffer.painter()->fillRect(bar, TQt::green); + } + + bar = contentsRect(); + buffer.painter()->setPen(TQt::black); + buffer.painter()->drawText(bar.x(), bar.y(), bar.width()/3, bar.height(), TQt::AlignVCenter | TQt::AlignLeft, m_minimumValueString); + buffer.painter()->drawText(bar.x()+(bar.width()/3), bar.y(), bar.width()/3, bar.height(), TQt::AlignVCenter | TQt::AlignHCenter, m_currentValueString); + buffer.painter()->drawText(bar.x()+((bar.width()/3)*2), bar.y(), bar.width()/3, bar.height(), TQt::AlignVCenter | TQt::AlignRight, m_maximumValueString); +} + +SensorDisplayWidget::SensorDisplayWidget(TQWidget *parent) + : TQWidget(parent) +{ + m_nameLabel = new TQLabel(this); + m_progressBar = new SensorBar(this); + + TQGridLayout *mainGrid = new TQGridLayout(this, 1, 2, 0, 1); + mainGrid->setRowStretch(1, 0); + mainGrid->addWidget(m_nameLabel, 0, 0); + mainGrid->addWidget(m_progressBar, 0, 1); +} + +SensorDisplayWidget::~SensorDisplayWidget() +{ +} + +void SensorDisplayWidget::setSensorName(TQString name) { + m_nameLabel->setText(name); +} + +void SensorDisplayWidget::setSensorCurrentValue(double value) { + m_current = value; +} + +void SensorDisplayWidget::setSensorMinimumValue(double value) { + m_minimum = value; +} + +void SensorDisplayWidget::setSensorMaximumValue(double value) { + m_maximum = value; +} + +void SensorDisplayWidget::setSensorWarningValue(double value) { + m_warning = value; +} + +void SensorDisplayWidget::setSensorCriticalValue(double value) { + m_critical = value; +} + +void SensorDisplayWidget::updateDisplay() { + double minimum = m_minimum; + double maximum = m_maximum; + double current = m_current; + double warning = m_warning; + double critical = m_critical; + + if (minimum < 0) { + minimum = 0; + } + if (maximum < 0) { + if (critical < 0) { + maximum = warning; + } + else { + maximum = critical; + } + } + if (warning > maximum) { + maximum = warning; + } + if (critical > maximum) { + maximum = critical; + } + + m_progressBar->setTotalSteps(maximum); + m_progressBar->m_currentLocation = current - minimum; + m_progressBar->setProgress(0); + + if (warning < 0) { + m_progressBar->m_warningLocation = -1; + } + else { + m_progressBar->m_warningLocation = warning - minimum; + } + if (critical < 0) { + m_progressBar->m_criticalLocation = -1; + } + else { + m_progressBar->m_criticalLocation = critical - minimum; + } + + m_progressBar->m_minimumValueString = (TQString("%1").arg(minimum)); + m_progressBar->m_maximumValueString = (TQString("%1").arg(maximum)); + m_progressBar->m_currentValueString = TQString("%1").arg(current); +} + +DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidget *parent) + : KDialogBase(Plain, TQString::null, Ok|Cancel, Ok, parent, 0L, true, true) +{ + m_device = device; + enableButtonOK( false ); + + if (m_device) { + base = new DevicePropertiesDialogBase(plainPage()); + + // Remove all non-applicable tabs + if (m_device->type() != TDEGenericDeviceType::Disk) { + base->tabBarWidget->removePage(base->tabDisk); + } + 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); + } + if (m_device->type() != TDEGenericDeviceType::Battery) { + base->tabBarWidget->removePage(base->tabBattery); + } + if (m_device->type() != TDEGenericDeviceType::PowerSupply) { + base->tabBarWidget->removePage(base->tabPowerSupply); + } + if (m_device->type() != TDEGenericDeviceType::Network) { + base->tabBarWidget->removePage(base->tabNetwork); + } + if (m_device->type() != TDEGenericDeviceType::Backlight) { + base->tabBarWidget->removePage(base->tabBacklight); + } + if (m_device->type() != TDEGenericDeviceType::Monitor) { + base->tabBarWidget->removePage(base->tabMonitor); + } + if (m_device->type() != TDEGenericDeviceType::RootSystem) { + base->tabBarWidget->removePage(base->tabRootSystem); + } + if (m_device->type() != TDEGenericDeviceType::Event) { + base->tabBarWidget->removePage(base->tabEvent); + } + + if (m_device->type() == TDEGenericDeviceType::CPU) { + connect(base->comboCPUGovernor, TQT_SIGNAL(activated(const TQString &)), this, TQT_SLOT(setCPUGovernor(const TQString &))); + } + if (m_device->type() == TDEGenericDeviceType::Disk) { + connect(base->buttonDiskMount, TQT_SIGNAL(clicked()), this, TQT_SLOT(mountDisk())); + connect(base->buttonDiskUnmount, TQT_SIGNAL(clicked()), this, TQT_SLOT(unmountDisk())); + } + + if ((m_device->type() == TDEGenericDeviceType::OtherSensor) || (m_device->type() == TDEGenericDeviceType::ThermalSensor)) { + base->groupSensors->setColumnLayout(0, TQt::Vertical ); + base->groupSensors->layout()->setSpacing( KDialog::spacingHint() ); + base->groupSensors->layout()->setMargin( KDialog::marginHint() ); + m_sensorDataGrid = new TQGridLayout( base->groupSensors->layout() ); + m_sensorDataGrid->setAlignment( TQt::AlignTop ); + m_sensorDataGridWidgets.setAutoDelete(true); + } + if (m_device->type() == TDEGenericDeviceType::Backlight) { + connect(base->sliderBacklightBrightness, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setBacklightBrightness(int))); + } + if (m_device->type() == TDEGenericDeviceType::RootSystem) { + connect(base->comboSystemHibernationMethod, TQT_SIGNAL(activated(int)), this, TQT_SLOT(setHibernationMethod(int))); + } + + TQGridLayout *mainGrid = new TQGridLayout(plainPage(), 1, 1, 0, spacingHint()); + mainGrid->setRowStretch(1, 1); + mainGrid->addWidget(base, 0, 0); + } + + TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); + + connect(hwdevices, TQT_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQT_SLOT(processHardwareRemoved(TDEGenericDevice*))); + connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(processHardwareUpdated(TDEGenericDevice*))); + + populateDeviceInformation(); +} + +DevicePropertiesDialog::~DevicePropertiesDialog() +{ +} + +void DevicePropertiesDialog::processHardwareRemoved(TDEGenericDevice* dev) { + if (dev == m_device) { + close(); + } +} + +void DevicePropertiesDialog::processHardwareUpdated(TDEGenericDevice* dev) { + if (dev == m_device) { + populateDeviceInformation(); + } +} + +TQString assembleSwitchList(TDESwitchType::TDESwitchType switches) { + return (TDEEventDevice::friendlySwitchList(switches).join("<br>")); +} + +void DevicePropertiesDialog::populateDeviceInformation() { + if (m_device) { + base->labelDeviceType->setText(m_device->friendlyDeviceType()); + base->iconDeviceType->setPixmap(m_device->icon(TDEIcon::SizeSmall)); + base->labelDeviceName->setText(m_device->friendlyName()); + base->labelDeviceNode->setText((m_device->deviceNode().isNull())?i18n("<none>"):m_device->deviceNode()); + base->labelSystemPath->setText(m_device->systemPath()); + base->labelSubsytemType->setText(m_device->subsystem()); + base->labelDeviceDriver->setText((m_device->deviceDriver().isNull())?i18n("<none>"):m_device->deviceDriver()); + base->labelDeviceClass->setText((m_device->PCIClass().isNull())?i18n("<n/a>"):m_device->PCIClass()); + base->labelModalias->setText((m_device->moduleAlias().isNull())?i18n("<none>"):m_device->moduleAlias()); + + // These might be redundant + #if 0 + base->labelVendorName->setText((m_device->vendorName().isNull())?i18n("<unknown>"):m_device->vendorName()); + base->labelVendorModel->setText((m_device->vendorModel().isNull())?i18n("<unknown>"):m_device->vendorModel()); + #else + base->labelVendorName->hide(); + base->stocklabelVendorName->hide(); + base->labelVendorModel->hide(); + base->stocklabelVendorModel->hide(); + #endif + base->labelSerialNumber->setText((m_device->serialNumber().isNull())?i18n("<unknown>"):m_device->serialNumber()); + + if (m_device->subsystem() == "pci") { + base->labelBusID->setText(m_device->busID()); + base->labelBusID->show(); + base->stocklabelBusID->show(); + } + else { + base->labelBusID->hide(); + base->stocklabelBusID->hide(); + } + + if (m_device->type() == TDEGenericDeviceType::Disk) { + TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); + + TQString mountPoint = sdevice->mountPath(); + if (mountPoint == "") mountPoint = i18n("<none>"); + base->labelDiskMountpoint->setText(mountPoint); + + TQString fsName = sdevice->fileSystemName(); + if (fsName == "") fsName = i18n("<unknown>"); + base->labelDiskFileSystemType->setText(fsName); + + TQString volUUID = sdevice->diskUUID(); + if (volUUID == "") volUUID = i18n("<none>"); + base->labelDiskUUID->setText(volUUID); + + // Show status + TQString status_text = "<qt>"; + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable)) { + status_text += "Mountable<br>"; + } + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) { + status_text += "Removable<br>"; + } + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Inserted)) { + status_text += "Inserted<br>"; + } + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) { + status_text += "Blank<br>"; + } + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)) { + status_text += "In use<br>"; + } + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsesDevice)) { + status_text += "Uses other device<br>"; + } + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem)) { + status_text += "Contains a filesystem<br>"; + } + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) { + status_text += "Hotpluggable<br>"; + } + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden)) { + status_text += "Hidden<br>"; + } + if (status_text == "<qt>") { + status_text += "<i>Unavailable</i>"; + } + status_text += "</qt>"; + base->labelDiskStatus->setText(status_text); + + // Update mount/unmount button status + if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable)) { + base->groupDiskActions->show(); + base->buttonDiskMount->setEnabled((sdevice->mountPath() == "")); + base->buttonDiskUnmount->setEnabled((sdevice->mountPath() != "")); + } + else { + base->groupDiskActions->hide(); + } + } + + if (m_device->type() == TDEGenericDeviceType::CPU) { + TDECPUDevice* cdevice = static_cast<TDECPUDevice*>(m_device); + + // Show information + base->labelCPUVendor->setText(cdevice->vendorEncoded()); + base->labelCPUFrequency->setText((cdevice->frequency()<0)?i18n("<unsupported>"):TQString("%1 MHz").arg(cdevice->frequency())); + base->labelMinCPUFrequency->setText((cdevice->minFrequency()<0)?i18n("<unsupported>"):TQString("%1 MHz").arg(cdevice->minFrequency())); + base->labelMaxCPUFrequency->setText((cdevice->maxFrequency()<0)?i18n("<unsupported>"):TQString("%1 MHz").arg(cdevice->maxFrequency())); + base->labelScalingDriver->setText((cdevice->scalingDriver().isNull())?i18n("<none>"):cdevice->scalingDriver()); + TQStringList scalingfreqs = cdevice->availableFrequencies(); + if (scalingfreqs.count() > 0) { + TQString scalingfreqsstring = "<qt>"; + for ( TQStringList::Iterator it = scalingfreqs.begin(); it != scalingfreqs.end(); ++it ) { + TQString freq = (*it); + scalingfreqsstring.append(TQString("%1 MHz<br>").arg(freq.toDouble()/1000)); + } + scalingfreqsstring.append("</qt>"); + base->labelScalingFrequencies->setText(scalingfreqsstring); + } + else { + base->labelScalingFrequencies->setText(i18n("<none>")); + } + TQStringList dependentcpus = cdevice->dependentProcessors(); + if (dependentcpus.count() > 0) { + TQString dependentcpusstring = "<qt>"; + for ( TQStringList::Iterator it = dependentcpus.begin(); it != dependentcpus.end(); ++it ) { + TQString proc = (*it); + dependentcpusstring.append(TQString("CPU %1<br>").arg(proc)); + } + dependentcpusstring.append("</qt>"); + base->labelDependentCPUs->setText(dependentcpusstring); + } + else { + base->labelDependentCPUs->setText(i18n("<none>")); + } + base->comboCPUGovernor->setEnabled(cdevice->canSetGovernor()); + TQStringList governorPolicies = cdevice->availableGovernors(); + if ((uint)governorPolicies.count() != (uint)base->comboCPUGovernor->count()) { + base->comboCPUGovernor->clear(); + int i=0; + for (TQStringList::Iterator it = governorPolicies.begin(); it != governorPolicies.end(); ++it) { + base->comboCPUGovernor->insertItem(*it, i); + i++; + } + } + base->comboCPUGovernor->setCurrentItem(cdevice->governor(), false); + } + + if ((m_device->type() == TDEGenericDeviceType::OtherSensor) || (m_device->type() == TDEGenericDeviceType::ThermalSensor)) { + TDESensorDevice* sdevice = static_cast<TDESensorDevice*>(m_device); + + TDESensorClusterMap map = sdevice->values(); + TDESensorClusterMap::Iterator it; + unsigned int i; + + if (m_sensorDataGridWidgets.count() != map.count()) { + m_sensorDataGridWidgets.clear(); + for (i=0;i<map.count();i++) { + SensorDisplayWidget* sensorWidget = new SensorDisplayWidget(base->groupSensors); + m_sensorDataGrid->addWidget(sensorWidget, i, 0); + m_sensorDataGridWidgets.append(sensorWidget); + } + } + + i=0; + 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("<unnamed>"); + } + + m_sensorDataGridWidgets.at(i)->setSensorName(sensorlabel); + m_sensorDataGridWidgets.at(i)->setSensorCurrentValue(values.current); + m_sensorDataGridWidgets.at(i)->setSensorMinimumValue(values.minimum); + m_sensorDataGridWidgets.at(i)->setSensorMaximumValue(values.maximum); + m_sensorDataGridWidgets.at(i)->setSensorWarningValue(values.warning); + m_sensorDataGridWidgets.at(i)->setSensorCriticalValue(values.critical); + m_sensorDataGridWidgets.at(i)->updateDisplay(); + + i++; + } + } + + if (m_device->type() == TDEGenericDeviceType::Battery) { + TDEBatteryDevice* bdevice = static_cast<TDEBatteryDevice*>(m_device); + + base->labelCurrentBatteryEnergy->setText((bdevice->energy()<0)?i18n("<unknown>"):TQString("%1 Wh").arg(bdevice->energy())); + base->labelMaximumBatteryEnergy->setText((bdevice->maximumEnergy()<0)?i18n("<unknown>"):TQString("%1 Wh").arg(bdevice->maximumEnergy())); + base->labelMaximumBatteryDesignEnergy->setText((bdevice->maximumDesignEnergy()<0)?i18n("<unknown>"):TQString("%1 Wh").arg(bdevice->maximumDesignEnergy())); + base->labelMinimumBatteryVoltage->setText((bdevice->minimumVoltage()<0)?i18n("<unknown>"):TQString("%1 V").arg(bdevice->minimumVoltage())); + base->labelCurrentBatteryVoltage->setText((bdevice->voltage()<0)?i18n("<unknown>"):TQString("%1 V").arg(bdevice->voltage())); + base->labelCurrentBatteryDischargeRate->setText((bdevice->dischargeRate()<0)?i18n("<unknown>"):TQString("%1 Wh").arg(bdevice->dischargeRate())); + TQString batteryStatusString = i18n("Unknown"); + TDEBatteryStatus::TDEBatteryStatus batteryStatus = bdevice->status(); + if (batteryStatus == TDEBatteryStatus::Charging) { + batteryStatusString = i18n("Charging"); + } + if (batteryStatus == TDEBatteryStatus::Discharging) { + batteryStatusString = i18n("Discharging"); + } + if (batteryStatus == TDEBatteryStatus::Full) { + batteryStatusString = i18n("Full"); + } + base->labelCurrentBatteryStatus->setText(batteryStatusString); + base->labelBatteryTechnology->setText((bdevice->technology().isNull())?i18n("<unknown>"):bdevice->technology()); + base->labelBatteryInstalled->setText((bdevice->installed()==0)?i18n("No"):i18n("Yes")); + base->labelBatteryCharge->setText((bdevice->chargePercent()<0)?i18n("<unknown>"):TQString("%1 %").arg(bdevice->chargePercent())); + base->labelBatteryTimeRemaining->setText((bdevice->timeRemaining()<0)?i18n("<unknown>"):TQString("%1 seconds").arg(bdevice->timeRemaining())); + } + + if (m_device->type() == TDEGenericDeviceType::PowerSupply) { + TDEMainsPowerDevice* pdevice = static_cast<TDEMainsPowerDevice*>(m_device); + + base->labelPowerSupplyOnline->setText((pdevice->online()==0)?i18n("No"):i18n("Yes")); + } + + if (m_device->type() == TDEGenericDeviceType::Network) { + TDENetworkDevice* ndevice = static_cast<TDENetworkDevice*>(m_device); + + base->labelNetworkMAC->setText((ndevice->macAddress().isNull())?i18n("<unknown>"):ndevice->macAddress()); + base->labelNetworkState->setText((ndevice->state().isNull())?i18n("<unknown>"):ndevice->state()); + base->labelNetworkCarrierPresent->setText((ndevice->carrierPresent()==0)?i18n("No"):i18n("Yes")); + base->labelNetworkDormant->setText((ndevice->dormant()==0)?i18n("No"):i18n("Yes")); + + base->labelNetworkIPV4Address->setText((ndevice->ipV4Address().isNull())?i18n("<none>"):ndevice->ipV4Address()); + base->labelNetworkIPV4Netmask->setText((ndevice->ipV4Netmask().isNull())?i18n("<none>"):ndevice->ipV4Netmask()); + base->labelNetworkIPV4Broadcast->setText((ndevice->ipV4Broadcast().isNull())?i18n("<none>"):ndevice->ipV4Broadcast()); + base->labelNetworkIPV4Destination->setText((ndevice->ipV4Destination().isNull())?i18n("<none>"):ndevice->ipV4Destination()); + + base->labelNetworkIPV6Address->setText((ndevice->ipV6Address().isNull())?i18n("<none>"):ndevice->ipV6Address()); + base->labelNetworkIPV6Netmask->setText((ndevice->ipV6Netmask().isNull())?i18n("<none>"):ndevice->ipV6Netmask()); + base->labelNetworkIPV6Broadcast->setText((ndevice->ipV6Broadcast().isNull())?i18n("<none>"):ndevice->ipV6Broadcast()); + base->labelNetworkIPV6Destination->setText((ndevice->ipV6Destination().isNull())?i18n("<none>"):ndevice->ipV6Destination()); + + base->labelNetworkRXBytes->setText((ndevice->rxBytes()<0)?i18n("<unknown>"):TDEHardwareDevices::bytesToFriendlySizeString(ndevice->rxBytes())); + base->labelNetworkTXBytes->setText((ndevice->txBytes()<0)?i18n("<unknown>"):TDEHardwareDevices::bytesToFriendlySizeString(ndevice->txBytes())); + base->labelNetworkRXPackets->setText((ndevice->rxPackets()<0)?i18n("<unknown>"):TQString("%1").arg(ndevice->rxPackets())); + base->labelNetworkTXPackets->setText((ndevice->txPackets()<0)?i18n("<unknown>"):TQString("%1").arg(ndevice->txPackets())); + } + + if (m_device->type() == TDEGenericDeviceType::Backlight) { + TDEBacklightDevice* bdevice = static_cast<TDEBacklightDevice*>(m_device); + + base->labelBacklightStatus->setText((bdevice->powerLevel()==TDEDisplayPowerLevel::On)?i18n("On"):i18n("Off")); + base->labelBacklightBrightness->setText((bdevice->brightnessPercent()<0)?i18n("<unknown>"):TQString("%1 %").arg(bdevice->brightnessPercent())); + base->sliderBacklightBrightness->setOrientation(TQt::Horizontal); + base->sliderBacklightBrightness->setMinValue(0); + base->sliderBacklightBrightness->setMaxValue(bdevice->brightnessSteps()-1); + base->sliderBacklightBrightness->setValue(bdevice->rawBrightness()); + base->sliderBacklightBrightness->setEnabled(bdevice->canSetBrightness()); + } + + if (m_device->type() == TDEGenericDeviceType::Monitor) { + TDEMonitorDevice* mdevice = static_cast<TDEMonitorDevice*>(m_device); + + base->labelDisplayPortType->setText((mdevice->portType().isNull())?i18n("<unknown>"):mdevice->portType()); + base->labelDisplayConnected->setText((mdevice->connected())?i18n("Yes"):i18n("No")); + base->labelDisplayEnabled->setText((mdevice->enabled())?i18n("Yes"):i18n("No")); + + TQString dpmsLevel; + TDEDisplayPowerLevel::TDEDisplayPowerLevel dpms = TDEDisplayPowerLevel::On; + if (dpms == TDEDisplayPowerLevel::On) { + dpmsLevel = i18n("On"); + } + else if (dpms == TDEDisplayPowerLevel::Standby) { + dpmsLevel = i18n("Standby"); + } + else if (dpms == TDEDisplayPowerLevel::Suspend) { + dpmsLevel = i18n("Suspend"); + } + else if (dpms == TDEDisplayPowerLevel::Off) { + dpmsLevel = i18n("Off"); + } + base->labelDisplayDPMS->setText(dpmsLevel); + + TDEResolutionList resolutionList = mdevice->resolutions(); + if (resolutionList.count() > 0) { + TQString resolutionsstring = "<qt>"; + TDEResolutionList::iterator it; + for (it = resolutionList.begin(); it != resolutionList.end(); ++it) { + TDEResolutionPair res = *it; + resolutionsstring += TQString("%1x%2<br>").arg(res.first).arg(res.second); + } + resolutionsstring += "</qt>"; + base->labelDisplayResolutions->setText(resolutionsstring); + } + else { + base->labelDisplayResolutions->setText(i18n("<unknown>")); + } + + // RandR warning + base->labelRandrWarning->setText("<qt><b>NOTE: Any further integration of displays into TDE <i>REQUIRES</i> multi GPU support and other features slated for RandR 2.0.</b><p>Development on such features has been sorely lacking for well over a year as of 2012; if you want to see Linux come up to Windows and Macintosh standards in this area <i>please tell the Xorg developers</i> at http://www.x.org/wiki/XorgMailingLists<p>The TDE project badly needs these features before it can proceed with graphical monitor configuration tools:<br> * GPU object support<br> * The ability to query the active driver name for any Xorg output<p><b>To recap, this is <i>not a TDE shortcoming</i>, but rather is the result of a lack of fundamental Linux support for graphics configuration!</b></qt>"); + } + + if (m_device->type() == TDEGenericDeviceType::RootSystem) { + TDERootSystemDevice* rdevice = static_cast<TDERootSystemDevice*>(m_device); + + TQString formFactorString; + TDESystemFormFactor::TDESystemFormFactor formFactor = rdevice->formFactor(); + if (formFactor == TDESystemFormFactor::Unclassified) { + formFactorString = i18n("Unknown"); + } + else if (formFactor == TDESystemFormFactor::Desktop) { + formFactorString = i18n("Desktop"); + } + else if (formFactor == TDESystemFormFactor::Laptop) { + formFactorString = i18n("Laptop"); + } + else if (formFactor == TDESystemFormFactor::Server) { + formFactorString = i18n("Server"); + } + base->labelSystemFormFactor->setText(formFactorString); + + TQString powerStatesString; + TDESystemPowerStateList powerStates = rdevice->powerStates(); + if (powerStates.count() > 0) { + powerStatesString = "<qt>"; + TDESystemPowerStateList::iterator it; + for (it = powerStates.begin(); it != powerStates.end(); ++it) { + if ((*it) == TDESystemPowerState::Active) { + powerStatesString += i18n("Active<br>"); + } + if ((*it) == TDESystemPowerState::Standby) { + powerStatesString += i18n("Standby<br>"); + } + if ((*it) == TDESystemPowerState::Freeze) { + powerStatesString += i18n("Freeze<br>"); + } + if ((*it) == TDESystemPowerState::Suspend) { + powerStatesString += i18n("Suspend<br>"); + } + if ((*it) == TDESystemPowerState::Hibernate) { + powerStatesString += i18n("Hibernate<br>"); + } + if ((*it) == TDESystemPowerState::PowerOff) { + powerStatesString += i18n("Power Off<br>"); + } + } + powerStatesString += "</qt>"; + } + else { + powerStatesString += i18n("<unknown>"); + } + base->labelSystemPowerStates->setText(powerStatesString); + + base->comboSystemHibernationMethod->setEnabled(rdevice->canSetHibernationMethod()); + TDESystemHibernationMethodList hibernationMethods = rdevice->hibernationMethods(); + if ((uint)hibernationMethods.count() != (uint)base->comboSystemHibernationMethod->count()) { + base->comboSystemHibernationMethod->clear(); + m_hibernationComboMap.clear(); + int i=0; + TQString label; + for (TDESystemHibernationMethodList::Iterator it = hibernationMethods.begin(); it != hibernationMethods.end(); ++it) { + if ((*it) == TDESystemHibernationMethod::Unsupported) { + label = i18n("<none>"); + } + if ((*it) == TDESystemHibernationMethod::Platform) { + label = i18n("Platform"); + } + if ((*it) == TDESystemHibernationMethod::Shutdown) { + label = i18n("Shutdown"); + } + if ((*it) == TDESystemHibernationMethod::Reboot) { + label = i18n("Reboot"); + } + if ((*it) == TDESystemHibernationMethod::TestProc) { + label = i18n("Test Procedure"); + } + if ((*it) == TDESystemHibernationMethod::Test) { + label = i18n("Test"); + } + base->comboSystemHibernationMethod->insertItem(label, i); + m_hibernationComboMap[*it] = i; + i++; + } + } + base->comboSystemHibernationMethod->setCurrentItem(m_hibernationComboMap[rdevice->hibernationMethod()]); + + base->labelSystemUserCanStandby->setText((rdevice->canStandby())?i18n("Yes"):i18n("No")); + base->labelSystemUserCanFreeze->setText((rdevice->canFreeze())?i18n("Yes"):i18n("No")); + base->labelSystemUserCanSuspend->setText((rdevice->canSuspend())?i18n("Yes"):i18n("No")); + base->labelSystemUserCanHibernate->setText((rdevice->canHibernate())?i18n("Yes"):i18n("No")); + base->labelSystemUserCanPowerOff->setText((rdevice->canPowerOff())?i18n("Yes"):i18n("No")); + + base->labelSystemHibernationSpace->setText((rdevice->diskSpaceNeededForHibernation()<0)?i18n("<unknown>"):TDEHardwareDevices::bytesToFriendlySizeString(rdevice->diskSpaceNeededForHibernation())); + } + + if (m_device->type() == TDEGenericDeviceType::Event) { + TDEEventDevice* edevice = static_cast<TDEEventDevice*>(m_device); + + TQString availableSwitches; + if (edevice->providedSwitches() == TDESwitchType::Null) { + availableSwitches = i18n("<none>"); + } + else { + availableSwitches = "<qt>"; + availableSwitches += assembleSwitchList(edevice->providedSwitches()); + availableSwitches += "</qt>"; + } + base->labelEventSwitchTypes->setText(availableSwitches); + + TQString activeSwitches; + if (edevice->activeSwitches() == TDESwitchType::Null) { + activeSwitches = i18n("<none>"); + } + else { + activeSwitches = "<qt>"; + activeSwitches += assembleSwitchList(edevice->activeSwitches()); + activeSwitches += "</qt>"; + } + base->labelEventSwitchActive->setText(activeSwitches); + } + } +} + +void DevicePropertiesDialog::setCPUGovernor(const TQString &governor) { + TDECPUDevice* cdevice = static_cast<TDECPUDevice*>(m_device); + + cdevice->setGovernor(governor); + populateDeviceInformation(); +} + +void DevicePropertiesDialog::setBacklightBrightness(int value) { + TDEBacklightDevice* bdevice = static_cast<TDEBacklightDevice*>(m_device); + + bdevice->setRawBrightness(value); +} + +void DevicePropertiesDialog::setHibernationMethod(int value) { + TDERootSystemDevice* rdevice = static_cast<TDERootSystemDevice*>(m_device); + + rdevice->setHibernationMethod(m_hibernationComboMap.keys()[value]); + populateDeviceInformation(); +} + +void DevicePropertiesDialog::mountDisk() { + TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); + + // FIXME + // This can only mount normal volumes + TQString qerror; + TQString diskLabel = sdevice->diskLabel(); + if (diskLabel.isNull()) { + diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize()); + } + TDEStorageMountOptions mountOptions; + TQString mountMessages; + TQString mountedPath = sdevice->mountDevice(diskLabel, mountOptions, &mountMessages); + if (mountedPath.isNull()) { + qerror = i18n("<qt>Unable to mount this device.<p>Potential reasons include:<br>Improper device and/or user privilege level<br>Corrupt data on storage device"); + if (!mountMessages.isNull()) { + qerror.append(i18n("<p>Technical details:<br>").append(mountMessages)); + } + qerror.append("</qt>"); + } + else { + qerror = ""; + } + + if (qerror != "") KMessageBox::error(this, qerror, i18n("Mount Failed")); + + populateDeviceInformation(); +} + +void DevicePropertiesDialog::unmountDisk() { + TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); + + TQString qerror; + TQString unmountMessages; + int unmountRetcode = 0; + if (!sdevice->unmountDevice(&unmountMessages, &unmountRetcode)) { + // Unmount failed! + qerror = "<qt>" + i18n("Unfortunately, the device could not be unmounted."); + if (!unmountMessages.isNull()) { + qerror.append(i18n("<p>Technical details:<br>").append(unmountMessages)); + } + qerror.append("</qt>"); + } + + if (qerror != "") KMessageBox::error(this, qerror, i18n("Unmount Failed")); + + populateDeviceInformation(); +} + +void DevicePropertiesDialog::virtual_hook( int id, void* data ) +{ KDialogBase::virtual_hook( id, data ); } + +#include "devicepropsdlg.moc" diff --git a/kcontrol/hwmanager/devicepropsdlg.h b/kcontrol/hwmanager/devicepropsdlg.h new file mode 100644 index 000000000..bbff43977 --- /dev/null +++ b/kcontrol/hwmanager/devicepropsdlg.h @@ -0,0 +1,207 @@ +/* This file is part of TDE + Copyright (C) 2012 Timothy Pearson <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef __devicepropsdlg_h__ +#define __devicepropsdlg_h__ + +#include <tqprogressbar.h> + +#include <kdialogbase.h> + +#include <tdehardwaredevices.h> + +#include "devicepropsdlgbase.h" + +/** + * + * Simple sensor name and text label value display widget + * + * @version 0.1 + * @author Timothy Pearson <[email protected]> + */ + +class TDEUI_EXPORT SensorDisplayLabelsWidget : public TQWidget +{ + Q_OBJECT +public: + /** + * Create a simple sensor name and value display widget + * @param parent Parent widget for the display widget + */ + SensorDisplayLabelsWidget(TQWidget* parent); + virtual ~SensorDisplayLabelsWidget(); + + /** + * Set sensor name + * @param name A TQString with the name of the sensor + */ + void setSensorName(TQString name); + + /** + * Set sensor value + * @param value A TQString with the value of the sensor + */ + void setSensorValue(TQString value); + +private: + TQLabel* m_nameLabel; + TQLabel* m_valueLabel; +}; + +class TDEUI_EXPORT SensorBar : public TQProgressBar +{ + Q_OBJECT +public: + SensorBar(TQWidget* parent=0, const char* name=0, WFlags f=0) : TQProgressBar(parent, name, f) {} + SensorBar(int totalSteps, TQWidget* parent=0, const char* name=0, WFlags f=0): TQProgressBar(totalSteps, parent, name, f) {} + +protected: + virtual bool setIndicator(TQString & progress_str, int progress, int totalSteps); + virtual void drawContents(TQPainter *p); + +public: + TQString m_currentValueString; + TQString m_maximumValueString; + TQString m_minimumValueString; + int m_currentLocation; + int m_warningLocation; + int m_criticalLocation; +}; + +/** + * + * Simple sensor information display widget + * + * @version 0.1 + * @author Timothy Pearson <[email protected]> + */ + +class TDEUI_EXPORT SensorDisplayWidget : public TQWidget +{ + Q_OBJECT +public: + /** + * Simple sensor information display widget + * @param parent Parent widget for the display widget + */ + SensorDisplayWidget(TQWidget* parent); + virtual ~SensorDisplayWidget(); + + /** + * Set sensor name + * @param name A TQString with the name of the sensor + */ + void setSensorName(TQString name); + + /** + * Set current sensor value + * @param value A double with the current value of the sensor + */ + void setSensorCurrentValue(double value); + + /** + * Set minimum sensor value + * @param value A double with the minimum value of the sensor, < 0 if not supported + */ + void setSensorMinimumValue(double value); + + /** + * Set maximum sensor value + * @param value A double with the maximum value of the sensor, < 0 if not supported + */ + void setSensorMaximumValue(double value); + + /** + * Set warning sensor value + * @param value A double with the warning value of the sensor, < 0 if not supported + */ + void setSensorWarningValue(double value); + + /** + * Set critical sensor value + * @param value A double with the critical value of the sensor, < 0 if not supported + */ + void setSensorCriticalValue(double value); + + /** + * Updates the sensor value display + */ + void updateDisplay(); + +private: + TQLabel* m_nameLabel; + SensorBar* m_progressBar; + + double m_current; + double m_minimum; + double m_maximum; + double m_warning; + double m_critical; +}; + +typedef TQPtrList<SensorDisplayWidget> SensorDisplayWidgetList; +typedef TQMap<TDESystemHibernationMethod::TDESystemHibernationMethod, int> HibernationComboMap; + +/** + * + * Dialog to view and edit hardware device properties + * + * @version 0.1 + * @author Timothy Pearson <[email protected]> + */ + +class TDEUI_EXPORT DevicePropertiesDialog : public KDialogBase +{ + Q_OBJECT +public: + /** + * Create a dialog that allows a user to view and edit hardware device properties + * @param parent Parent widget + */ + DevicePropertiesDialog(TDEGenericDevice* device, TQWidget *parent); + virtual ~DevicePropertiesDialog(); + +protected: + virtual void virtual_hook( int id, void* data ); + +private slots: + void processHardwareRemoved(TDEGenericDevice*); + void processHardwareUpdated(TDEGenericDevice*); + void populateDeviceInformation(); + + void setCPUGovernor(const TQString &); + void setBacklightBrightness(int); + void setHibernationMethod(int); + + void mountDisk(); + void unmountDisk(); + +private: + TDEGenericDevice* m_device; + DevicePropertiesDialogBase* base; + + class DevicePropertiesDialogPrivate; + DevicePropertiesDialogPrivate* d; + + TQGridLayout* m_sensorDataGrid; + SensorDisplayWidgetList m_sensorDataGridWidgets; + + HibernationComboMap m_hibernationComboMap; +}; + +#endif diff --git a/kcontrol/hwmanager/devicepropsdlgbase.ui b/kcontrol/hwmanager/devicepropsdlgbase.ui new file mode 100644 index 000000000..74afdf5f3 --- /dev/null +++ b/kcontrol/hwmanager/devicepropsdlgbase.ui @@ -0,0 +1,1545 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>DevicePropertiesDialogBase</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>DevicePropertiesDialogBase</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQTabWidget" row="0" column="0"> + <property name="name"> + <cstring>tabBarWidget</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabGeneral</cstring> + </property> + <attribute name="title"> + <string>General</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupProps</cstring> + </property> + <property name="title"> + <string>Properties</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Device Type:</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>iconDeviceType</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="2" colspan="1"> + <property name="name"> + <cstring>labelDeviceType</cstring> + </property> + </widget> + <spacer row="0" column="3"> + <property name="name" stdset="0"> + <cstring>Spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>1</height> + </size> + </property> + </spacer> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Device Name:</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="3"> + <property name="name"> + <cstring>labelDeviceName</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Device Node:</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="1" colspan="3"> + <property name="name"> + <cstring>labelDeviceNode</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>System Path:</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" colspan="3"> + <property name="name"> + <cstring>labelSystemPath</cstring> + </property> + </widget> + <widget class="TQLabel" row="4" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Subsystem Type:</string> + </property> + </widget> + <widget class="TQLabel" row="4" column="1" colspan="3"> + <property name="name"> + <cstring>labelSubsytemType</cstring> + </property> + </widget> + <widget class="TQLabel" row="5" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Device Driver:</string> + </property> + </widget> + <widget class="TQLabel" row="5" column="1" colspan="3"> + <property name="name"> + <cstring>labelDeviceDriver</cstring> + </property> + </widget> + <widget class="TQLabel" row="6" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Device Class:</string> + </property> + </widget> + <widget class="TQLabel" row="6" column="1" colspan="3"> + <property name="name"> + <cstring>labelDeviceClass</cstring> + </property> + </widget> + <widget class="TQLabel" row="7" column="0" colspan="1"> + <property name="name"> + <cstring>stocklabelVendorName</cstring> + </property> + <property name="text"> + <string>Manufacturer:</string> + </property> + </widget> + <widget class="TQLabel" row="7" column="1" colspan="3"> + <property name="name"> + <cstring>labelVendorName</cstring> + </property> + </widget> + <widget class="TQLabel" row="8" column="0" colspan="1"> + <property name="name"> + <cstring>stocklabelVendorModel</cstring> + </property> + <property name="text"> + <string>Model:</string> + </property> + </widget> + <widget class="TQLabel" row="8" column="1" colspan="3"> + <property name="name"> + <cstring>labelVendorModel</cstring> + </property> + </widget> + <widget class="TQLabel" row="9" column="0" colspan="1"> + <property name="name"> + <cstring>stocklabelSerialNumber</cstring> + </property> + <property name="text"> + <string>Serial Number:</string> + </property> + </widget> + <widget class="TQLabel" row="9" column="1" colspan="3"> + <property name="name"> + <cstring>labelSerialNumber</cstring> + </property> + </widget> + <widget class="TQLabel" row="10" column="0" colspan="1"> + <property name="name"> + <cstring>stocklabelBusID</cstring> + </property> + <property name="text"> + <string>Bus ID:</string> + </property> + </widget> + <widget class="TQLabel" row="10" column="1" colspan="3"> + <property name="name"> + <cstring>labelBusID</cstring> + </property> + </widget> + <widget class="TQLabel" row="11" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Technical Details:</string> + </property> + </widget> + <widget class="TQLabel" row="11" column="1" colspan="3"> + <property name="name"> + <cstring>labelModalias</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabDisk</cstring> + </property> + <attribute name="title"> + <string>Disk</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupProps</cstring> + </property> + <property name="title"> + <string>Volume Information</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Mountpoint:</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelDiskMountpoint</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Filesystem Type:</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>labelDiskFileSystemType</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Volume UUID:</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="1" colspan="1"> + <property name="name"> + <cstring>labelDiskUUID</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Status:</string> + </property> + <property name="alignment"> + <set>AlignTop|AlignLeft</set> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" colspan="1"> + <property name="name"> + <cstring>labelDiskStatus</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="1" column="0"> + <property name="name"> + <cstring>groupDiskActions</cstring> + </property> + <property name="title"> + <string>Device Actions</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQPushButton" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>buttonDiskMount</cstring> + </property> + <property name="text"> + <string>Mount</string> + </property> + </widget> + <widget class="TQPushButton" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>buttonDiskUnmount</cstring> + </property> + <property name="text"> + <string>Unmount</string> + </property> + </widget> + </grid> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabCPU</cstring> + </property> + <attribute name="title"> + <string>Processor</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupProps</cstring> + </property> + <property name="title"> + <string>Processor Information</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Vendor ID:</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelCPUVendor</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Minimum Frequency:</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>labelMinCPUFrequency</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Current Frequency:</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="1" colspan="1"> + <property name="name"> + <cstring>labelCPUFrequency</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Maximum Frequency:</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" colspan="1"> + <property name="name"> + <cstring>labelMaxCPUFrequency</cstring> + </property> + </widget> + <widget class="TQLabel" row="4" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Scaling Driver:</string> + </property> + </widget> + <widget class="TQLabel" row="4" column="1" colspan="1"> + <property name="name"> + <cstring>labelScalingDriver</cstring> + </property> + </widget> + <widget class="TQLabel" row="5" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Available Frequencies:</string> + </property> + <property name="alignment"> + <set>AlignTop|AlignLeft</set> + </property> + </widget> + <widget class="TQLabel" row="5" column="1" colspan="1"> + <property name="name"> + <cstring>labelScalingFrequencies</cstring> + </property> + </widget> + <widget class="TQLabel" row="6" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Frequency Locked Processor(s):</string> + </property> + <property name="alignment"> + <set>AlignTop|AlignLeft</set> + </property> + </widget> + <widget class="TQLabel" row="6" column="1" colspan="1"> + <property name="name"> + <cstring>labelDependentCPUs</cstring> + </property> + </widget> + <widget class="TQLabel" row="7" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Frequency Policy:</string> + </property> + <property name="alignment"> + <set>AlignTop|AlignLeft</set> + </property> + </widget> + <widget class="KComboBox" row="7" column="1" colspan="1"> + <property name="name"> + <cstring>comboCPUGovernor</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabSensor</cstring> + </property> + <attribute name="title"> + <string>Sensor</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupSensors</cstring> + </property> + <property name="title"> + <string>Sensor Readings</string> + </property> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabBattery</cstring> + </property> + <attribute name="title"> + <string>Battery</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBattery</cstring> + </property> + <property name="title"> + <string>Battery Status</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Current Energy</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelCurrentBatteryEnergy</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Maximum Energy</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>labelMaximumBatteryEnergy</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Maximum Design Energy</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="1" colspan="1"> + <property name="name"> + <cstring>labelMaximumBatteryDesignEnergy</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Minimum Voltage</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" colspan="1"> + <property name="name"> + <cstring>labelMinimumBatteryVoltage</cstring> + </property> + </widget> + <widget class="TQLabel" row="4" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Current Voltage</string> + </property> + </widget> + <widget class="TQLabel" row="4" column="1" colspan="1"> + <property name="name"> + <cstring>labelCurrentBatteryVoltage</cstring> + </property> + </widget> + <widget class="TQLabel" row="5" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Current Charge / Discharge Rate</string> + </property> + </widget> + <widget class="TQLabel" row="5" column="1" colspan="1"> + <property name="name"> + <cstring>labelCurrentBatteryDischargeRate</cstring> + </property> + </widget> + <widget class="TQLabel" row="6" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Status</string> + </property> + </widget> + <widget class="TQLabel" row="6" column="1" colspan="1"> + <property name="name"> + <cstring>labelCurrentBatteryStatus</cstring> + </property> + </widget> + <widget class="TQLabel" row="7" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Technology</string> + </property> + </widget> + <widget class="TQLabel" row="7" column="1" colspan="1"> + <property name="name"> + <cstring>labelBatteryTechnology</cstring> + </property> + </widget> + <widget class="TQLabel" row="8" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Installed</string> + </property> + </widget> + <widget class="TQLabel" row="8" column="1" colspan="1"> + <property name="name"> + <cstring>labelBatteryInstalled</cstring> + </property> + </widget> + <widget class="TQLabel" row="9" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Current Charge</string> + </property> + </widget> + <widget class="TQLabel" row="9" column="1" colspan="1"> + <property name="name"> + <cstring>labelBatteryCharge</cstring> + </property> + </widget> + <widget class="TQLabel" row="10" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Time To Charge / Discharge</string> + </property> + </widget> + <widget class="TQLabel" row="10" column="1" colspan="1"> + <property name="name"> + <cstring>labelBatteryTimeRemaining</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabPowerSupply</cstring> + </property> + <attribute name="title"> + <string>Power Supply</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupPowerSupply</cstring> + </property> + <property name="title"> + <string>Power Supply Status</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Online</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelPowerSupplyOnline</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabNetwork</cstring> + </property> + <attribute name="title"> + <string>Network</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupNetwork</cstring> + </property> + <property name="title"> + <string>Network Device Information</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>MAC Address</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkMAC</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Link State</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkState</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Carrier Detected</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkCarrierPresent</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Dormant</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkDormant</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="1" column="0"> + <property name="name"> + <cstring>groupNetworkAddresses</cstring> + </property> + <property name="title"> + <string>Network Addresses</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>IPv4 Address</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkIPV4Address</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>IPv4 Netmask</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkIPV4Netmask</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>IPv4 Broadcast</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkIPV4Broadcast</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>IPv4 Destination</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkIPV4Destination</cstring> + </property> + </widget> + <widget class="TQLabel" row="4" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>IPv6 Address</string> + </property> + </widget> + <widget class="TQLabel" row="4" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkIPV6Address</cstring> + </property> + </widget> + <widget class="TQLabel" row="5" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>IPv6 Netmask</string> + </property> + </widget> + <widget class="TQLabel" row="5" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkIPV6Netmask</cstring> + </property> + </widget> + <widget class="TQLabel" row="6" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>IPv6 Broadcast</string> + </property> + </widget> + <widget class="TQLabel" row="6" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkIPV6Broadcast</cstring> + </property> + </widget> + <widget class="TQLabel" row="7" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>IPv6 Destination</string> + </property> + </widget> + <widget class="TQLabel" row="7" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkIPV6Destination</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="3" column="0"> + <property name="name"> + <cstring>groupNetworkStatistics</cstring> + </property> + <property name="title"> + <string>Network Statistics</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Received Bytes</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkRXBytes</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Transmitted Bytes</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkTXBytes</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Received Packets</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkRXPackets</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Transmitted Packets</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" colspan="1"> + <property name="name"> + <cstring>labelNetworkTXPackets</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabBacklight</cstring> + </property> + <attribute name="title"> + <string>Backlight</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBacklight</cstring> + </property> + <property name="title"> + <string>Backlight Status</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Status</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelBacklightStatus</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Brightness</string> + </property> + </widget> + <widget class="TQSlider" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>sliderBacklightBrightness</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <widget class="TQLabel" row="1" column="2" colspan="1"> + <property name="name"> + <cstring>labelBacklightBrightness</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabMonitor</cstring> + </property> + <attribute name="title"> + <string>Display</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupMonitor</cstring> + </property> + <property name="title"> + <string>Display Status</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Port Type</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelDisplayPortType</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Connected</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>labelDisplayConnected</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Enabled</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="1" colspan="1"> + <property name="name"> + <cstring>labelDisplayEnabled</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>DPMS Status</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" colspan="1"> + <property name="name"> + <cstring>labelDisplayDPMS</cstring> + </property> + </widget> + <widget class="TQLabel" row="4" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Supported Resolutions</string> + </property> + <property name="alignment"> + <set>AlignTop|AlignLeft</set> + </property> + </widget> + <widget class="TQLabel" row="4" column="1" colspan="1"> + <property name="name"> + <cstring>labelDisplayResolutions</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>labelRandrWarning</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabRootSystem</cstring> + </property> + <attribute name="title"> + <string>System</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupSysinfo</cstring> + </property> + <property name="title"> + <string>System Information</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Form Factor</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelSystemFormFactor</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="1" column="0"> + <property name="name"> + <cstring>groupSystemPower</cstring> + </property> + <property name="title"> + <string>Power Management</string> + </property> + <grid> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Available Power States</string> + </property> + <property name="alignment"> + <set>AlignTop|AlignLeft</set> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelSystemPowerStates</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Hibernation Method</string> + </property> + <property name="alignment"> + <set>AlignTop|AlignLeft</set> + </property> + </widget> + <widget class="KComboBox" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>comboSystemHibernationMethod</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Disk Space Needed to Hibernate</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="1" colspan="1"> + <property name="name"> + <cstring>labelSystemHibernationSpace</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>User Can Request Standby</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" colspan="1"> + <property name="name"> + <cstring>labelSystemUserCanStandby</cstring> + </property> + </widget> + <widget class="TQLabel" row="4" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>User Can Request Freeze</string> + </property> + </widget> + <widget class="TQLabel" row="4" column="1" colspan="1"> + <property name="name"> + <cstring>labelSystemUserCanFreeze</cstring> + </property> + </widget> + <widget class="TQLabel" row="5" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>User Can Request Suspend</string> + </property> + </widget> + <widget class="TQLabel" row="5" column="1" colspan="1"> + <property name="name"> + <cstring>labelSystemUserCanSuspend</cstring> + </property> + </widget> + <widget class="TQLabel" row="6" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>User Can Request Hibernation</string> + </property> + </widget> + <widget class="TQLabel" row="6" column="1" colspan="1"> + <property name="name"> + <cstring>labelSystemUserCanHibernate</cstring> + </property> + </widget> + <widget class="TQLabel" row="7" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>User Can Request Shutdown</string> + </property> + </widget> + <widget class="TQLabel" row="7" column="1" colspan="1"> + <property name="name"> + <cstring>labelSystemUserCanPowerOff</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tabEvent</cstring> + </property> + <attribute name="title"> + <string>Event Input</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupInput</cstring> + </property> + <property name="title"> + <string>Input Status</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Physical Switch Type(s)</string> + </property> + <property name="alignment"> + <set>AlignTop|AlignLeft</set> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>labelEventSwitchTypes</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Active Switch Type(s)</string> + </property> + <property name="alignment"> + <set>AlignTop|AlignLeft</set> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>labelEventSwitchActive</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="8" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + </widget> + </grid> +</widget> +<includes> + <include location="local" impldecl="in implementation">DevicePropertiesDialogBase.ui.h</include> +</includes> +<Q_SLOTS> + <slot>enableSupport_toggled(bool)</slot> +</Q_SLOTS> +<includes> + <include location="local" impldecl="in implementation">kdialog.h</include> +</includes> +<layoutdefaults spacing="3" margin="6"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI> diff --git a/kcontrol/hwmanager/hwmanager.cpp b/kcontrol/hwmanager/hwmanager.cpp new file mode 100644 index 000000000..a82daf1be --- /dev/null +++ b/kcontrol/hwmanager/hwmanager.cpp @@ -0,0 +1,215 @@ +/** + * hwmanager.cpp + * + * Copyright (c) 2009-2010 Timothy Pearson <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <tqcheckbox.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqlineedit.h> +#include <tqpushbutton.h> + +#include <dcopclient.h> + +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <tdeconfig.h> +#include <kcombobox.h> +#include <kdebug.h> +#include <kdialog.h> +#include <tdeglobal.h> +#include <tdelistview.h> +#include <tdelocale.h> +#include <tdemessagebox.h> +#include <tdepopupmenu.h> +#include <kinputdialog.h> +#include <kurlrequester.h> +#include <kgenericfactory.h> + +#include <unistd.h> +#include <ksimpleconfig.h> +#include <string> +#include <stdio.h> +#include <tqstring.h> + +#include "hwmanager.h" + +using namespace std; + +/**** DLL Interface ****/ +typedef KGenericFactory<TDEHWManager, TQWidget> TDEHWManagerFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_hwmanager, TDEHWManagerFactory("kcmhwmanager") ) + +KSimpleConfig *config; +KSimpleConfig *systemconfig; + +/**** TDEHWManager ****/ + +TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringList &) + : 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" )); + + TDEAboutData *about = + new TDEAboutData(I18N_NOOP("kcmhwmanager"), I18N_NOOP("TDE Hardware Device Manager"), + 0, 0, TDEAboutData::License_GPL, + I18N_NOOP("(c) 2012 Timothy Pearson")); + + about->addAuthor("Timothy Pearson", 0, "[email protected]"); + setAboutData( about ); + + base = new TDEHWManagerBase(this); + layout->add(base); + + base->deviceFilter->setListView(base->deviceTree); + + setRootOnlyMsg(i18n("<b>Hardware settings are system wide, and therefore require administrator access</b><br>To alter the system's hardware 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(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*))); + + load(); + + populateTreeView(); +} + +TDEHWManager::~TDEHWManager() +{ + delete config; + delete systemconfig; +} + +void TDEHWManager::load() +{ + load( false ); +} + +void TDEHWManager::load(bool useDefaults ) +{ + emit changed(useDefaults); +} + +void TDEHWManager::save() +{ + emit changed(false); +} + +void TDEHWManager::defaults() +{ + load( true ); +} + +void TDEHWManager::populateTreeView() +{ + bool show_by_connection = base->showByConnection->isChecked(); + + // Figure out which device, if any, was selected + TQString selected_syspath; + DeviceIconItem* selItem = dynamic_cast<DeviceIconItem*>(base->deviceTree->selectedItem()); + if (selItem) { + if (selItem->device()) { + selected_syspath = selItem->device()->systemPath(); + } + } + + base->deviceTree->clear(); + + if (show_by_connection) { + TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); + TDEGenericHardwareList hwlist = hwdevices->listByDeviceClass(TDEGenericDeviceType::RootSystem); + TDEGenericDevice *hwdevice; + for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { + DeviceIconItem* item = new DeviceIconItem(base->deviceTree, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); + if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { + base->deviceTree->ensureItemVisible(item); + base->deviceTree->setSelected(item, true); + } + populateTreeViewLeaf(item, show_by_connection, selected_syspath); + } + } + else { + 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); + TDEGenericDevice *hwdevice; + TDEGenericHardwareList hwlist = hwdevices->listByDeviceClass((TDEGenericDeviceType::TDEGenericDeviceType)i); + for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { + DeviceIconItem* item = new DeviceIconItem(rootitem, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); + if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { + base->deviceTree->ensureItemVisible(item); + base->deviceTree->setSelected(item, true); + } + } + } + } + } +} + +void TDEHWManager::populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_connection, TQString selected_syspath) { + if (show_by_connection) { + TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); + TDEGenericHardwareList hwlist = hwdevices->listAllPhysicalDevices(); + TDEGenericDevice *hwdevice; + for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { + if (hwdevice->parentDevice() == parent->device()) { + DeviceIconItem* item = new DeviceIconItem(parent, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); + if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { + base->deviceTree->ensureItemVisible(item); + base->deviceTree->setSelected(item, true); + } + populateTreeViewLeaf(item, show_by_connection, selected_syspath); + } + } + } +} + +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; + } +} + +TQString TDEHWManager::quickHelp() const +{ + return i18n("<h1>TDE Hardware Device Manager</h1> This module allows you to configure hardware devices on your system"); +} + +#include "hwmanager.moc" diff --git a/kcontrol/hwmanager/hwmanager.desktop b/kcontrol/hwmanager/hwmanager.desktop new file mode 100644 index 000000000..161c331bd --- /dev/null +++ b/kcontrol/hwmanager/hwmanager.desktop @@ -0,0 +1,21 @@ +[Desktop Entry] +Exec=tdecmshell hwmanager +Icon=background +Type=Application +X-DocPath=kcontrol/hwmanager/index.html + +X-TDE-Library=hwmanager +X-TDE-ParentApp=kcontrol +X-TDE-SubstituteUID=true + +Categories=Qt;TDE;X-TDE-settings-hardware; +Comment=Configure hardware devices +Comment[en_US]=Configure hardware devices +GenericName= +GenericName[en_US]= +Keywords=hardware; +MimeType= +Name=Hardware Device Manager +Name[en_US]=Hardware Device Manager + +NoDisplay=false diff --git a/kcontrol/hwmanager/hwmanager.h b/kcontrol/hwmanager/hwmanager.h new file mode 100644 index 000000000..b75a494d9 --- /dev/null +++ b/kcontrol/hwmanager/hwmanager.h @@ -0,0 +1,72 @@ +/** + * hwmanager.h + * + * Copyright (c) 2012 Timothy Pearson <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KCM_HWMANAGER_H +#define _KCM_HWMANAGER_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <tdecmodule.h> +#include <tdelistviewsearchline.h> + +#include <dcopobject.h> + +#include "hwmanagerbase.h" +#include "devicepropsdlg.h" +#include "deviceiconview.h" + +class TDEConfig; +class TDEPopupMenu; +class TDEListViewItem; + +class TDEHWManager : public TDECModule, public DCOPObject +{ + K_DCOP + Q_OBJECT + +public: + //TDEHWManager(TQWidget *parent = 0L, const char *name = 0L); + TDEHWManager(TQWidget *parent, const char *name, const TQStringList &); + virtual ~TDEHWManager(); + + void load(); + void load( bool useDefaults); + void save(); + void defaults(); + + TQString quickHelp() const; + +k_dcop: + +private slots: + void populateTreeView(); + void populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_connection, TQString selected_syspath); + void deviceChanged(TDEGenericDevice*); + +private: + TDEHWManagerBase *base; + + TDEConfig *config; +}; + +#endif + diff --git a/kcontrol/hwmanager/hwmanagerbase.ui b/kcontrol/hwmanager/hwmanagerbase.ui new file mode 100644 index 000000000..47de4caf5 --- /dev/null +++ b/kcontrol/hwmanager/hwmanagerbase.ui @@ -0,0 +1,85 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>TDEHWManagerBase</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>TDEHWManagerBase</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQTabWidget" row="0" column="0"> + <property name="name"> + <cstring>TabWidget2</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>Hardware Devices</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupSystemSettings</cstring> + </property> + <property name="title"> + <string>System Settings</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQCheckBox" row="0" column="0" colspan="4"> + <property name="name"> + <cstring>showByConnection</cstring> + </property> + <property name="text"> + <string>&List devices by connection</string> + </property> + </widget> + <widget class="DeviceIconView" row="1" column="0" colspan="4"> + <property name="name"> + <cstring>deviceTree</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Filter by Name:</string> + </property> + </widget> + <widget class="TDEListViewSearchLine" row="2" column="1" colspan="3"> + <property name="name"> + <cstring>deviceFilter</cstring> + </property> + </widget> + </grid> + </widget> + </grid> + </widget> + </widget> + </grid> +</widget> +<includes> + <include location="local" impldecl="in implementation">TDEHWManagerBase.ui.h</include> + <include location="local" impldecl="in implementation">deviceiconview.h</include> +</includes> +<Q_SLOTS> + <slot>enableSupport_toggled(bool)</slot> +</Q_SLOTS> +<includes> + <include location="local" impldecl="in implementation">kdialog.h</include> +</includes> +<layoutdefaults spacing="3" margin="6"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI> |