diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ ) find_package(KF5 ${KF5_MIN_VERSION} OPTIONAL_COMPONENTS Activities + Purpose ) find_package(Phonon4Qt5 CONFIG REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -278,6 +278,7 @@ KF5::DBusAddons KF5::Notifications Phonon::phonon4qt5 + KF5::PurposeWidgets ) if (KF5Activities_FOUND) diff --git a/src/dolphincontextmenu.h b/src/dolphincontextmenu.h --- a/src/dolphincontextmenu.h +++ b/src/dolphincontextmenu.h @@ -25,13 +25,15 @@ #include #include +#include class QAction; class DolphinMainWindow; class KFileItemActions; class KFileItemListProperties; class DolphinRemoveAction; + /** * @brief Represents the context menu which appears when doing a right * click on an item or the viewport of the file manager. @@ -167,6 +169,8 @@ Command m_command; DolphinRemoveAction* m_removeAction; // Action that represents either 'Move To Trash' or 'Delete' + + Purpose::Menu* m_shareMenu; }; #endif diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -54,6 +54,10 @@ #include #include #include +#include +#include +#include +#include DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, const QPoint& pos, @@ -71,12 +75,17 @@ m_copyToMenu(parent), m_customActions(), m_command(None), - m_removeAction(nullptr) + m_removeAction(nullptr), + m_shareMenu(new Purpose::Menu()) { // The context menu either accesses the URLs of the selected items // or the items itself. To increase the performance both lists are cached. const DolphinView* view = m_mainWindow->activeViewContainer()->view(); m_selectedItems = view->selectedItems(); + + m_shareMenu->setTitle(i18n("Share")); + m_shareMenu->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); + m_shareMenu->model()->setPluginType(QStringLiteral("Export")); } DolphinContextMenu::~DolphinContextMenu() @@ -304,6 +313,19 @@ m_copyToMenu.addActionsTo(this); } + QJsonArray urlsJson; + + for (QUrl url : m_selectedItems.targetUrlList()) { + urlsJson.append(url.toString()); + } + + m_shareMenu->model()->setInputData(QJsonObject{ + { QStringLiteral("mimeType"), QJsonValue{QStringLiteral("*/*")} }, + { QStringLiteral("urls"), urlsJson } + }); + m_shareMenu->reload(); + addMenu(m_shareMenu); + // insert 'Properties...' entry QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); addAction(propertiesAction);