From 4c44d87c732a9bd2e2b02278ebd287cd57376a50 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 29 Aug 2012 14:35:32 -0500 Subject: Fix TDEHW library media backend Add PictBridge camera support to same --- kcontrol/hwmanager/devicepropsdlg.cpp | 79 ++++++++++++++++++++++++++++++-- kcontrol/hwmanager/devicepropsdlg.h | 3 ++ kcontrol/hwmanager/devicepropsdlgbase.ui | 57 ++++++++++++++++++++++- 3 files changed, 135 insertions(+), 4 deletions(-) (limited to 'kcontrol/hwmanager') diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp index 784c49b69..ee5ee5981 100644 --- a/kcontrol/hwmanager/devicepropsdlg.cpp +++ b/kcontrol/hwmanager/devicepropsdlg.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "devicepropsdlg.h" @@ -286,6 +287,11 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge 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() ); @@ -370,7 +376,18 @@ void DevicePropertiesDialog::populateDeviceInformation() { if (m_device->type() == TDEGenericDeviceType::Disk) { TDEStorageDevice* sdevice = static_cast(m_device); - base->labelDiskMountpoint->setText(sdevice->mountPath()); + + TQString mountPoint = sdevice->mountPath(); + if (mountPoint == "") mountPoint = i18n(""); + base->labelDiskMountpoint->setText(mountPoint); + + TQString fsName = sdevice->fileSystemName(); + if (fsName == "") fsName = i18n(""); + base->labelDiskFileSystemType->setText(fsName); + + TQString volUUID = sdevice->diskUUID(); + if (volUUID == "") volUUID = i18n(""); + base->labelDiskUUID->setText(volUUID); // Show status TQString status_text = ""; @@ -401,8 +418,15 @@ void DevicePropertiesDialog::populateDeviceInformation() { status_text += ""; base->labelDiskStatus->setText(status_text); - // TODO - // Add mount/unmount buttons + // 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) { @@ -742,6 +766,55 @@ void DevicePropertiesDialog::setHibernationMethod(int value) { populateDeviceInformation(); } +void DevicePropertiesDialog::mountDisk() { + TDEStorageDevice* sdevice = static_cast(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()); + } + TQString optionString; + TQString mountMessages; + TQString mountedPath = sdevice->mountDevice(diskLabel, optionString, &mountMessages); + if (mountedPath.isNull()) { + qerror = i18n("Unable to mount this device.

Potential reasons include:
Improper device and/or user privilege level
Corrupt data on storage device"); + if (!mountMessages.isNull()) { + qerror.append(i18n("

Technical details:
").append(mountMessages)); + } + qerror.append(""); + } + else { + qerror = ""; + } + + if (qerror != "") KMessageBox::error(this, qerror, i18n("Mount Failed")); + + populateDeviceInformation(); +} + +void DevicePropertiesDialog::unmountDisk() { + TDEStorageDevice* sdevice = static_cast(m_device); + + TQString qerror; + TQString unmountMessages; + int unmountRetcode = 0; + if (!sdevice->unmountDevice(&unmountMessages, &unmountRetcode)) { + // Unmount failed! + qerror = "" + i18n("Unfortunately, the device could not be unmounted."); + if (!unmountMessages.isNull()) { + qerror.append(i18n("

Technical details:
").append(unmountMessages)); + } + qerror.append(""); + } + + if (qerror != "") KMessageBox::error(this, qerror, i18n("Unmount Failed")); + + populateDeviceInformation(); +} + void DevicePropertiesDialog::virtual_hook( int id, void* data ) { KDialogBase::virtual_hook( id, data ); } diff --git a/kcontrol/hwmanager/devicepropsdlg.h b/kcontrol/hwmanager/devicepropsdlg.h index 192ebffd4..bbff43977 100644 --- a/kcontrol/hwmanager/devicepropsdlg.h +++ b/kcontrol/hwmanager/devicepropsdlg.h @@ -188,6 +188,9 @@ private slots: void setBacklightBrightness(int); void setHibernationMethod(int); + void mountDisk(); + void unmountDisk(); + private: TDEGenericDevice* m_device; DevicePropertiesDialogBase* base; diff --git a/kcontrol/hwmanager/devicepropsdlgbase.ui b/kcontrol/hwmanager/devicepropsdlgbase.ui index dc328d643..bd3688402 100644 --- a/kcontrol/hwmanager/devicepropsdlgbase.ui +++ b/kcontrol/hwmanager/devicepropsdlgbase.ui @@ -280,6 +280,32 @@ + + unnamed + + + Filesystem Type: + + + + + labelDiskFileSystemType + + + + + unnamed + + + Volume UUID: + + + + + labelDiskUUID + + + unnamed @@ -290,13 +316,42 @@ AlignTop|AlignLeft - + labelDiskStatus + + + groupDiskActions + + + Device Actions + + + + unnamed + + + + buttonDiskMount + + + Mount + + + + + buttonDiskUnmount + + + Unmount + + + + Spacer4 -- cgit v1.2.1