Commit b4eca901 authored by Aaron J. Seigo's avatar Aaron J. Seigo

only accept drops of executables for launcher creation

CCBUG:261443

svn path=/branches/KDE/4.6/kdebase/workspace/; revision=1213907
parent 173b0d81
......@@ -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;
}
......
......@@ -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 **/
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment