From 96b46370f2f699add123912f6b9e5dc9185f0cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=8D=9A=E6=96=87?= Date: Thu, 23 Jun 2016 15:30:06 +0800 Subject: [PATCH] add drop to open file Change-Id: Icf959366f347533bf31b23b41cd61982583d1670 --- frame/dbus/dbusdockentry.h | 5 +++++ frame/item/appitem.cpp | 16 +++++++++++++++- frame/item/appitem.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/frame/dbus/dbusdockentry.h b/frame/dbus/dbusdockentry.h index 4272452dc..f2a3be571 100644 --- a/frame/dbus/dbusdockentry.h +++ b/frame/dbus/dbusdockentry.h @@ -89,6 +89,11 @@ public Q_SLOTS: // METHODS return asyncCall(QStringLiteral("HandleMenuItem"), item); } + inline QDBusPendingReply<> HandleDragDrop(const QStringList &uriList) + { + return asyncCall(QStringLiteral("HandleDragDrop"), QVariant::fromValue(uriList)); + } + inline QDBusPendingReply<> RequestDock() { return asyncCall(QStringLiteral("RequestDock")); diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index b4a99cc56..0c0334201 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -185,7 +185,21 @@ void AppItem::resizeEvent(QResizeEvent *e) void AppItem::dragEnterEvent(QDragEnterEvent *e) { - qDebug() << e; + // ignore drag from panel + if (e->source()) + return; + + e->accept(); +} + +void AppItem::dropEvent(QDropEvent *e) +{ + QStringList uriList; + for (auto uri : e->mimeData()->urls()) + uriList << uri.toString(); + +// qDebug() << uriList; + m_itemEntry->HandleDragDrop(uriList); } void AppItem::invokedMenuItem(const QString &itemId, const bool checked) diff --git a/frame/item/appitem.h b/frame/item/appitem.h index a836861c7..540919e28 100644 --- a/frame/item/appitem.h +++ b/frame/item/appitem.h @@ -25,6 +25,7 @@ private: void mouseMoveEvent(QMouseEvent *e); void resizeEvent(QResizeEvent *e); void dragEnterEvent(QDragEnterEvent *e); + void dropEvent(QDropEvent *e); void invokedMenuItem(const QString &itemId, const bool checked); const QString contextMenu() const;