aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron J. Seigo <aseigo@kde.org>2011-01-12 02:44:59 (GMT)
committerAaron J. Seigo <aseigo@kde.org>2011-01-12 02:44:59 (GMT)
commitb4eca90184cb43ce689724f5dab6f052361fb075 (patch)
tree10e045e34f782979cfbc8ec4b0b75619795bd4b9
parent173b0d817f3df03c3608eb05403ebb6108c8385f (diff)
only accept drops of executables for launcher creation
CCBUG:261443 svn path=/branches/KDE/4.6/kdebase/workspace/; revision=1213907
Notes
Notes: Backport-of: 195344a8ea69964455c65fe13664fdb8cff6c60d
-rw-r--r--plasma/desktop/applets/tasks/abstracttaskitem.cpp42
-rw-r--r--plasma/desktop/applets/tasks/abstracttaskitem.h1
-rw-r--r--plasma/desktop/applets/tasks/taskgroupitem.cpp7
3 files changed, 39 insertions, 11 deletions
diff --git a/plasma/desktop/applets/tasks/abstracttaskitem.cpp b/plasma/desktop/applets/tasks/abstracttaskitem.cpp
index e0c682b..1923578 100644
--- a/plasma/desktop/applets/tasks/abstracttaskitem.cpp
+++ b/plasma/desktop/applets/tasks/abstracttaskitem.cpp
@@ -24,6 +24,7 @@
// Qt
#include <QApplication>
+#include <QFileInfo>
#include <QGraphicsLinearLayout>
#include <QGraphicsSceneContextMenuEvent>
#include <QGraphicsView>
@@ -38,12 +39,12 @@
// KDE
#include <KAuthorized>
+#include <KColorUtils>
#include <KDebug>
+#include <KGlobalSettings>
#include <KIcon>
#include <KIconEffect>
-#include <KGlobalSettings>
#include <KIconLoader>
-#include <KColorUtils>
#include <NETWinInfo>
@@ -869,12 +870,41 @@ void AbstractTaskItem::setBackgroundFadeAlpha(qreal progress)
update();
}
+bool AbstractTaskItem::shouldIgnoreDragEvent(QGraphicsSceneDragDropEvent *event)
+{
+ if (event->mimeData()->hasFormat(TaskManager::Task::mimetype()) ||
+ event->mimeData()->hasFormat(TaskManager::Task::groupMimetype())) {
+ return true;
+ }
+
+ if (event->mimeData()->hasFormat("text/uri-list")) {
+ // we want to check if we have executables; if so, then we treat it as a possible
+ // drop for a launcher
+ const KUrl::List uris = KUrl::List::fromMimeData(event->mimeData());
+ if (!uris.isEmpty()) {
+ foreach (const QUrl &uri, uris) {
+ KUrl url(uri);
+ if (url.isLocalFile()) {
+ const QString path = url.toLocalFile();
+ QFileInfo info(path);
+ if (info.isDir() || !info.isExecutable()) {
+ return false;
+ break;
+ }
+ }
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
void AbstractTaskItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
- if (event->mimeData()->hasFormat(TaskManager::Task::mimetype()) ||
- event->mimeData()->hasFormat(TaskManager::Task::groupMimetype()) ||
- event->mimeData()->hasFormat("text/uri-list")) {
- event->ignore(); //ignore it so the taskbar gets the event
+ if (shouldIgnoreDragEvent(event)) {
+ event->ignore();
return;
}
diff --git a/plasma/desktop/applets/tasks/abstracttaskitem.h b/plasma/desktop/applets/tasks/abstracttaskitem.h
index fd8e31b..4b855f2 100644
--- a/plasma/desktop/applets/tasks/abstracttaskitem.h
+++ b/plasma/desktop/applets/tasks/abstracttaskitem.h
@@ -192,6 +192,7 @@ protected:
virtual void updateToolTip() = 0; // pure virtual function
QString expanderElement() const;
void stopWindowHoverEffect();
+ bool shouldIgnoreDragEvent(QGraphicsSceneDragDropEvent *event);
protected Q_SLOTS:
/** Event compression **/
diff --git a/plasma/desktop/applets/tasks/taskgroupitem.cpp b/plasma/desktop/applets/tasks/taskgroupitem.cpp
index 1a9fbcc..5f5794f 100644
--- a/plasma/desktop/applets/tasks/taskgroupitem.cpp
+++ b/plasma/desktop/applets/tasks/taskgroupitem.cpp
@@ -1047,11 +1047,8 @@ void TaskGroupItem::itemPositionChanged(AbstractGroupableItem * item)
void TaskGroupItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
//kDebug()<<"Drag enter";
- if (collapsed() &&
- (event->mimeData()->hasFormat(TaskManager::Task::mimetype()) ||
- event->mimeData()->hasFormat(TaskManager::Task::groupMimetype()) ||
- event->mimeData()->hasFormat("text/uri-list"))) {
- event->acceptProposedAction();
+ if (collapsed() && shouldIgnoreDragEvent(event)) {
+ event->ignore();
//kDebug()<<"Drag enter accepted";
} else {
event->accept();