summaryrefslogtreecommitdiffstats
path: root/kcontrol/hwmanager
diff options
context:
space:
mode:
Diffstat (limited to 'kcontrol/hwmanager')
-rw-r--r--kcontrol/hwmanager/CMakeLists.txt10
-rw-r--r--kcontrol/hwmanager/cryptpassworddlg.cpp12
-rw-r--r--kcontrol/hwmanager/cryptpassworddlg.h2
-rw-r--r--kcontrol/hwmanager/cryptpassworddlgbase.ui4
-rw-r--r--kcontrol/hwmanager/deviceiconview.cpp9
-rw-r--r--kcontrol/hwmanager/deviceiconview.h22
-rw-r--r--kcontrol/hwmanager/devicepropsdlg.cpp239
-rw-r--r--kcontrol/hwmanager/devicepropsdlg.h21
-rw-r--r--kcontrol/hwmanager/devicepropsdlgbase.ui51
-rw-r--r--kcontrol/hwmanager/hwdevicetray.cpp786
-rw-r--r--kcontrol/hwmanager/hwdevicetray.h72
-rw-r--r--kcontrol/hwmanager/hwdevicetray_app.cpp4
-rw-r--r--kcontrol/hwmanager/hwdevicetray_app.h6
-rw-r--r--kcontrol/hwmanager/hwdevicetray_bindings.cpp3
-rw-r--r--kcontrol/hwmanager/hwdevicetray_configdialog.h2
-rw-r--r--kcontrol/hwmanager/hwdevicetray_main.cpp9
-rw-r--r--kcontrol/hwmanager/hwmanager.cpp77
-rw-r--r--kcontrol/hwmanager/hwmanager.h8
-rw-r--r--kcontrol/hwmanager/hwmanagerbase.ui4
-rw-r--r--kcontrol/hwmanager/passworddlg.cpp66
-rw-r--r--kcontrol/hwmanager/passworddlg.h62
-rw-r--r--kcontrol/hwmanager/unlockdialog.ui160
22 files changed, 1199 insertions, 430 deletions
diff --git a/kcontrol/hwmanager/CMakeLists.txt b/kcontrol/hwmanager/CMakeLists.txt
index be8d3f2cb..d48e65320 100644
--- a/kcontrol/hwmanager/CMakeLists.txt
+++ b/kcontrol/hwmanager/CMakeLists.txt
@@ -48,8 +48,8 @@ set_property( SOURCE hwmanager.cpp APPEND PROPERTY COMPILE_DEFINITIONS KDE_CONFD
tde_add_kpart( kcm_hwmanager AUTOMOC
SOURCES
hwmanager.cpp deviceiconview.cpp devicepropsdlg.cpp devicepropsdlgbase.ui hwmanagerbase.ui
- cryptpassworddlg.cpp cryptpassworddlgbase.ui hwmanager.skel
- LINK tdeio-shared
+ cryptpassworddlg.cpp unlockdialog.ui passworddlg.cpp cryptpassworddlgbase.ui hwmanager.skel
+ LINK tdeio-shared ${TDEHW_LIBRARIES}
DESTINATION ${PLUGIN_INSTALL_DIR}
)
@@ -58,7 +58,7 @@ tde_add_kpart( kcm_hwmanager AUTOMOC
tde_add_executable( tdehwdevicetray AUTOMOC
SOURCES
hwdevicetray_main.cpp hwdevicetray.cpp hwdevicetray_app.cpp
- hwdevicetray_configdialog.cpp
- LINK tdeio-shared tdeutils-shared tdeui-shared
+ hwdevicetray_configdialog.cpp unlockdialog.ui passworddlg.cpp
+ LINK tdeio-shared tdeutils-shared tdeui-shared ${TDEHW_LIBRARIES}
DESTINATION ${BIN_INSTALL_DIR}
-) \ No newline at end of file
+)
diff --git a/kcontrol/hwmanager/cryptpassworddlg.cpp b/kcontrol/hwmanager/cryptpassworddlg.cpp
index b0f0e1cd8..eb9d23090 100644
--- a/kcontrol/hwmanager/cryptpassworddlg.cpp
+++ b/kcontrol/hwmanager/cryptpassworddlg.cpp
@@ -31,7 +31,7 @@
#include <tqpainter.h>
#include <tqstyle.h>
#include <tqfile.h>
-#include <tqinternal_p.h>
+#include <private/tqinternal_p.h>
#undef Unsorted // Required for --enable-final (tqdir.h)
#include <tqfiledialog.h>
@@ -73,11 +73,11 @@ CryptPasswordDialog::CryptPasswordDialog(TQWidget *parent, TQString passwordProm
}
}
- connect(m_base->textPasswordButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
- connect(m_base->filePasswordButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
- connect(m_base->cardKeyButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
- connect(m_base->textPasswordEntry, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts()));
- connect(m_base->filePasswordURL, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts()));
+ connect(m_base->textPasswordButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(processLockouts()));
+ connect(m_base->filePasswordButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(processLockouts()));
+ connect(m_base->cardKeyButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(processLockouts()));
+ connect(m_base->textPasswordEntry, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(processLockouts()));
+ connect(m_base->filePasswordURL, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(processLockouts()));
m_base->textPasswordEntry->setFocus();
diff --git a/kcontrol/hwmanager/cryptpassworddlg.h b/kcontrol/hwmanager/cryptpassworddlg.h
index d595c4a73..f155df968 100644
--- a/kcontrol/hwmanager/cryptpassworddlg.h
+++ b/kcontrol/hwmanager/cryptpassworddlg.h
@@ -35,7 +35,7 @@ class KSSLCertificate;
class TDEUI_EXPORT CryptPasswordDialog : public KDialogBase
{
- Q_OBJECT
+ TQ_OBJECT
public:
/**
* Create a dialog that allows a user to enter LUKS passwords or password files
diff --git a/kcontrol/hwmanager/cryptpassworddlgbase.ui b/kcontrol/hwmanager/cryptpassworddlgbase.ui
index f7a6a70a7..2c3a425a8 100644
--- a/kcontrol/hwmanager/cryptpassworddlgbase.ui
+++ b/kcontrol/hwmanager/cryptpassworddlgbase.ui
@@ -137,9 +137,9 @@
<includes>
<include location="local" impldecl="in implementation">CryptPasswordDialogBase.ui.h</include>
</includes>
- <Q_SLOTS>
+ <slots>
<slot>enableSupport_toggled(bool)</slot>
- </Q_SLOTS>
+ </slots>
<includes>
<include location="global" impldecl="in implementation">kdialog.h</include>
<include location="global" impldecl="in implementation">kpassdlg.h</include>
diff --git a/kcontrol/hwmanager/deviceiconview.cpp b/kcontrol/hwmanager/deviceiconview.cpp
index 7ccb93daf..3ad111378 100644
--- a/kcontrol/hwmanager/deviceiconview.cpp
+++ b/kcontrol/hwmanager/deviceiconview.cpp
@@ -22,7 +22,7 @@
#include <tqcursor.h>
#include <tdelocale.h>
-#include <kstandarddirs.h>
+#include <tdestandarddirs.h>
#include <kservicegroup.h>
#include <kiconloader.h>
#include <tdemessagebox.h>
@@ -43,8 +43,8 @@ DeviceIconView::DeviceIconView(TQWidget * parent, const char * name)
header()->hide();
- connect(this, TQT_SIGNAL(clicked(TQListViewItem*)), this, TQT_SLOT(slotItemSelected(TQListViewItem*)));
- connect(this, TQT_SIGNAL(executed(TQListViewItem*)), this, TQT_SLOT(slotItemDoubleClicked(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(clicked(TQListViewItem*)), this, TQ_SLOT(slotItemSelected(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(executed(TQListViewItem*)), this, TQ_SLOT(slotItemDoubleClicked(TQListViewItem*)));
}
void DeviceIconView::slotItemSelected(TQListViewItem* item)
@@ -73,7 +73,8 @@ void DeviceIconView::slotItemDoubleClicked(TQListViewItem* item)
delete propsDlg;
}
else {
- KMessageBox::sorry(this, "Detailed information is not available for this device", "Information Unavailable");
+ KMessageBox::sorry(this, i18n("Detailed information is not available for this device"),
+ i18n("Information Unavailable"));
}
}
diff --git a/kcontrol/hwmanager/deviceiconview.h b/kcontrol/hwmanager/deviceiconview.h
index 913c4c9ef..6460beb0a 100644
--- a/kcontrol/hwmanager/deviceiconview.h
+++ b/kcontrol/hwmanager/deviceiconview.h
@@ -32,36 +32,30 @@ class ConfigModuleList;
class DeviceIconItem : public TDEListViewItem
{
public:
- DeviceIconItem(TQListViewItem *parent, const TQString& text, const TQPixmap& pm, TDEGenericDevice *d = 0)
+ DeviceIconItem(TQListViewItem *parent, const TQString& text, const TQPixmap& pm, TQString deviceUid)
: TDEListViewItem(parent, text)
- , _tag(TQString::null)
- , _device(d)
+ , _deviceUid(deviceUid)
{
setPixmap(0, pm);
}
- DeviceIconItem(TQListView *parent, const TQString& text, const TQPixmap& pm, TDEGenericDevice *d = 0)
+ DeviceIconItem(TQListView *parent, const TQString& text, const TQPixmap& pm, TQString deviceUid)
: TDEListViewItem(parent, text)
- , _tag(TQString::null)
- , _device(d)
+ , _deviceUid(deviceUid)
{
setPixmap(0, pm);
}
- void setDevice(TDEGenericDevice* d) { _device = d; }
- void setTag(const TQString& t) { _tag = t; }
+ void setDevice(TQString deviceUid) { _deviceUid = deviceUid; }
- TDEGenericDevice* device() { return _device; }
- TQString tag() { return _tag; }
-
+ TDEGenericDevice* device() { return TDEGlobal::hardwareDevices()->findByUniqueID(_deviceUid); }
private:
- TQString _tag;
- TDEGenericDevice *_device;
+ TQString _deviceUid; // device unique id
};
class DeviceIconView : public TDEListView
{
- Q_OBJECT
+ TQ_OBJECT
public:
DeviceIconView(TQWidget * parent = 0, const char * name = 0);
diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp
index 18ac13f7a..5770c8d97 100644
--- a/kcontrol/hwmanager/devicepropsdlg.cpp
+++ b/kcontrol/hwmanager/devicepropsdlg.cpp
@@ -28,7 +28,10 @@
#include <tqslider.h>
#include <tqpainter.h>
#include <tqstyle.h>
-#include <tqinternal_p.h>
+#include <private/tqinternal_p.h>
+#include <tdeprocess.h>
+#include <dcopclient.h>
+#include <dcopref.h>
#undef Unsorted // Required for --enable-final (tqdir.h)
#include <tqfiledialog.h>
@@ -45,6 +48,7 @@
#include <ksslcertificate.h>
#include "cryptpassworddlg.h"
+#include "passworddlg.h"
#include "devicepropsdlg.h"
@@ -295,16 +299,20 @@ 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 &)));
+ connect(base->comboCPUGovernor, TQ_SIGNAL(activated(const TQString &)), this, TQ_SLOT(setCPUGovernor(const TQString &)));
}
if (m_device->type() == TDEGenericDeviceType::Disk) {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- connect(base->buttonDiskMount, TQT_SIGNAL(clicked()), this, TQT_SLOT(mountDisk()));
- connect(base->buttonDiskUnmount, TQT_SIGNAL(clicked()), this, TQT_SLOT(unmountDisk()));
+ connect(base->buttonDiskMount, TQ_SIGNAL(clicked()), this, TQ_SLOT(mountDisk()));
+ connect(base->buttonDiskUnmount, TQ_SIGNAL(clicked()), this, TQ_SLOT(unmountDisk()));
+ connect(base->buttonDiskUnlock, TQ_SIGNAL(clicked()), this, TQ_SLOT(unlockDisk()));
+ connect(base->buttonDiskLock, TQ_SIGNAL(clicked()), this, TQ_SLOT(lockDisk()));
+ connect(base->buttonDiskEject, TQ_SIGNAL(clicked()), this, TQ_SLOT(ejectDisk()));
+ connect(base->buttonDiskSafeRemove, TQ_SIGNAL(clicked()), this, TQ_SLOT(safeRemoveDisk()));
if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- connect(base->cryptLUKSAddKey, TQT_SIGNAL(clicked()), this, TQT_SLOT(cryptLUKSAddKey()));
- connect(base->cryptLUKSDelKey, TQT_SIGNAL(clicked()), this, TQT_SLOT(cryptLUKSDelKey()));
- connect(base->cryptLUKSKeySlotList, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(processLockouts()));
+ connect(base->cryptLUKSAddKey, TQ_SIGNAL(clicked()), this, TQ_SLOT(cryptLUKSAddKey()));
+ connect(base->cryptLUKSDelKey, TQ_SIGNAL(clicked()), this, TQ_SLOT(cryptLUKSDelKey()));
+ connect(base->cryptLUKSKeySlotList, TQ_SIGNAL(selectionChanged()), this, TQ_SLOT(processLockouts()));
base->cryptLUKSKeySlotList->setAllColumnsShowFocus(true);
base->cryptLUKSKeySlotList->setFullWidth(true);
cryptLUKSPopulateList();
@@ -324,10 +332,10 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge
m_sensorDataGridWidgets.setAutoDelete(true);
}
if (m_device->type() == TDEGenericDeviceType::Backlight) {
- connect(base->sliderBacklightBrightness, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setBacklightBrightness(int)));
+ connect(base->sliderBacklightBrightness, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(setBacklightBrightness(int)));
}
if (m_device->type() == TDEGenericDeviceType::RootSystem) {
- connect(base->comboSystemHibernationMethod, TQT_SIGNAL(activated(int)), this, TQT_SLOT(setHibernationMethod(int)));
+ connect(base->comboSystemHibernationMethod, TQ_SIGNAL(activated(int)), this, TQ_SLOT(setHibernationMethod(int)));
}
TQGridLayout *mainGrid = new TQGridLayout(plainPage(), 1, 1, 0, spacingHint());
@@ -337,8 +345,8 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge
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*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(processHardwareRemoved(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQ_SLOT(processHardwareUpdated(TDEGenericDevice*)));
populateDeviceInformation();
}
@@ -367,7 +375,49 @@ static TQString formatDisplayString(TQString input) {
return TQStyleSheet::escape(input);
}
-void DevicePropertiesDialog::populateDeviceInformation() {
+bool DevicePropertiesDialog::isMonitoredDevice(TDEStorageDevice *sdevice)
+{
+ // Type selection logic largely duplicated from the media manager tdeioslave
+ return ((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden) &&
+ (sdevice->isDiskOfType(TDEDiskDeviceType::HDD) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDMO) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRWW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRAM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRWDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRWDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDVideo) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Floppy) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Zip) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Jaz) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Camera)));
+}
+
+void DevicePropertiesDialog::populateDeviceInformation()
+{
if (m_device) {
base->labelDeviceType->setText(m_device->friendlyDeviceType());
base->iconDeviceType->setPixmap(m_device->icon(TDEIcon::SizeSmall));
@@ -416,48 +466,88 @@ void DevicePropertiesDialog::populateDeviceInformation() {
if (volUUID == "") volUUID = i18n("<none>");
base->labelDiskUUID->setText(formatDisplayString(volUUID));
+ TQString mappedName = sdevice->mappedName();
+ if (mappedName == "") mappedName = i18n("<none>");
+ base->labelMappedName->setText(formatDisplayString(mappedName));
+
// Show status
TQString status_text = "<qt>";
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable)) {
- status_text += "Mountable<br>";
+ status_text += i18n("Mountable") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) {
- status_text += "Removable<br>";
+ status_text += i18n("Removable") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Inserted)) {
- status_text += "Inserted<br>";
+ status_text += i18n("Inserted") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
- status_text += "Blank<br>";
+ status_text += i18n("Blank") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)) {
- status_text += "In use<br>";
+ status_text += i18n("In use") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsesDevice)) {
- status_text += "Uses other device<br>";
+ status_text += i18n("Uses other device") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem)) {
- status_text += "Contains a filesystem<br>";
- }
- if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) {
- status_text += "Hotpluggable<br>";
+ status_text += i18n("Contains a filesystem") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden)) {
- status_text += "Hidden<br>";
+ status_text += i18n("Hidden") + "<br>";
}
if (status_text == "<qt>") {
- status_text += "<i>Unavailable</i>";
+ status_text += "<i>" + i18n("Unknown") + "</i>";
}
status_text += "</qt>";
base->labelDiskStatus->setText(status_text);
- // Update mount/unmount button status
- if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable)) {
- base->groupDiskActions->show();
+ // Update action button status
+ base->buttonDiskMount->setEnabled(false);
+ base->buttonDiskUnmount->setEnabled(false);
+ base->buttonDiskUnlock->setEnabled(false);
+ base->buttonDiskLock->setEnabled(false);
+ base->buttonDiskEject->setEnabled(false);
+ base->buttonDiskSafeRemove->setEnabled(false);
+ base->buttonDiskMount->setHidden(true);
+ base->buttonDiskUnmount->setHidden(true);
+ base->buttonDiskUnlock->setHidden(true);
+ base->buttonDiskLock->setHidden(true);
+ base->buttonDiskEject->setHidden(true);
+ base->buttonDiskSafeRemove->setHidden(true);
+ bool showGroup = false;
+ if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable))
+ {
base->buttonDiskMount->setEnabled((sdevice->mountPath() == ""));
base->buttonDiskUnmount->setEnabled((sdevice->mountPath() != ""));
+ base->buttonDiskMount->setHidden(false);
+ base->buttonDiskUnmount->setHidden(false);
+ showGroup = true;
}
- else {
+ else if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted))
+ {
+ base->buttonDiskUnlock->setEnabled(!sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt));
+ base->buttonDiskLock->setEnabled(sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt));
+ base->buttonDiskUnlock->setHidden(false);
+ base->buttonDiskLock->setHidden(false);
+ showGroup = true;
+ }
+ if (isMonitoredDevice(sdevice) &&
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable))
+ {
+ base->buttonDiskEject->setEnabled(true);
+ base->buttonDiskSafeRemove->setEnabled(true);
+ base->buttonDiskEject->setHidden(false);
+ base->buttonDiskSafeRemove->setHidden(false);
+ showGroup = true;
+ }
+ if (showGroup)
+ {
+ base->groupDiskActions->show();
+ }
+ else
+ {
base->groupDiskActions->hide();
}
}
@@ -659,7 +749,7 @@ void DevicePropertiesDialog::populateDeviceInformation() {
}
// 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>");
+ base->labelRandrWarning->setText(i18n("<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) {
@@ -791,8 +881,8 @@ void DevicePropertiesDialog::populateDeviceInformation() {
if (m_device->type() == TDEGenericDeviceType::CryptographicCard) {
TDECryptographicCardDevice* cdevice = static_cast<TDECryptographicCardDevice*>(m_device);
- connect(cdevice, TQT_SIGNAL(cardInserted(TDECryptographicCardDevice*)), this, TQT_SLOT(cryptographicCardInserted()));
- connect(cdevice, TQT_SIGNAL(cardRemoved(TDECryptographicCardDevice*)), this, TQT_SLOT(cryptographicCardRemoved()));
+ connect(cdevice, TQ_SIGNAL(cardInserted(TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardInserted()));
+ connect(cdevice, TQ_SIGNAL(cardRemoved(TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardRemoved()));
updateCryptographicCardStatusDisplay();
}
@@ -879,49 +969,74 @@ void DevicePropertiesDialog::setHibernationMethod(int value) {
void DevicePropertiesDialog::mountDisk() {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- TQString qerror;
- TQString diskLabel = sdevice->diskLabel();
- if (diskLabel.isNull()) {
- diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize());
+
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-m" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
}
- TDEStorageMountOptions mountOptions;
- TQStringVariantMap mountResult = sdevice->mountDevice(diskLabel, mountOptions);
- TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
- if (mountedPath.isEmpty()) {
- 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");
- TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
- if (!errStr.isEmpty()) {
- qerror.append(i18n("<p>Technical details:<br>").append(errStr));
- }
- qerror.append("</qt>");
+}
+
+void DevicePropertiesDialog::unmountDisk() {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
+
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-u" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
}
- else {
- qerror = "";
+}
+
+void DevicePropertiesDialog::unlockDisk() {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
+
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-k" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
}
+}
- if (qerror != "") KMessageBox::error(this, qerror, i18n("Mount Failed"));
+void DevicePropertiesDialog::lockDisk() {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- populateDeviceInformation();
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-l" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
+ }
}
-void DevicePropertiesDialog::unmountDisk() {
+void DevicePropertiesDialog::ejectDisk() {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- TQString qerror;
- TQStringVariantMap unmountResult = sdevice->unmountDevice();
- if (unmountResult["result"].toBool() == false) {
- // Unmount failed!
- qerror = "<qt>" + i18n("Unfortunately, the device could not be unmounted.");
- TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
- if (!errStr.isEmpty()) {
- qerror.append(i18n("<p>Technical details:<br>").append(errStr));
- }
- qerror.append("</qt>");
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-e" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
}
+}
- if (qerror != "") KMessageBox::error(this, qerror, i18n("Unmount Failed"));
+void DevicePropertiesDialog::safeRemoveDisk() {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- populateDeviceInformation();
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-s" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
+ }
}
void DevicePropertiesDialog::cryptLUKSAddKey() {
diff --git a/kcontrol/hwmanager/devicepropsdlg.h b/kcontrol/hwmanager/devicepropsdlg.h
index e958d39ba..e961e689f 100644
--- a/kcontrol/hwmanager/devicepropsdlg.h
+++ b/kcontrol/hwmanager/devicepropsdlg.h
@@ -20,13 +20,13 @@
#define __devicepropsdlg_h__
#include <tqprogressbar.h>
-
#include <kdialogbase.h>
-
#include <tdehardwaredevices.h>
#include "devicepropsdlgbase.h"
+class PasswordDlg;
+
/**
*
* Simple sensor name and text label value display widget
@@ -37,7 +37,7 @@
class TDEUI_EXPORT SensorDisplayLabelsWidget : public TQWidget
{
- Q_OBJECT
+ TQ_OBJECT
public:
/**
* Create a simple sensor name and value display widget
@@ -65,7 +65,7 @@ private:
class TDEUI_EXPORT SensorBar : public TQProgressBar
{
- Q_OBJECT
+ TQ_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) {}
@@ -93,7 +93,7 @@ public:
class TDEUI_EXPORT SensorDisplayWidget : public TQWidget
{
- Q_OBJECT
+ TQ_OBJECT
public:
/**
* Simple sensor information display widget
@@ -167,7 +167,7 @@ typedef TQMap<TDESystemHibernationMethod::TDESystemHibernationMethod, int> Hiber
class TDEUI_EXPORT DevicePropertiesDialog : public KDialogBase
{
- Q_OBJECT
+ TQ_OBJECT
public:
/**
* Create a dialog that allows a user to view and edit hardware device properties
@@ -190,6 +190,10 @@ private slots:
void mountDisk();
void unmountDisk();
+ void unlockDisk();
+ void lockDisk();
+ void ejectDisk();
+ void safeRemoveDisk();
void cryptLUKSAddKey();
void cryptLUKSDelKey();
@@ -202,12 +206,11 @@ private slots:
void processLockouts();
private:
+ static bool isMonitoredDevice(TDEStorageDevice *sdevice);
+
TDEGenericDevice* m_device;
DevicePropertiesDialogBase* base;
- class DevicePropertiesDialogPrivate;
- DevicePropertiesDialogPrivate* d;
-
TQGridLayout* m_sensorDataGrid;
SensorDisplayWidgetList m_sensorDataGridWidgets;
diff --git a/kcontrol/hwmanager/devicepropsdlgbase.ui b/kcontrol/hwmanager/devicepropsdlgbase.ui
index 48fcf7d75..dce403fe7 100644
--- a/kcontrol/hwmanager/devicepropsdlgbase.ui
+++ b/kcontrol/hwmanager/devicepropsdlgbase.ui
@@ -302,13 +302,26 @@
<cstring>unnamed</cstring>
</property>
<property name="text">
+ <string>Mapped name:</string>
+ </property>
+ </widget>
+ <widget class="KActiveLabel" row="3" column="1" colspan="1">
+ <property name="name">
+ <cstring>labelMappedName</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="4" 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="KActiveLabel" row="3" column="1" colspan="1">
+ <widget class="KActiveLabel" row="4" column="1" colspan="1">
<property name="name">
<cstring>labelDiskStatus</cstring>
</property>
@@ -342,6 +355,38 @@
<string>Unmount</string>
</property>
</widget>
+ <widget class="KPushButton" row="0" column="0" colspan="1">
+ <property name="name">
+ <cstring>buttonDiskUnlock</cstring>
+ </property>
+ <property name="text">
+ <string>Unlock</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="0" column="1" colspan="1">
+ <property name="name">
+ <cstring>buttonDiskLock</cstring>
+ </property>
+ <property name="text">
+ <string>Lock</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="1" column="0" colspan="1">
+ <property name="name">
+ <cstring>buttonDiskEject</cstring>
+ </property>
+ <property name="text">
+ <string>Eject</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="1" column="1" colspan="1">
+ <property name="name">
+ <cstring>buttonDiskSafeRemove</cstring>
+ </property>
+ <property name="text">
+ <string>Safe Remove</string>
+ </property>
+ </widget>
</grid>
</widget>
<spacer row="8" column="0">
@@ -1714,9 +1759,9 @@
<includes>
<include location="local" impldecl="in implementation">DevicePropertiesDialogBase.ui.h</include>
</includes>
-<Q_SLOTS>
+<slots>
<slot>enableSupport_toggled(bool)</slot>
-</Q_SLOTS>
+</slots>
<includes>
<include location="global" impldecl="in implementation">kactivelabel.h</include>
<include location="global" impldecl="in implementation">kcombobox.h</include>
diff --git a/kcontrol/hwmanager/hwdevicetray.cpp b/kcontrol/hwmanager/hwdevicetray.cpp
index 18ef3d5e9..f1726a2a1 100644
--- a/kcontrol/hwmanager/hwdevicetray.cpp
+++ b/kcontrol/hwmanager/hwdevicetray.cpp
@@ -1,8 +1,8 @@
/*
* Copyright 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
- *
+ *
* This file is part of hwdevicetray, the TDE Hardware Device Monitor System Tray Application
- *
+ *
* hwdevicetray 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 3
@@ -17,55 +17,148 @@
* License along with cryptocardwatcher. If not, see http://www.gnu.org/licenses/.
*/
-#include <tqtimer.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cstdlib>
+#include <unistd.h>
+
+#include <tqfileinfo.h>
#include <tqimage.h>
+#include <tqtimer.h>
#include <tqtooltip.h>
-#include <tqfileinfo.h>
+#include <tqvaluevector.h>
+#include <kcmultidialog.h>
+#include <tdeglobalaccel.h>
+#include <khelpmenu.h>
+#include "tdeprocess.h"
+#include <kpropertiesdialog.h>
#include <krun.h>
+#include <tdesimpleconfig.h>
+#include <tdestandarddirs.h>
+
#include <tdeaction.h>
#include <tdeapplication.h>
-#include <kcmultidialog.h>
-#include <kdebug.h>
-#include <khelpmenu.h>
-#include <kiconloader.h>
-#include <tdelocale.h>
-#include <tdepopupmenu.h>
-#include <kstdaction.h>
-#include <kstdguiitem.h>
#include <tdeglobal.h>
+#include <tdehardwaredevices.h>
+#include <tdelocale.h>
#include <tdemessagebox.h>
-#include <kpassivepopup.h>
-#include <kstandarddirs.h>
+#include "tdepassivepopupstack.h"
+#include <tdepopupmenu.h>
#include <dcopclient.h>
+#include <dcopref.h>
-#include <cstdlib>
-#include <unistd.h>
-
+#include "hwdevicetray.h"
#include "hwdevicetray_configdialog.h"
-#include "hwdevicetray.h"
-HwDeviceSystemTray::HwDeviceSystemTray(TQWidget* parent, const char *name)
- : KSystemTray(parent, name) {
+// Storage Device Action
+namespace SDActions
+{
+ // use 'int' as underlying type to avoid exposing a bunch of unnecessary
+ // enums/structs in the class header file private methods' signature
+ // Note: must start from 0 because the Type value is also used as index
+ // of a TQValueVector
+ enum Type : int
+ {
+ Open = 0,
+ Mount,
+ Unmount,
+ Unlock,
+ Lock,
+ Eject,
+ SafeRemove,
+ Properties
+ };
+
+ struct Details
+ {
+ const char *iconName;
+ const char *actionName;
+ const char *collectionName;
+ };
+
+ // Allows to use a for loop to iterate over all action types
+ static const Type All[] = { Open, Mount, Unmount, Unlock, Lock, Eject, SafeRemove, Properties };
+
+ static const TQMap<Type, Details> populateMap()
+ {
+ TQMap<Type, Details> map;
+ map[Open] = { "window-new", I18N_NOOP("Open"), "open_menu" };
+ map[Mount] = { "drive-harddisk-mounted", I18N_NOOP("Mount"), "mount_menu" };
+ map[Unmount] = { "drive-harddisk-unmounted", I18N_NOOP("Unmount"), "unmount_menu" };
+ map[Unlock] = { "decrypted", I18N_NOOP("Unlock"), "unlock_menu" };
+ map[Lock] = { "encrypted", I18N_NOOP("Lock"), "lock_menu" };
+ map[Eject] = { "player_eject", I18N_NOOP("Eject"), "eject_menu" };
+ map[SafeRemove] = { "player_safe_removal", I18N_NOOP("Safe remove"), "safe_remove_menu" };
+ map[Properties] = { "edit", I18N_NOOP("Properties"), "properties_menu" };
+ return map;
+ }
+
+ static const TQMap<Type, Details> Data = populateMap();
+}
+
+// Storage Device Action Menu Entry, representing an action
+// and the storage device on which to perform it
+struct SDActionMenuEntry
+{
+ SDActions::Type actionType;
+ TQString uuid;
+};
+
+struct KnownDiskDeviceInfo
+{
+ TQString deviceLabel;
+ TQString node;
+};
+
+
+class HwDeviceSystemTrayPrivate
+{
+public:
+ HwDeviceSystemTrayPrivate()
+ {
+ }
+
+ ~HwDeviceSystemTrayPrivate()
+ {
+ }
+
+ // Members
+ TDEAction *m_deviceManagerAction;
+ TDEAction *m_quitAction;
+ TDEAction *m_shortcutKeysAction;
+ KHelpMenu *m_helpMenu;
+ TDEPopupMenu *m_LMBMenu;
+ TDEPopupMenu *m_RMBMenu;
+
+ TQMap<int, SDActionMenuEntry> m_actionMenuEntryMap;
+ TQMap<SDActions::Type, TDEActionMenu*> m_RMBActionMenuMap;
+
+ TQMap<TQString, KnownDiskDeviceInfo> m_knownDiskDevices;
+ TDEPassivePopupStackContainer *m_hardwareNotifierContainer;
+};
+
+
+HwDeviceSystemTray::HwDeviceSystemTray(TQWidget *parent, const char *name)
+ : KSystemTray(parent, name), d(new HwDeviceSystemTrayPrivate())
+{
// Create notifier
- m_hardwareNotifierContainer = new TDEPassivePopupStackContainer();
- connect(m_hardwareNotifierContainer, TQT_SIGNAL(popupClicked(KPassivePopup*, TQPoint, TQString)), this, TQT_SLOT(devicePopupClicked(KPassivePopup*, TQPoint, TQString)));
+ d->m_hardwareNotifierContainer = new TDEPassivePopupStackContainer();
+ connect(d->m_hardwareNotifierContainer, TQ_SIGNAL(popupClicked(KPassivePopup*, TQPoint, TQString)), this, TQ_SLOT(devicePopupClicked(KPassivePopup*, TQPoint, TQString)));
- // Create help submenu
- m_help = new KHelpMenu(this, TDEGlobal::instance()->aboutData(), false, actionCollection());
- TDEPopupMenu *help = m_help->menu();
- help->connectItem(KHelpMenu::menuHelpContents, this, TQT_SLOT(slotHelpContents()));
+ initMenus();
setPixmap(KSystemTray::loadIcon("hwinfo"));
- setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
- connect(this, TQT_SIGNAL(quitSelected()), this, TQT_SLOT(_quit()));
+ setAlignment(TQt::AlignHCenter | TQt::AlignVCenter);
+ connect(this, TQ_SIGNAL(quitSelected()), this, TQ_SLOT(quitApp()));
TQToolTip::add(this, i18n("Device monitor"));
- m_parent = parent;
- globalKeys = new TDEGlobalAccel(TQT_TQOBJECT(this));
+ globalKeys = new TDEGlobalAccel(this);
TDEGlobalAccel* keys = globalKeys;
#include "hwdevicetray_bindings.cpp"
// the keys need to be read from tdeglobals, not kickerrc
@@ -73,36 +166,35 @@ HwDeviceSystemTray::HwDeviceSystemTray(TQWidget* parent, const char *name)
globalKeys->setEnabled(true);
globalKeys->updateConnections();
- connect(kapp, TQT_SIGNAL(settingsChanged(int)), TQT_SLOT(slotSettingsChanged(int)));
-
- new TDEActionMenu(i18n("Open Device"), SmallIcon("connect_creating", TQIconSet::Automatic), actionCollection(), "mount_menu");
- new TDEActionMenu(i18n("Eject Device"), SmallIcon("connect_no", TQIconSet::Automatic), actionCollection(), "unmount_menu");
+ connect(tdeApp, TQ_SIGNAL(settingsChanged(int)), TQ_SLOT(slotSettingsChanged(int)));
-#ifdef __TDE_HAVE_TDEHWLIB
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
- connect(hwdevices, TQT_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQT_SLOT(deviceAdded(TDEGenericDevice*)));
- connect(hwdevices, TQT_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQT_SLOT(deviceRemoved(TDEGenericDevice*)));
- connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(deviceChanged(TDEGenericDevice*)));
-#endif
+ doDiskNotifications(true);
+ connect(hwdevices, TQ_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQ_SLOT(deviceAdded(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(deviceRemoved(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQ_SLOT(deviceChanged(TDEGenericDevice*)));
}
-HwDeviceSystemTray::~HwDeviceSystemTray() {
- delete m_hardwareNotifierContainer;
+HwDeviceSystemTray::~HwDeviceSystemTray()
+{
+ delete d->m_hardwareNotifierContainer;
+ delete d;
}
/*!
- * \b TQT_SLOT which called if hwdevicetray is exited by the user. In this case the user
+ * \b TQ_SLOT which called if hwdevicetray is exited by the user. In this case the user
* is asked through a yes/no box if "HwDeviceTray should start automatically on log in" and the
* result is written to the KDE configfile.
*/
-void HwDeviceSystemTray::_quit () {
- r_config = new KSimpleConfig("tdehwdevicetrayrc");
+void HwDeviceSystemTray::quitApp()
+{
+ TDESimpleConfig *config = new TDESimpleConfig("tdehwdevicetrayrc");
- TQString tmp1 = i18n ("Start device monitor automatically when you log in?");
- int tmp2 = KMessageBox::questionYesNo (0, tmp1, i18n("Question"), i18n("Start Automatically"), i18n("Do Not Start"));
- r_config->setGroup("General");
- r_config->writeEntry ("Autostart", tmp2 == KMessageBox::Yes);
- r_config->sync ();
+ TQString tmp1 = i18n("Start device monitor automatically when you log in?");
+ int tmp2 = KMessageBox::questionYesNo(0, tmp1, i18n("Question"), i18n("Start Automatically"), i18n("Do Not Start"));
+ config->setGroup("General");
+ config->writeEntry("Autostart", tmp2 == KMessageBox::Yes);
+ config->sync();
exit(0);
}
@@ -129,185 +221,373 @@ void HwDeviceSystemTray::showEvent (TQShowEvent *) {
resizeTrayIcon();
}
-void HwDeviceSystemTray::mousePressEvent(TQMouseEvent* e) {
- // Popup the context menu with left-click
- if (e->button() == Qt::LeftButton) {
- contextMenuAboutToShow(contextMenu());
- contextMenu()->popup(e->globalPos());
- e->accept();
- return;
+void HwDeviceSystemTray::mousePressEvent(TQMouseEvent* e)
+{
+ switch (e->button())
+ {
+ case TQt::LeftButton:
+ populateLMBMenu();
+ d->m_LMBMenu->popup(e->globalPos());
+ break;
+
+ case TQt::MidButton:
+ TQTimer::singleShot(0, this, TQ_SLOT(slotHardwareConfig()));
+ break;
+
+ case TQt::RightButton:
+ contextMenuAboutToShow(d->m_RMBMenu);
+ d->m_RMBMenu->popup(e->globalPos());
+ break;
+
+ default:
+ // do nothing
+ break;
}
-
- KSystemTray::mousePressEvent(e);
}
-bool HwDeviceSystemTray::isMonitoredDevice(TDEStorageDevice* sdevice) {
+bool HwDeviceSystemTray::isMonitoredDevice(TDEStorageDevice* sdevice)
+{
// Type selection logic largely duplicated from the media manager tdeioslave
- if (((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)
- || sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem)
- || sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio)
- || sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
- && !sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)
- && !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden)
- && (sdevice->isDiskOfType(TDEDiskDeviceType::HDD)
- || (sdevice->isDiskOfType(TDEDiskDeviceType::CDROM))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::CDR))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::CDRW))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::CDMO))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRW))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRWW))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDROM))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRAM))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDR))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRW))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRDL))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRWDL))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSR))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRW))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRDL))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRWDL))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::BDROM))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::BDR))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::BDRW))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDROM))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDR))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDRW))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::BDVideo))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::Floppy))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::Zip))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::Jaz))))
- || (sdevice->isDiskOfType(TDEDiskDeviceType::Camera))) {
- return true;
- }
- else {
- return false;
- }
+ return ((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden) &&
+ (sdevice->isDiskOfType(TDEDiskDeviceType::HDD) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDMO) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRWW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRAM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRWDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRWDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDVideo) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Floppy) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Zip) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Jaz) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Camera)));
}
-void HwDeviceSystemTray::contextMenuAboutToShow(TDEPopupMenu* menu) {
- menu->clear();
- menu->setCheckable(true);
+void HwDeviceSystemTray::initMenus()
+{
+ // RMB menu
+ d->m_RMBMenu = contextMenu();
+
+ // Device actions
+ for (const SDActions::Type &actionType : SDActions::All)
+ {
+ SDActions::Details ad = SDActions::Data[actionType];
+ d->m_RMBActionMenuMap.insert(actionType, new TDEActionMenu(i18n(ad.actionName),
+ SmallIcon(ad.iconName, TQIconSet::Automatic), actionCollection(), ad.collectionName));
+ }
- populateMenu(menu);
+ // Global Configuration
+ d->m_deviceManagerAction = new TDEAction(i18n("Show Device Manager..."), SmallIconSet("kcmpci"),
+ TDEShortcut(), this, TQ_SLOT(slotHardwareConfig()), actionCollection());
+ d->m_shortcutKeysAction = new TDEAction(i18n("Configure Shortcut Keys..."), SmallIconSet("configure"),
+ TDEShortcut(), this, TQ_SLOT(slotEditShortcutKeys()), actionCollection());
- menu->insertTitle(SmallIcon("configure"), i18n("Global Configuration"));
+ // Help & Quit
+ d->m_helpMenu = new KHelpMenu(this, TDEGlobal::instance()->aboutData(), false, actionCollection());
+ d->m_helpMenu->menu()->connectItem(KHelpMenu::menuHelpContents, this, TQ_SLOT(slotHelpContents()));
+ d->m_quitAction = actionCollection()->action(KStdAction::name(KStdAction::Quit));
- TDEAction *actHardwareConfig = new TDEAction(i18n("Configure Devices..."), SmallIconSet("kcmpci"), TDEShortcut(), TQT_TQOBJECT(this), TQT_SLOT(slotHardwareConfig()), actionCollection());
- actHardwareConfig->plug(menu);
+ // LMB menu
+ d->m_LMBMenu = new TDEPopupMenu(this);
+}
+
+TQString HwDeviceSystemTray::getDeviceLabel(TDEStorageDevice *sdevice)
+{
+ if (!sdevice)
+ {
+ return TQString::null;
+ }
- TDEAction *actShortcutKeys = new TDEAction(i18n("Configure Shortcut Keys..."), SmallIconSet("configure"), TDEShortcut(), TQT_TQOBJECT(this), TQT_SLOT(slotEditShortcutKeys()), actionCollection());
- actShortcutKeys->plug(menu);
+ DCOPRef mediamanager("kded", "mediamanager");
+ DCOPReply reply = mediamanager.call("properties", sdevice->deviceNode());
+ TQString deviceLabel = TQString::null;
+ if (reply.isValid())
+ {
+ // TODO R14.2.0: make sure the reply is a valid Medium
+ // once the media library is part of tdelibs
+ TQStringList properties = reply;
+ if (properties.size() >= 4)
+ {
+ deviceLabel = properties[3]; // medium label
+ }
+ }
+
+ if (deviceLabel.isEmpty())
+ {
+ deviceLabel = !sdevice->diskLabel().isEmpty() ? sdevice->diskLabel() : sdevice->friendlyName();
+ deviceLabel += " (" + sdevice->deviceNode() + ")";
+ }
- menu->insertItem(SmallIcon("help"), KStdGuiItem::help().text(), m_help->menu());
- TDEAction *quitAction = actionCollection()->action(KStdAction::name(KStdAction::Quit));
- quitAction->plug(menu);
+ return deviceLabel;
+}
- m_menu = menu;
+void HwDeviceSystemTray::addDeviceToLMBMenu(TDEStorageDevice *sdevice, const int type,
+ TDEActionMenu *actionMenu, int &actionMenuIdx)
+{
+ TQString uuid = !sdevice->diskUUID().isEmpty() ? sdevice->diskUUID() : sdevice->systemPath();
+ SDActions::Type actionType = (SDActions::Type)type;
+ SDActions::Details ad = SDActions::Data[actionType];
+ actionMenu->popupMenu()->insertItem(SmallIcon(ad.iconName), i18n(ad.actionName), actionMenuIdx);
+ actionMenu->popupMenu()->connectItem(actionMenuIdx, this,
+ TQ_SLOT(slotExecuteDeviceAction(int)));
+ d->m_actionMenuEntryMap[actionMenuIdx++] = { actionType, uuid };
}
-void HwDeviceSystemTray::configChanged() {
- //
+void HwDeviceSystemTray::addDeviceToRMBMenu(TDEStorageDevice *sdevice, const int type, int &actionMenuIdx)
+{
+ TQString uuid = !sdevice->diskUUID().isEmpty() ? sdevice->diskUUID() : sdevice->systemPath();
+ SDActions::Type actionType = (SDActions::Type)type;
+ TDEActionMenu *actionMenu = d->m_RMBActionMenuMap[actionType];
+ actionMenu->popupMenu()->insertItem(sdevice->icon(TDEIcon::SizeSmall),
+ getDeviceLabel(sdevice), actionMenuIdx);
+ actionMenu->popupMenu()->connectItem(actionMenuIdx, this,
+ TQ_SLOT(slotExecuteDeviceAction(int)));
+ actionMenu->setEnabled(true);
+ d->m_actionMenuEntryMap[actionMenuIdx++] = { actionType, uuid };
}
-void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) {
- int lastMountIndex;
- int lastUnmountIndex;
- TDEGenericDevice *hwdevice;
+void HwDeviceSystemTray::contextMenuAboutToShow(TDEPopupMenu *menu)
+{
+ d->m_RMBMenu = menu;
+ menu->clear();
- TDEActionMenu* mountDiskActionMenu = static_cast<TDEActionMenu*>(actionCollection()->action("mount_menu"));
- mountDiskActionMenu->popupMenu()->clear();
- m_mountMenuIndexMap.clear();
- TDEActionMenu* unmountDiskActionMenu = static_cast<TDEActionMenu*>(actionCollection()->action("unmount_menu"));
- unmountDiskActionMenu->popupMenu()->clear();
- m_mountMenuIndexMap.clear();
+ for (const SDActions::Type &actionType : SDActions::All)
+ {
+ TDEActionMenu *actionMenu = d->m_RMBActionMenuMap[actionType];
+ actionMenu->popupMenu()->clear();
+ actionMenu->setEnabled(false);
+ actionMenu->unplug(d->m_RMBMenu);
+ }
- menu->insertTitle(SmallIcon("drive-harddisk-unmounted"), i18n("Storage Devices"));
+ d->m_actionMenuEntryMap.clear();
- // Find all storage devices and add them to the popup menu
- lastMountIndex = 1;
- lastUnmountIndex = 1;
+ // Find all storage devices, sort them by label and add them to the popup menus
+ TQValueVector<TQMap<TQString, TDEStorageDevice*>*> rmbMenuEntries(sizeof(SDActions::All) / sizeof(SDActions::Type), nullptr);
+ for (size_t idx = 0; idx < rmbMenuEntries.size(); ++idx)
+ {
+ rmbMenuEntries[idx] = new TQMap<TQString, TDEStorageDevice*>();
+ }
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
TDEGenericHardwareList diskDeviceList = hwdevices->listByDeviceClass(TDEGenericDeviceType::Disk);
- for (hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next()) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
- if (isMonitoredDevice(sdevice)) {
- lastMountIndex = mountDiskActionMenu->popupMenu()->insertItem(hwdevice->icon(TDEIcon::SizeSmall), i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode()));
- mountDiskActionMenu->popupMenu()->connectItem(lastMountIndex, this, TQT_SLOT(slotMountDevice(int)));
- m_mountMenuIndexMap[lastMountIndex] = sdevice->diskUUID();
- if (m_mountMenuIndexMap[lastMountIndex] == "") {
- m_mountMenuIndexMap[lastMountIndex] = sdevice->systemPath();
+ for (TDEGenericDevice *hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next())
+ {
+ TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice);
+ if (isMonitoredDevice(sdevice))
+ {
+ TQString deviceLabel = getDeviceLabel(sdevice);
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted))
+ {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt))
+ {
+ (*rmbMenuEntries[SDActions::Lock])[deviceLabel] = sdevice;
+ }
+ else
+ {
+ (*rmbMenuEntries[SDActions::Unlock])[deviceLabel] = sdevice;
+ }
}
- if (sdevice->mountPath() != TQString::null) {
- lastUnmountIndex = unmountDiskActionMenu->popupMenu()->insertItem(hwdevice->icon(TDEIcon::SizeSmall), i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode()));
- unmountDiskActionMenu->popupMenu()->connectItem(lastUnmountIndex, this, TQT_SLOT(slotUnmountDevice(int)));
- m_unmountMenuIndexMap[lastUnmountIndex] = sdevice->diskUUID();
- if (m_unmountMenuIndexMap[lastMountIndex] == "") {
- m_unmountMenuIndexMap[lastMountIndex] = sdevice->systemPath();
+
+ if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable))
+ {
+ if (sdevice->mountPath().isEmpty())
+ {
+ (*rmbMenuEntries[SDActions::Mount])[deviceLabel] = sdevice;
}
+ else
+ {
+ (*rmbMenuEntries[SDActions::Unmount])[deviceLabel] = sdevice;
+ }
+
+ // Mounted and unmounted disks can also be opened
+ (*rmbMenuEntries[SDActions::Open])[deviceLabel] = sdevice;
}
+
+ if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable))
+ {
+ (*rmbMenuEntries[SDActions::Eject])[deviceLabel] = sdevice;
+
+ (*rmbMenuEntries[SDActions::SafeRemove])[deviceLabel] = sdevice;
+ }
+
+ (*rmbMenuEntries[SDActions::Properties])[deviceLabel] = sdevice;
}
}
- if (lastMountIndex == 0) {
- mountDiskActionMenu->setEnabled(false);
- }
- else {
- mountDiskActionMenu->setEnabled(true);
- }
- if (lastUnmountIndex == 0) {
- unmountDiskActionMenu->setEnabled(false);
- }
- else {
- unmountDiskActionMenu->setEnabled(true);
+ // Plug in meaningful action menus
+ d->m_RMBMenu->insertTitle(SmallIcon("drive-harddisk-unmounted"), i18n("Storage Device Actions"), 0);
+ int actionMenuIdx = 0;
+ for (const SDActions::Type &actionType : SDActions::All)
+ {
+ TDEActionMenu *actionMenu = d->m_RMBActionMenuMap[actionType];
+ for (TDEStorageDevice *sdevice : *rmbMenuEntries[actionType])
+ {
+ addDeviceToRMBMenu(sdevice, actionType, actionMenuIdx);
+ }
+ if (actionMenu->isEnabled())
+ {
+ actionMenu->plug(d->m_RMBMenu);
+ }
+ delete rmbMenuEntries[actionType];
+ rmbMenuEntries[actionType] = nullptr;
}
- mountDiskActionMenu->plug(menu);
- unmountDiskActionMenu->plug(menu);
+ // Global Configuration
+ menu->insertTitle(SmallIcon("configure"), i18n("Global Configuration"));
+
+ d->m_deviceManagerAction->plug(menu);
+ d->m_shortcutKeysAction->plug(menu);
+
+ // Help & Quit
+ menu->insertSeparator();
+ menu->insertItem(SmallIcon("help"), KStdGuiItem::help().text(), d->m_helpMenu->menu());
+ d->m_quitAction->plug(menu);
}
-void HwDeviceSystemTray::slotMountDevice(int parameter)
+void HwDeviceSystemTray::populateLMBMenu()
{
- TDEGenericDevice *hwdevice;
- TQString uuid = m_mountMenuIndexMap[parameter];
- if (uuid != "") {
- TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
- TDEGenericHardwareList diskDeviceList = hwdevices->listByDeviceClass(TDEGenericDeviceType::Disk);
- for (hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next()) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
- if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid)) {
- if (sdevice->isDiskOfType(TDEDiskDeviceType::Camera)) {
- new KRun(TQString("media:/%1").arg(sdevice->friendlyName()));
+ d->m_LMBMenu->clear();
+ d->m_LMBMenu->insertTitle(SmallIcon("drive-harddisk-unmounted"), i18n("Storage Devices"), 0);
+
+ d->m_actionMenuEntryMap.clear();
+ int actionMenuIdx = 0;
+
+ // Find all storage devices and add them to the popup menus
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEGenericHardwareList diskDeviceList = hwdevices->listByDeviceClass(TDEGenericDeviceType::Disk);
+ TQMap<TQString, TDEActionMenu*> lmbMenuEntries;
+ for (TDEGenericDevice *hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next())
+ {
+ TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice);
+ if (isMonitoredDevice(sdevice) &&
+ (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)))
+ {
+ TQString deviceLabel = getDeviceLabel(sdevice);
+ TDEActionMenu *actionMenu = new TDEActionMenu(deviceLabel,
+ sdevice->icon(TDEIcon::SizeSmall));
+
+ if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable))
+ {
+ // Mounted and unmounted disks can also be opened
+ addDeviceToLMBMenu(sdevice, SDActions::Open, actionMenu, actionMenuIdx);
+
+ if (sdevice->mountPath().isEmpty())
+ {
+ addDeviceToLMBMenu(sdevice, SDActions::Mount, actionMenu, actionMenuIdx);
+ }
+ else
+ {
+ addDeviceToLMBMenu(sdevice, SDActions::Unmount, actionMenu, actionMenuIdx);
}
- else {
- new KRun(TQString("system:/media/%1").arg(TQFileInfo(sdevice->deviceNode()).baseName(true)));
+ }
+
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted))
+ {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt))
+ {
+ addDeviceToLMBMenu(sdevice, SDActions::Lock, actionMenu, actionMenuIdx);
+ }
+ else
+ {
+ addDeviceToLMBMenu(sdevice, SDActions::Unlock, actionMenu, actionMenuIdx);
}
- return;
}
+
+
+ if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable))
+ {
+ addDeviceToLMBMenu(sdevice, SDActions::Eject, actionMenu, actionMenuIdx);
+
+ addDeviceToLMBMenu(sdevice, SDActions::SafeRemove, actionMenu, actionMenuIdx);
+ }
+
+ addDeviceToLMBMenu(sdevice, SDActions::Properties, actionMenu, actionMenuIdx);
+
+ lmbMenuEntries[deviceLabel] = actionMenu;
}
}
+ // Insert menu entries in sorted order
+ for (TDEActionMenu *am : lmbMenuEntries)
+ {
+ am->plug(d->m_LMBMenu);
+ }
}
-void HwDeviceSystemTray::slotUnmountDevice(int parameter)
+void HwDeviceSystemTray::slotExecuteDeviceAction(int parameter)
{
- TDEGenericDevice *hwdevice;
- TQString uuid = m_unmountMenuIndexMap[parameter];
- if (uuid != "") {
+ TQString uuid = d->m_actionMenuEntryMap[parameter].uuid;
+ int actionType = d->m_actionMenuEntryMap[parameter].actionType;
+ if (!uuid.isEmpty())
+ {
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
TDEGenericHardwareList diskDeviceList = hwdevices->listByDeviceClass(TDEGenericDeviceType::Disk);
- for (hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next()) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
- if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid)) {
- if (!sdevice->mountPath().isEmpty()) {
- TQStringVariantMap unmountResult = sdevice->unmountDevice();
- if (unmountResult["result"].toBool() == false) {
- TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
- TQString retcodeStr = unmountResult.contains("retCode") ? unmountResult["retCode"].toString() : "not available";
- KMessageBox::error(0, i18n("<qt><b>Unable to eject device</b><p>Detailed error information:<br>%1 (error code %2)</qt>").arg(errStr).arg(retcodeStr), i18n("Eject Failed"));
+ for (TDEGenericDevice *hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next())
+ {
+ TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice);
+ if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid))
+ {
+ if (actionType == SDActions::Open)
+ {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::Camera))
+ {
+ new KRun(TQString("media:/%1").arg(sdevice->friendlyName()));
+ }
+ else
+ {
+ new KRun(TQString("system:/media/%1").arg(TQFileInfo(sdevice->deviceNode()).baseName(true)));
+ }
+ }
+ else if (actionType == SDActions::Properties)
+ {
+ new KPropertiesDialog(KURL(TQString("media:/%1").arg(sdevice->deviceNode())));
+ }
+ else
+ {
+ TQString opType = TQString::null;
+ if (actionType == SDActions::Mount) { opType = "-m"; }
+ else if (actionType == SDActions::Unmount) { opType = "-u"; }
+ else if (actionType == SDActions::Unlock) { opType = "-k"; }
+ else if (actionType == SDActions::Lock) { opType = "-l"; }
+ else if (actionType == SDActions::Eject) { opType = "-e"; }
+ else if (actionType == SDActions::SafeRemove) { opType = "-s"; }
+
+ if (!opType.isEmpty())
+ {
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << opType << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
+ }
}
- return;
}
}
}
@@ -341,63 +621,117 @@ void HwDeviceSystemTray::slotEditShortcutKeys() {
delete dlg;
}
-void HwDeviceSystemTray::deviceAdded(TDEGenericDevice* device) {
-#ifdef __TDE_HAVE_TDEHWLIB
- if (device->type() == TDEGenericDeviceType::Disk) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
- if (isMonitoredDevice(sdevice)) {
- TQString uuid = sdevice->diskUUID();
- if (uuid == "") {
- uuid = sdevice->systemPath();
+void HwDeviceSystemTray::doDiskNotifications(bool scanOnly)
+{
+ TDEConfig config("mediamanagerrc");
+ config.setGroup("Global");
+ bool popupEnable = config.readBoolEntry("DeviceMonitorPopupsEnabled", true);
+
+ // Scan devices for changes and notify new devices if needed.
+ // This is necessary because the device information may not be available
+ // at the time the hardwareAdded signal is emitted
+ TQMap<TQString, KnownDiskDeviceInfo> oldKnownDevices = d->m_knownDiskDevices;
+ d->m_knownDiskDevices.clear();
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEGenericHardwareList diskDeviceList = hwdevices->listByDeviceClass(TDEGenericDeviceType::Disk);
+ for (TDEGenericDevice *hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next())
+ {
+ TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice);
+ if (isMonitoredDevice(sdevice))
+ {
+ TQString sysPath = sdevice->systemPath();
+ if (oldKnownDevices.contains(sysPath))
+ {
+ d->m_knownDiskDevices[sysPath] = oldKnownDevices[sysPath];
+ oldKnownDevices.remove(sysPath);
+ }
+ else
+ {
+ TQString deviceLabel = getDeviceLabel(sdevice);
+ d->m_knownDiskDevices[sysPath] = { deviceLabel, sdevice->deviceNode() };
+ if (!scanOnly && popupEnable)
+ {
+ d->m_hardwareNotifierContainer->displayMessage(
+ i18n("A disk device has been added!"), deviceLabel,
+ SmallIcon("drive-harddisk-unmounted"), 0, 0, "ADD: " + sysPath);
+ }
}
- m_hardwareNotifierContainer->displayMessage(
- i18n("A disk device has been added!"),
- i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode()), SmallIcon("drive-harddisk-unmounted"),
- 0, 0, "ADD: " + uuid);
}
}
-#endif
+ // Notify devices which have been removed, if necessary
+ if (!scanOnly && popupEnable)
+ {
+ TQMap<TQString, KnownDiskDeviceInfo>::ConstIterator delIt;
+ for (delIt = oldKnownDevices.begin(); delIt != oldKnownDevices.end(); delIt++)
+ {
+ d->m_hardwareNotifierContainer->displayMessage(
+ i18n("A disk device has been removed!"), delIt.data().deviceLabel,
+ SmallIcon("drive-harddisk-unmounted"), 0, 0, "REMOVE: " + delIt.key());
+ }
+ }
}
-void HwDeviceSystemTray::deviceRemoved(TDEGenericDevice* device) {
-#ifdef __TDE_HAVE_TDEHWLIB
- if (device->type() == TDEGenericDeviceType::Disk) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
- if (isMonitoredDevice(sdevice)) {
- TQString uuid = sdevice->diskUUID();
- if (uuid == "") {
- uuid = sdevice->systemPath();
+void HwDeviceSystemTray::deviceAdded(TDEGenericDevice* device)
+{
+ if (device->type() == TDEGenericDeviceType::Disk)
+ {
+ TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(device);
+ // The device information may not be available at the time the hardwareAdded signal is emitted.
+ // In such case ignore the event and handle that at the subsequent hardwareUpdate signal emission.
+ TQString sysPath = sdevice->systemPath();
+ if (isMonitoredDevice(sdevice) && !d->m_knownDiskDevices.contains(sysPath))
+ {
+ TQString deviceLabel = getDeviceLabel(sdevice);
+ d->m_knownDiskDevices[sysPath] = { deviceLabel, sdevice->deviceNode() };
+ TDEConfig config("mediamanagerrc");
+ config.setGroup("Global");
+ if (config.readBoolEntry("DeviceMonitorPopupsEnabled", true))
+ {
+ d->m_hardwareNotifierContainer->displayMessage(
+ i18n("A disk device has been added!"), deviceLabel,
+ SmallIcon("drive-harddisk-unmounted"), 0, 0, "ADD: " + sysPath);
}
- m_hardwareNotifierContainer->displayMessage(
- i18n("A disk device has been removed!"),
- i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode()), SmallIcon("drive-harddisk-unmounted"),
- 0, 0, "REMOVE: " + uuid);
}
}
-#endif
}
-void HwDeviceSystemTray::deviceChanged(TDEGenericDevice* device) {
-#ifdef __TDE_HAVE_TDEHWLIB
- if (device->type() == TDEGenericDeviceType::Disk) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
- if (isMonitoredDevice(sdevice)) {
- TQString uuid = sdevice->diskUUID();
- if (uuid == "") {
- uuid = sdevice->systemPath();
+void HwDeviceSystemTray::deviceRemoved(TDEGenericDevice* device)
+{
+ if (device->type() == TDEGenericDeviceType::Disk)
+ {
+ TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(device);
+ TQString sysPath = sdevice->systemPath();
+ if (isMonitoredDevice(sdevice) && d->m_knownDiskDevices.contains(sysPath))
+ {
+ TDEConfig config("mediamanagerrc");
+ config.setGroup("Global");
+ if (config.readBoolEntry("DeviceMonitorPopupsEnabled", true))
+ {
+ TQString deviceLabel = getDeviceLabel(sdevice);
+ d->m_hardwareNotifierContainer->displayMessage(
+ i18n("A disk device has been removed!"), deviceLabel,
+ SmallIcon("drive-harddisk-unmounted"), 0, 0, "REMOVE: " + sysPath);
}
- m_hardwareNotifierContainer->displayMessage(
- i18n("A disk device has been changed!"),
- i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode()), SmallIcon("drive-harddisk-unmounted"),
- 0, 0, "CHANGE: " + uuid);
+ d->m_knownDiskDevices.remove(sysPath);
}
}
-#endif
+}
+
+void HwDeviceSystemTray::deviceChanged(TDEGenericDevice* device)
+{
+ doDiskNotifications(false);
}
void HwDeviceSystemTray::devicePopupClicked(KPassivePopup* popup, TQPoint point, TQString uuid) {
TDEGenericDevice *hwdevice;
if (uuid.startsWith("ADD: ")) {
+ TDEConfig config("mediamanagerrc");
+ config.setGroup("Global");
+ if (config.readBoolEntry("NotificationPopupsEnabled", true))
+ {
+ return;
+ }
+
uuid = uuid.right(uuid.length() - strlen("ADD: "));
if (uuid != "") {
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
@@ -426,7 +760,7 @@ void HwDeviceSystemTray::devicePopupClicked(KPassivePopup* popup, TQPoint point,
}
void HwDeviceSystemTray::slotHelpContents() {
- kapp->invokeHelp(TQString::null, "hwdevicetray");
+ tdeApp->invokeHelp(TQString::null, "hwdevicetray");
}
-#include "hwdevicetray.moc" \ No newline at end of file
+#include "hwdevicetray.moc"
diff --git a/kcontrol/hwmanager/hwdevicetray.h b/kcontrol/hwmanager/hwdevicetray.h
index d49f5b4b3..4f019ae58 100644
--- a/kcontrol/hwmanager/hwdevicetray.h
+++ b/kcontrol/hwmanager/hwdevicetray.h
@@ -1,8 +1,8 @@
/*
* Copyright 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
- *
+ *
* This file is part of hwdevicetray, the TDE Hardware Device Monitor System Tray Application
- *
+ *
* hwdevicetray 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 3
@@ -20,76 +20,58 @@
#ifndef TDEHWDEVICETRAY_H
#define TDEHWDEVICETRAY_H
-#include <tqptrlist.h>
-
#include <ksystemtray.h>
-#include <kglobalaccel.h>
-#include <ksimpleconfig.h>
-#include <tdepassivepopupstack.h>
-
-#ifdef __TDE_HAVE_TDEHWLIB
-#include <tdehardwaredevices.h>
-#else
-#define TDEGenericDevice void
-#endif
-class KHelpMenu;
+class HwDeviceSystemTrayPrivate;
+class KPassivePopup;
+class TDEActionMenu;
+class TDEGenericDevice;
+class TDEGlobalAccel;
class TDEPopupMenu;
+class TDEStorageDevice;
-typedef TQMap<int, TQString> TQStringMap;
-
-class HwDeviceSystemTray : public KSystemTray
+class HwDeviceSystemTray : public KSystemTray
{
- Q_OBJECT
+ TQ_OBJECT
public:
HwDeviceSystemTray(TQWidget* parent = 0, const char *name = 0);
~HwDeviceSystemTray();
- TDEGlobalAccel *globalKeys;
- virtual void contextMenuAboutToShow(TDEPopupMenu* menu);
+ TDEGlobalAccel *globalKeys;
- void configChanged();
+ virtual void contextMenuAboutToShow(TDEPopupMenu *menu);
protected slots:
void slotHardwareConfig();
void slotEditShortcutKeys();
void slotSettingsChanged(int category);
void slotHelpContents();
+ void slotExecuteDeviceAction(int parameter);
- void slotMountDevice(int parameter);
- void slotUnmountDevice(int parameter);
-
-protected:
- void mousePressEvent(TQMouseEvent *e);
- void resizeEvent(TQResizeEvent *);
- void showEvent(TQShowEvent *);
-
-private slots:
- void _quit();
+ void quitApp();
void deviceAdded(TDEGenericDevice*);
void deviceRemoved(TDEGenericDevice*);
void deviceChanged(TDEGenericDevice*);
-
void devicePopupClicked(KPassivePopup*, TQPoint, TQString);
+ void doDiskNotifications(bool scanOnly);
-private:
- bool isMonitoredDevice(TDEStorageDevice* sdevice);
-
-private:
- void populateMenu(TDEPopupMenu* menu);
+protected:
+ void initMenus();
+ void mousePressEvent(TQMouseEvent *e);
+ void populateLMBMenu();
+ void resizeEvent(TQResizeEvent *);
void resizeTrayIcon();
+ void showEvent(TQShowEvent *);
- bool m_popupUp;
- KHelpMenu* m_help;
+ static bool isMonitoredDevice(TDEStorageDevice *sdevice);
+ static TQString getDeviceLabel(TDEStorageDevice *sdevice);
- TQWidget* m_parent;
- TDEPassivePopupStackContainer* m_hardwareNotifierContainer;
+ void addDeviceToLMBMenu(TDEStorageDevice *sdevice, const int type, TDEActionMenu *actionMenu,
+ int &actionMenuIdx);
+ void addDeviceToRMBMenu(TDEStorageDevice *sdevice, const int type, int &actionMenuIdx);
- TQStringMap m_mountMenuIndexMap;
- TQStringMap m_unmountMenuIndexMap;
- TDEPopupMenu* m_menu;
- KSimpleConfig *r_config;
+ HwDeviceSystemTrayPrivate *d;
};
#endif
diff --git a/kcontrol/hwmanager/hwdevicetray_app.cpp b/kcontrol/hwmanager/hwdevicetray_app.cpp
index 3f96f76a4..0928a399d 100644
--- a/kcontrol/hwmanager/hwdevicetray_app.cpp
+++ b/kcontrol/hwmanager/hwdevicetray_app.cpp
@@ -17,6 +17,10 @@
* License along with cryptocardwatcher. If not, see http://www.gnu.org/licenses/.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <kdebug.h>
#include "hwdevicetray_app.h"
diff --git a/kcontrol/hwmanager/hwdevicetray_app.h b/kcontrol/hwmanager/hwdevicetray_app.h
index fae4d6cd9..b4e03973f 100644
--- a/kcontrol/hwmanager/hwdevicetray_app.h
+++ b/kcontrol/hwmanager/hwdevicetray_app.h
@@ -21,13 +21,13 @@
#define TDEHWDEVICEAPP_H
#include <tqtimer.h>
-#include <kuniqueapplication.h>
+#include <tdeuniqueapplication.h>
class HwDeviceSystemTray;
-class HwDeviceApp : public KUniqueApplication
+class HwDeviceApp : public TDEUniqueApplication
{
- Q_OBJECT
+ TQ_OBJECT
public:
HwDeviceApp();
diff --git a/kcontrol/hwmanager/hwdevicetray_bindings.cpp b/kcontrol/hwmanager/hwdevicetray_bindings.cpp
index 08145cb9e..09974ac68 100644
--- a/kcontrol/hwmanager/hwdevicetray_bindings.cpp
+++ b/kcontrol/hwmanager/hwdevicetray_bindings.cpp
@@ -1,4 +1,3 @@
-// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
/* This file is part of the KDE project
Copyright (C) by Andrew Stanley-Jones
@@ -19,7 +18,7 @@
*/
#ifndef NOSLOTS
# define DEF( name, key3, key4, fnSlot ) \
- keys->insert( name, i18n(name), TQString(), key3, key4, TQT_TQOBJECT(this), TQT_SLOT(fnSlot) )
+ keys->insert( name, i18n(name), TQString(), key3, key4, this, TQ_SLOT(fnSlot) )
#else
# define DEF( name, key3, key4, fnSlot ) \
keys->insert( name, i18n(name), TQString(), key3, key4 )
diff --git a/kcontrol/hwmanager/hwdevicetray_configdialog.h b/kcontrol/hwmanager/hwdevicetray_configdialog.h
index 657b3ee43..823931757 100644
--- a/kcontrol/hwmanager/hwdevicetray_configdialog.h
+++ b/kcontrol/hwmanager/hwdevicetray_configdialog.h
@@ -42,7 +42,7 @@ class ConfigDialog;
class ConfigDialog : public KDialogBase
{
- Q_OBJECT
+ TQ_OBJECT
public:
ConfigDialog(TDEGlobalAccel *accel, bool isApplet );
diff --git a/kcontrol/hwmanager/hwdevicetray_main.cpp b/kcontrol/hwmanager/hwdevicetray_main.cpp
index dc0704d57..0584c92fd 100644
--- a/kcontrol/hwmanager/hwdevicetray_main.cpp
+++ b/kcontrol/hwmanager/hwdevicetray_main.cpp
@@ -36,8 +36,13 @@ static const TDECmdLineOptions options[] =
int main(int argc, char **argv)
{
- TDEAboutData aboutData("hwdevicetray", I18N_NOOP("Device Monitor"), hwdevicetrayVersion, I18N_NOOP("Device Monitor Tray Application\n\nAllows you not only to get informations about hardware changes on your system,\nbut also to open and eject storage devices if possible."), TDEAboutData::License_GPL_V3,
- "(c) 2015 Timothy Pearson\n(c) 2019 The Trinity Desktop Project", 0L, "");
+ TDEAboutData aboutData("hwdevicetray", I18N_NOOP("Device Monitor"), hwdevicetrayVersion,
+ I18N_NOOP("Device Monitor Tray Application\n\n"
+ "Allows you not only to get informations about hardware changes on your system,\n"
+ "but also to open and eject storage devices if possible."),
+ TDEAboutData::License_GPL_V3,
+ I18N_NOOP("(c) 2015 Timothy Pearson\n"
+ "(c) 2019 The Trinity Desktop Project"), 0L, "");
aboutData.addAuthor("Timothy Pearson",I18N_NOOP("Initial developer and maintainer"), "kb9vqf@pearsoncomputing.net");
aboutData.setProductName("hwdevices/hwdevicetray");
TDEGlobal::locale()->setMainCatalogue("tdehwdevicetray");
diff --git a/kcontrol/hwmanager/hwmanager.cpp b/kcontrol/hwmanager/hwmanager.cpp
index 3258453d0..662844ec3 100644
--- a/kcontrol/hwmanager/hwmanager.cpp
+++ b/kcontrol/hwmanager/hwmanager.cpp
@@ -23,6 +23,7 @@
#include <tqlayout.h>
#include <tqlineedit.h>
#include <tqpushbutton.h>
+#include <tqtimer.h>
#include <dcopclient.h>
@@ -43,7 +44,7 @@
#include <unistd.h>
#include <kpassdlg.h>
-#include <ksimpleconfig.h>
+#include <tdesimpleconfig.h>
#include <string>
#include <stdio.h>
#include <tqstring.h>
@@ -58,8 +59,8 @@ using namespace std;
typedef KGenericFactory<TDEHWManager, TQWidget> TDEHWManagerFactory;
K_EXPORT_COMPONENT_FACTORY( kcm_hwmanager, TDEHWManagerFactory("kcmhwmanager") )
-KSimpleConfig *config;
-KSimpleConfig *systemconfig;
+TDESimpleConfig *config;
+TDESimpleConfig *systemconfig;
/**** TDEHWManager ****/
@@ -67,14 +68,17 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis
: 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" ));
+ config = new TDESimpleConfig( TQString::fromLatin1( "hwmanagerrc" ));
+ systemconfig = new TDESimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdehw/hwmanagerrc" ));
TDEAboutData *about =
- new TDEAboutData(I18N_NOOP("kcmhwmanager"), I18N_NOOP("TDE Device Manager\n\nCan be used to get all kind of informations about your devices on your system, shows which drivers are used by them and allows to change device settings."),
- 0, 0, TDEAboutData::License_GPL,
- I18N_NOOP("(c) 2012 Timothy Pearson\n(c) 2019 The Trinity Desktop Project"));
-
+ new TDEAboutData(I18N_NOOP("kcmhwmanager"), I18N_NOOP("TDE Device Manager"), 0,
+ I18N_NOOP("Device Manager\n\n"
+ "Can be used to get all kind of informations about your devices on your system,\n"
+ "shows which drivers are used by them and allows to change device settings."),
+ TDEAboutData::License_GPL,
+ I18N_NOOP("(c) 2012 Timothy Pearson\n"
+ "(c) 2019 The Trinity Desktop Project"));
about->addAuthor("Timothy Pearson", 0, "kb9vqf@pearsoncomputing.net");
setAboutData( about );
@@ -83,18 +87,19 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis
base->deviceFilter->setListView(base->deviceTree);
+ deviceUpdateScheduled = false;
+
setRootOnlyMsg(i18n("<b>Device settings are system wide, and therefore require administrator access</b><br>To alter the system's device 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(base->showByConnection, TQ_SIGNAL(clicked()), TQ_SLOT(changed()));
+ connect(base->showByConnection, TQ_SIGNAL(clicked()), TQ_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*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQ_SLOT(scheduleDeviceUpdate()));
+ connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(scheduleDeviceUpdate()));
load();
@@ -103,6 +108,7 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis
TDEHWManager::~TDEHWManager()
{
+ TDEGlobal::hardwareDevices()->setTriggerlessHardwareUpdatesEnabled(false);
delete config;
delete systemconfig;
}
@@ -127,8 +133,19 @@ void TDEHWManager::defaults()
load( true );
}
+void TDEHWManager::scheduleDeviceUpdate()
+{
+ if (!deviceUpdateScheduled)
+ {
+ deviceUpdateScheduled = true;
+ TQTimer::singleShot(1000, this, TQ_SLOT(populateTreeView()));
+ }
+}
+
void TDEHWManager::populateTreeView()
{
+ deviceUpdateScheduled = false;
+
bool show_by_connection = base->showByConnection->isChecked();
// Figure out which device, if any, was selected
@@ -149,11 +166,11 @@ void TDEHWManager::populateTreeView()
for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) {
if (hwdevice->type() == TDEGenericDeviceType::CryptographicCard) {
TDECryptographicCardDevice* cdevice = static_cast<TDECryptographicCardDevice*>(hwdevice);
- connect(cdevice, SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*)));
+ connect(cdevice, TQ_SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*)));
cdevice->enableCardMonitoring(true);
cdevice->enablePINEntryCallbacks(true);
}
- DeviceIconItem* item = new DeviceIconItem(base->deviceTree, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice);
+ DeviceIconItem* item = new DeviceIconItem(base->deviceTree, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice->uniqueID());
if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) {
base->deviceTree->ensureItemVisible(item);
base->deviceTree->setSelected(item, true);
@@ -165,17 +182,17 @@ void TDEHWManager::populateTreeView()
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);
+ DeviceIconItem* rootitem = new DeviceIconItem(base->deviceTree, hwdevices->getFriendlyDeviceTypeStringFromType((TDEGenericDeviceType::TDEGenericDeviceType)i), hwdevices->getDeviceTypeIconFromType((TDEGenericDeviceType::TDEGenericDeviceType)i, base->deviceTree->iconSize()), TQString::null);
TDEGenericDevice *hwdevice;
TDEGenericHardwareList hwlist = hwdevices->listByDeviceClass((TDEGenericDeviceType::TDEGenericDeviceType)i);
for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) {
if (hwdevice->type() == TDEGenericDeviceType::CryptographicCard) {
TDECryptographicCardDevice* cdevice = static_cast<TDECryptographicCardDevice*>(hwdevice);
- connect(cdevice, SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*)));
+ connect(cdevice, TQ_SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*)));
cdevice->enableCardMonitoring(true);
cdevice->enablePINEntryCallbacks(true);
}
- DeviceIconItem* item = new DeviceIconItem(rootitem, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice);
+ DeviceIconItem* item = new DeviceIconItem(rootitem, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice->uniqueID());
if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) {
base->deviceTree->ensureItemVisible(item);
base->deviceTree->setSelected(item, true);
@@ -194,12 +211,12 @@ void TDEHWManager::populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_con
for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) {
if (hwdevice->type() == TDEGenericDeviceType::CryptographicCard) {
TDECryptographicCardDevice* cdevice = static_cast<TDECryptographicCardDevice*>(hwdevice);
- connect(cdevice, SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*)));
+ connect(cdevice, TQ_SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*)));
cdevice->enableCardMonitoring(true);
cdevice->enablePINEntryCallbacks(true);
}
if (hwdevice->parentDevice() == parent->device()) {
- DeviceIconItem* item = new DeviceIconItem(parent, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice);
+ DeviceIconItem* item = new DeviceIconItem(parent, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice->uniqueID());
if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) {
base->deviceTree->ensureItemVisible(item);
base->deviceTree->setSelected(item, true);
@@ -210,24 +227,6 @@ void TDEHWManager::populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_con
}
}
-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;
- }
-}
-
void TDEHWManager::cryptographicCardPinRequested(TQString prompt, TDECryptographicCardDevice* cdevice) {
TQString password;
int result = KPasswordDialog::getPassword(password, prompt);
diff --git a/kcontrol/hwmanager/hwmanager.h b/kcontrol/hwmanager/hwmanager.h
index abc05fa54..020a51f22 100644
--- a/kcontrol/hwmanager/hwmanager.h
+++ b/kcontrol/hwmanager/hwmanager.h
@@ -41,7 +41,7 @@ class TDEListViewItem;
class TDEHWManager : public TDECModule, public DCOPObject
{
K_DCOP
- Q_OBJECT
+ TQ_OBJECT
public:
//TDEHWManager(TQWidget *parent = 0L, const char *name = 0L);
@@ -58,15 +58,15 @@ public:
k_dcop:
private slots:
+ void cryptographicCardPinRequested(TQString prompt, TDECryptographicCardDevice* cdevice);
void populateTreeView();
void populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_connection, TQString selected_syspath);
- void deviceChanged(TDEGenericDevice*);
- void cryptographicCardPinRequested(TQString prompt, TDECryptographicCardDevice* cdevice);
+ void scheduleDeviceUpdate();
private:
TDEHWManagerBase *base;
-
TDEConfig *config;
+ bool deviceUpdateScheduled;
};
#endif
diff --git a/kcontrol/hwmanager/hwmanagerbase.ui b/kcontrol/hwmanager/hwmanagerbase.ui
index 6c785921d..ee84b81c3 100644
--- a/kcontrol/hwmanager/hwmanagerbase.ui
+++ b/kcontrol/hwmanager/hwmanagerbase.ui
@@ -74,9 +74,9 @@
<include location="local" impldecl="in implementation">TDEHWManagerBase.ui.h</include>
<include location="local" impldecl="in implementation">deviceiconview.h</include>
</includes>
-<Q_SLOTS>
+<slots>
<slot>enableSupport_toggled(bool)</slot>
-</Q_SLOTS>
+</slots>
<includes>
<include location="global" impldecl="in implementation">kdialog.h</include>
<include location="global" impldecl="in implementation">tdelistviewsearchline.h</include>
diff --git a/kcontrol/hwmanager/passworddlg.cpp b/kcontrol/hwmanager/passworddlg.cpp
new file mode 100644
index 000000000..22b82648f
--- /dev/null
+++ b/kcontrol/hwmanager/passworddlg.cpp
@@ -0,0 +1,66 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2007 Jan Klötzke <jan kloetzke at freenet de>
+ *
+ * Based on kryptomedia- Another KDE cryto media application.
+ * Copyright (C) 2006 Daniel Gollub <dgollub@suse.de>
+ *
+ * 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 "passworddlg.h"
+
+PasswordDlg::PasswordDlg() :
+ KDialogBase(NULL, "PasswordDlg", true, i18n("Unlock Storage Device"), (Cancel|User1),
+ User1, false, KGuiItem(i18n("Unlock"), "unlocked" ))
+{
+ unlockDialog = new UnlockDialog(this);
+ enableButton( User1, false );
+ unlockDialog->encryptedIcon->setPixmap(TDEGlobal::iconLoader()->loadIcon("drive-harddisk-locked",
+ TDEIcon::NoGroup, TDEIcon::SizeLarge));
+ connect(unlockDialog->passwordEdit, TQ_SIGNAL (textChanged(const TQString &)), this, TQ_SLOT (slotPasswordChanged(const TQString &)));
+
+ setMainWidget(unlockDialog);
+}
+
+PasswordDlg::~PasswordDlg()
+{
+ delete unlockDialog;
+}
+
+void PasswordDlg::setDevice(TQString deviceName)
+{
+ unlockDialog->descLabel->setText("<p><b>" + deviceName + "</b> is an encrypted storage device.</p>"
+ "<p>Please enter the password to unlock the storage device.</p>");
+ unlockDialog->descLabel->adjustSize();
+ unlockDialog->adjustSize();
+}
+
+void PasswordDlg::clearPassword()
+{
+ unlockDialog->passwordEdit->setText(TQString::null);
+}
+
+TQString PasswordDlg::getPassword()
+{
+ return unlockDialog->passwordEdit->text();
+}
+
+void PasswordDlg::slotPasswordChanged(const TQString &text)
+{
+ enableButton( User1, !text.isEmpty() );
+}
+
+#include "passworddlg.moc"
diff --git a/kcontrol/hwmanager/passworddlg.h b/kcontrol/hwmanager/passworddlg.h
new file mode 100644
index 000000000..091b5aa5f
--- /dev/null
+++ b/kcontrol/hwmanager/passworddlg.h
@@ -0,0 +1,62 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2007 Jan Klötzke <jan kloetzke at freenet de>
+ *
+ * Based on kryptomedia- Another KDE cryto media application.
+ * Copyright (C) 2006 Daniel Gollub <dgollub@suse.de>
+ *
+ * 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 DIALOG_H_
+#define DIALOG_H_
+
+#include <tdemessagebox.h>
+#include <tdelocale.h>
+#include <tdeconfig.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <kiconloader.h>
+
+#include <tqlineedit.h>
+#include <tqlabel.h>
+#include <tqgroupbox.h>
+
+#include "unlockdialog.h"
+
+class PasswordDlg : public KDialogBase
+{
+
+ TQ_OBJECT
+
+public:
+ PasswordDlg();
+ ~PasswordDlg();
+
+ void setDevice(TQString deviceName);
+ void clearPassword();
+ TQString getPassword();
+
+ int index;
+
+public slots:
+ void slotPasswordChanged(const TQString &text);
+
+private:
+ UnlockDialog *unlockDialog;
+};
+
+#endif // DIALOG_H_
+
diff --git a/kcontrol/hwmanager/unlockdialog.ui b/kcontrol/hwmanager/unlockdialog.ui
new file mode 100644
index 000000000..576de07a4
--- /dev/null
+++ b/kcontrol/hwmanager/unlockdialog.ui
@@ -0,0 +1,160 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>UnlockDialog</class>
+<widget class="TQWidget">
+ <property name="name">
+ <cstring>UnlockDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>207</width>
+ <height>172</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Decrypting Storage Device</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>encryptedIcon</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>48</width>
+ <height>48</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ <property name="alignment">
+ <set>AlignTop</set>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>descLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Dummy placeholder</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Password:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>passwordEdit</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit">
+ <property name="name">
+ <cstring>passwordEdit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>