Commit c801276a authored by Eike Hein's avatar Eike Hein
Browse files

Make drags from the Task Manager less prone to disaster

The Task Manager applet previously set a task's launcher URL as
generic URL MIME data of drags initiated from it. This made
everything that's willing to handle an URL drop a drop target
for drags from the Task Manager, which resulted e.g. in users
accidentally dropping .desktop files into chat apps that would
immediately send them as a message.

In truth, the utility of drags initiated from the Task Manager
is mostly confined to the shell: Adding apps to the desktop, to
the panel, to launcher menus (we don't have this currently but
should add it), and so on. It's therefore appropriate to use a
special internal MIME type for this payload instead of one as
generic as text/url. We already use special internal MIME types
to shuttle around window ids (for drops onto pagers, to assign
tasks to different virtual desktops or activities) and filter
out drops onto the Task Manager applet itself.

This patch makes the necessary changes in the Task Manager and
in the Folder View containment, which needs special care due to
its complex drop handling. A seperate patch will augment
ContainmentInterface::processMimeData to take care of the Desktop
and Panel containments (while compatible with the Folder View

This is an implementation of an idea by David Edmundson posted
in D13162.

Reviewers: davidedmundson, Zren

Subscribers: plasma-devel

Tags: #plasma

Differential Revision:
parent 9919bca4
......@@ -73,13 +73,11 @@ void DragHelper::startDragInternal(QQuickItem *item, const QString &mimeType,
QPointer<QQuickItem> grabber = item;
QList<QUrl> urlList;
QMimeData *dragData = new QMimeData();
const QByteArray &taskUrlData = Backend::tryDecodeApplicationsUrl(url).toString().toUtf8();
dragData->setData("text/x-orgkdeplasmataskmanager_taskurl", taskUrlData);
dragData->setData(mimeType, mimeData.toByteArray());
dragData->setData("application/x-orgkdeplasmataskmanager_taskbuttonitem", mimeData.toByteArray());
QDrag *drag = new QDrag(static_cast<QQuickItem *>(parent()));
......@@ -68,8 +68,9 @@ function effectiveNavDirection(flow, layoutDirection, direction) {
function isFileDrag(event) {
var taskUrl = event.mimeData.formats.indexOf("text/x-orgkdeplasmataskmanager_taskurl") != -1;
var arkService = event.mimeData.formats.indexOf("application/x-kde-ark-dndextract-service") != -1;
var arkPath = event.mimeData.formats.indexOf("application/x-kde-ark-dndextract-path") != -1;
return (event.mimeData.hasUrls || (arkService && arkPath));
return (event.mimeData.hasUrls || taskUrl || (arkService && arkPath));
......@@ -1107,6 +1107,11 @@ void FolderModel::drop(QQuickItem *target, QObject* dropEvent, int row)
// Catch drops from a Task Manager and convert to usable URL.
if (!mimeData->hasUrls() && mimeData->hasFormat(QStringLiteral("text/x-orgkdeplasmataskmanager_taskurl"))) {
QList<QUrl> urls = {QUrl(QString::fromUtf8(mimeData->data(QStringLiteral("text/x-orgkdeplasmataskmanager_taskurl"))))};
if (m_usedByContainment && !m_screenMapper->sharedDesktops()) {
if (isDropBetweenSharedViews(mimeData->urls(), dropTargetFolderUrl)) {
Supports Markdown
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