From 5f27e3ead5c7d78075ff7fdcfa7a17c1403c826b Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 6 Apr 2012 19:27:38 -0500 Subject: Enhance device manager module --- kcontrol/hwmanager/CMakeLists.txt | 2 +- kcontrol/hwmanager/devicepropsdlg.cpp | 66 +++------- kcontrol/hwmanager/devicepropsdlg.h | 5 +- kcontrol/hwmanager/devicepropsdlgbase.ui | 209 +++++++++++++++++++++++++++++++ kcontrol/hwmanager/hwmanager.cpp | 35 +++++- kcontrol/hwmanager/hwmanager.h | 6 +- 6 files changed, 262 insertions(+), 61 deletions(-) create mode 100644 kcontrol/hwmanager/devicepropsdlgbase.ui (limited to 'kcontrol/hwmanager') diff --git a/kcontrol/hwmanager/CMakeLists.txt b/kcontrol/hwmanager/CMakeLists.txt index dc1265e49..4973c894f 100644 --- a/kcontrol/hwmanager/CMakeLists.txt +++ b/kcontrol/hwmanager/CMakeLists.txt @@ -33,7 +33,7 @@ set_source_files_properties( hwmanager.cpp PROPERTIES COMPILE_FLAGS -DKDE_CONFDI tde_add_kpart( kcm_hwmanager AUTOMOC SOURCES - hwmanager.cpp deviceiconview.cpp devicepropsdlg.cpp hwmanagerbase.ui hwmanager.skel + hwmanager.cpp deviceiconview.cpp devicepropsdlg.cpp devicepropsdlgbase.ui hwmanagerbase.ui hwmanager.skel LINK kio-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp index 16b01adc9..43892ce8c 100644 --- a/kcontrol/hwmanager/devicepropsdlg.cpp +++ b/kcontrol/hwmanager/devicepropsdlg.cpp @@ -42,62 +42,28 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge enableButtonOK( false ); if (m_device) { + base = new DevicePropertiesDialogBase(plainPage()); + TQGridLayout *mainGrid = new TQGridLayout(plainPage(), 1, 1, 0, spacingHint()); mainGrid->setRowStretch(1, 1); mainGrid->setRowStretch(1, 1); - - TQTabWidget *mainTabs = new TQTabWidget(plainPage()); - - TQWidget *genericPropertiesTab = new TQWidget(this); - - TQGridLayout *generalTabLayout = new TQGridLayout(genericPropertiesTab, 4, 2, 0, spacingHint() ); + mainGrid->addWidget(base, 0, 0); - int row = 0; - TQLabel *label; - label = new TQLabel(i18n("Device Name:"), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 0); - label = new TQLabel(m_device->friendlyName(), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 1); - row++; - label = new TQLabel(i18n("Device Node:"), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 0); - label = new TQLabel(m_device->deviceNode(), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 1); - row++; - label = new TQLabel(i18n("System Path:"), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 0); - label = new TQLabel(m_device->systemPath(), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 1); - row++; - label = new TQLabel(i18n("Subsystem Type:"), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 0); - label = new TQLabel(m_device->subsystem(), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 1); - row++; - label = new TQLabel(i18n("Device Driver:"), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 0); - label = new TQLabel((m_device->deviceDriver().isNull())?i18n(""):m_device->deviceDriver(), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 1); - row++; - label = new TQLabel(i18n("Device Class:"), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 0); - label = new TQLabel((m_device->PCIClass().isNull())?i18n(""):m_device->PCIClass(), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 1); - row++; + base->labelDeviceType->setText(m_device->friendlyDeviceType()); + base->iconDeviceType->setPixmap(m_device->icon(KIcon::SizeSmall)); + base->labelDeviceName->setText(m_device->friendlyName()); + base->labelDeviceNode->setText((m_device->deviceNode().isNull())?i18n(""):m_device->deviceNode()); + base->labelSystemPath->setText(m_device->systemPath()); + base->labelSubsytemType->setText(m_device->subsystem()); + base->labelDeviceDriver->setText((m_device->deviceDriver().isNull())?i18n(""):m_device->deviceDriver()); + base->labelDeviceClass->setText((m_device->PCIClass().isNull())?i18n(""):m_device->PCIClass()); if (m_device->subsystem() == "pci") { - TQString busid = m_device->systemPath(); - busid = busid.remove(0, busid.findRev("/")+1); - busid = busid.remove(0, busid.find(":")+1); - label = new TQLabel(i18n("Bus ID:"), genericPropertiesTab); - generalTabLayout->addWidget(label, row, 0); - label = new TQLabel(busid, genericPropertiesTab); - generalTabLayout->addWidget(label, row, 1); - row++; + base->labelBusID->setText(m_device->busID()); + } + else { + base->labelBusID->hide(); + base->stocklabelBusID->hide(); } - - mainTabs->addTab(genericPropertiesTab, i18n("&General")); - - mainGrid->addWidget(mainTabs, 0, 0); } } diff --git a/kcontrol/hwmanager/devicepropsdlg.h b/kcontrol/hwmanager/devicepropsdlg.h index 30c69b1a7..d6ef07b03 100644 --- a/kcontrol/hwmanager/devicepropsdlg.h +++ b/kcontrol/hwmanager/devicepropsdlg.h @@ -19,12 +19,12 @@ #ifndef __devicepropsdlg_h__ #define __devicepropsdlg_h__ -// #include - #include #include +#include "devicepropsdlgbase.h" + /** * * Dialog to view and edit hardware device properties @@ -49,6 +49,7 @@ protected: private: TDEGenericDevice* m_device; + DevicePropertiesDialogBase* base; class DevicePropertiesDialogPrivate; DevicePropertiesDialogPrivate* d; diff --git a/kcontrol/hwmanager/devicepropsdlgbase.ui b/kcontrol/hwmanager/devicepropsdlgbase.ui new file mode 100644 index 000000000..e55b8dd40 --- /dev/null +++ b/kcontrol/hwmanager/devicepropsdlgbase.ui @@ -0,0 +1,209 @@ + +DevicePropertiesDialogBase + + + DevicePropertiesDialogBase + + + + 0 + 0 + 519 + 356 + + + + + unnamed + + + + TabWidget2 + + + true + + + + tab + + + General + + + + unnamed + + + + groupProps + + + Properties + + + + unnamed + + + + unnamed + + + Device Type: + + + + + iconDeviceType + + + + + labelDeviceType + + + + + Spacer1 + + + Horizontal + + + Expanding + + + + 20 + 1 + + + + + + unnamed + + + Device Name: + + + + + labelDeviceName + + + + + unnamed + + + Device Node: + + + + + labelDeviceNode + + + + + unnamed + + + System Path: + + + + + labelSystemPath + + + + + unnamed + + + Subsystem Type: + + + + + labelSubsytemType + + + + + unnamed + + + Device Driver: + + + + + labelDeviceDriver + + + + + unnamed + + + Device Class: + + + + + labelDeviceClass + + + + + stocklabelBusID + + + Bus ID: + + + + + labelBusID + + + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + DevicePropertiesDialogBase.ui.h + + + enableSupport_toggled(bool) + + + kdialog.h + + + + diff --git a/kcontrol/hwmanager/hwmanager.cpp b/kcontrol/hwmanager/hwmanager.cpp index 049460d17..cf39b579a 100644 --- a/kcontrol/hwmanager/hwmanager.cpp +++ b/kcontrol/hwmanager/hwmanager.cpp @@ -125,6 +125,15 @@ 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(base->deviceTree->selectedItem()); + if (selItem) { + if (selItem->device()) { + selected_syspath = selItem->device()->systemPath(); + } + } + base->deviceTree->clear(); if (show_by_connection) { @@ -135,25 +144,37 @@ void TDEHWManager::populateTreeView() TDEGenericDevice *hwdevice; for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { DeviceIconItem* item = new DeviceIconItem(rootitem, hwdevice->friendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); - populateTreeViewLeaf(item, show_by_connection); + 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 = KGlobal::hardwareDevices(); for (int i=0;i<=TDEGenericDeviceType::Last;i++) { if (i != TDEGenericDeviceType::Root) { - DeviceIconItem* item = new DeviceIconItem(base->deviceTree, hwdevices->getFriendlyDeviceTypeStringFromType((TDEGenericDeviceType::TDEGenericDeviceType)i), hwdevices->getDeviceTypeIconFromType((TDEGenericDeviceType::TDEGenericDeviceType)i, base->deviceTree->iconSize()), 0); + DeviceIconItem* rootitem = new DeviceIconItem(base->deviceTree, hwdevices->getFriendlyDeviceTypeStringFromType((TDEGenericDeviceType::TDEGenericDeviceType)i), hwdevices->getDeviceTypeIconFromType((TDEGenericDeviceType::TDEGenericDeviceType)i, base->deviceTree->iconSize()), 0); TDEGenericDevice *hwdevice; TDEGenericHardwareList hwlist = hwdevices->listByDeviceClass((TDEGenericDeviceType::TDEGenericDeviceType)i); for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { - new DeviceIconItem(item, hwdevice->friendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); + DeviceIconItem* item = new DeviceIconItem(rootitem, hwdevice->friendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); + if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { + base->deviceTree->ensureItemVisible(item); + base->deviceTree->setSelected(item, true); + } } } } } + + if (!selected_syspath.isNull()) { + + } } -void TDEHWManager::populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_connection) { +void TDEHWManager::populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_connection, TQString selected_syspath) { if (show_by_connection) { TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices(); TDEGenericHardwareList hwlist = hwdevices->listAllPhysicalDevices(); @@ -161,7 +182,11 @@ void TDEHWManager::populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_con for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { if (hwdevice->parentDevice() == parent->device()) { DeviceIconItem* item = new DeviceIconItem(parent, hwdevice->friendlyName(), hwdevices->getDeviceTypeIconFromType(hwdevice->type(), base->deviceTree->iconSize()), hwdevice); - populateTreeViewLeaf(item, show_by_connection); + if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { + base->deviceTree->ensureItemVisible(item); + base->deviceTree->setSelected(item, true); + } + populateTreeViewLeaf(item, show_by_connection, selected_syspath); } } } diff --git a/kcontrol/hwmanager/hwmanager.h b/kcontrol/hwmanager/hwmanager.h index c8b7053df..dfa972b50 100644 --- a/kcontrol/hwmanager/hwmanager.h +++ b/kcontrol/hwmanager/hwmanager.h @@ -47,8 +47,6 @@ public: TDEHWManager(TQWidget *parent, const char *name, const TQStringList &); virtual ~TDEHWManager(); - TDEHWManagerBase *base; - void load(); void load( bool useDefaults); void save(); @@ -61,9 +59,11 @@ k_dcop: private slots: void populateTreeView(); - void populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_connection); + void populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_connection, TQString selected_syspath); private: + TDEHWManagerBase *base; + KConfig *config; }; -- cgit v1.2.1