[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdereview/plasma/applets/trash
From: Marco Martin <notmart () gmail ! com>
Date: 2008-02-13 13:25:26
Message-ID: 1202909126.632284.26513.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 774536 by mart:
Experiment: eject (with solid) cds and unmount drives when they are dropped on the \
trashcan
M +1 -1 CMakeLists.txt
M +31 -3 trash.cpp
M +0 -1 trash.h
--- trunk/kdereview/plasma/applets/trash/CMakeLists.txt #774535:774536
@@ -10,7 +10,7 @@
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
kde4_add_plugin(plasma_applet_trash ${trash_SRCS})
-target_link_libraries(plasma_applet_trash ${PLASMA_LIBS} konq ${KDE4_KIO_LIBS})
+target_link_libraries(plasma_applet_trash ${PLASMA_LIBS} ${SOLID_LIBS} konq \
${KDE4_KIO_LIBS})
install(TARGETS plasma_applet_trash DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plasma-applet-trash.desktop DESTINATION ${SERVICES_INSTALL_DIR})
--- trunk/kdereview/plasma/applets/trash/trash.cpp #774535:774536
@@ -34,12 +34,22 @@
#include <KSharedConfig>
#include <KMessageBox>
#include <KUrl>
+#include <konq_operations.h>
-
-#include <konq_operations.h>
+//Plasma
#include <plasma/widgets/icon.h>
#include <plasma/containment.h>
+//Solid
+#include <solid/devicenotifier.h>
+#include <solid/device.h>
+#include <solid/deviceinterface.h>
+#include <solid/predicate.h>
+#include <solid/storageaccess.h>
+#include <solid/opticaldrive.h>
+#include <solid/opticaldisc.h>
+
+
Trash::Trash(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args),
m_icon(0),
@@ -282,7 +292,25 @@
if (urls.count() > 0) {
event->accept();
- KonqOperations::del( &m_menu, KonqOperations::TRASH, urls );
+
+ //try to unmount a mountpoint if the first item is a mountpoint
+ //TODO: decide if iterate all urls if there is more than one (would it \
be too complex? and how to behave if there are ordinary files mixed with mount \
points?) + bool isDevice = false;
+ Solid::Predicate predicate = \
Solid::Predicate(Solid::DeviceInterface::StorageAccess, "filePath", \
urls.first().path()); +
+ foreach (Solid::Device device, Solid::Device::listFromQuery(predicate, \
QString())) { + if (device.is<Solid::OpticalDisc>()) {
+ device.parent().as<Solid::OpticalDrive>()->eject();
+ } else {
+ device.as<Solid::StorageAccess>()->teardown();
+ }
+
+ isDevice = true;
+ }
+
+ if (!isDevice) {
+ KonqOperations::del( &m_menu, KonqOperations::TRASH, urls );
+ }
}
}
--- trunk/kdereview/plasma/applets/trash/trash.h #774535:774536
@@ -29,7 +29,6 @@
#include <KDirLister>
#include <plasma/applet.h>
-//#include <plasma/layouts/boxlayout.h>
class KPropertiesDialog;
class QAction;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic