From 184412d88e80da168efac4a7f31fca592066d898 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 19 Oct 2015 15:22:27 +0200 Subject: [PATCH] Dolphin shell integration: Renames the plugins And put the helper in a shared library so it is shared accross both plugins --- .../dolphin_kf5/0001-KOverlayIconPlugin.patch | 257 ------------------ shell_integration/dolphin_kf5/CMakeLists.txt | 32 ++- shell_integration/dolphin_kf5/README | 5 +- ...on.cpp => ownclouddolphinactionplugin.cpp} | 2 +- ...op => ownclouddolphinactionplugin.desktop} | 2 +- ...n.cpp => ownclouddolphinoverlayplugin.cpp} | 4 +- ...json => ownclouddolphinoverlayplugin.json} | 0 .../dolphin_kf5/ownclouddolphinpluginhelper.h | 3 +- 8 files changed, 25 insertions(+), 280 deletions(-) delete mode 100644 shell_integration/dolphin_kf5/0001-KOverlayIconPlugin.patch rename shell_integration/dolphin_kf5/{ownclouddolphinpluginaction.cpp => ownclouddolphinactionplugin.cpp} (98%) rename shell_integration/dolphin_kf5/{ownclouddolphinpluginaction.desktop => ownclouddolphinactionplugin.desktop} (76%) rename shell_integration/dolphin_kf5/{ownclouddolphinplugin.cpp => ownclouddolphinoverlayplugin.cpp} (97%) rename shell_integration/dolphin_kf5/{ownclouddolphinplugin.json => ownclouddolphinoverlayplugin.json} (100%) diff --git a/shell_integration/dolphin_kf5/0001-KOverlayIconPlugin.patch b/shell_integration/dolphin_kf5/0001-KOverlayIconPlugin.patch deleted file mode 100644 index 96a2f5dcd..000000000 --- a/shell_integration/dolphin_kf5/0001-KOverlayIconPlugin.patch +++ /dev/null @@ -1,257 +0,0 @@ -From 47d99986d97a69582485e6b23c8c0b9018e8f2d5 Mon Sep 17 00:00:00 2001 -From: Olivier Goffart -Date: Mon, 7 Sep 2015 17:47:53 +0200 -Subject: [PATCH] WIP: KOverlayIconPlugin - ---- - src/CMakeLists.txt | 4 +- - src/kitemviews/kfileitemmodelrolesupdater.cpp | 35 ++++++++++++- - src/kitemviews/kfileitemmodelrolesupdater.h | 8 +++ - src/views/versioncontrol/koverlayiconplugin.cpp | 29 +++++++++++ - .../versioncontrol/koverlayiconplugin.desktop | 4 ++ - src/views/versioncontrol/koverlayiconplugin.h | 57 ++++++++++++++++++++++ - 6 files changed, 135 insertions(+), 2 deletions(-) - create mode 100644 src/views/versioncontrol/koverlayiconplugin.cpp - create mode 100644 src/views/versioncontrol/koverlayiconplugin.desktop - create mode 100644 src/views/versioncontrol/koverlayiconplugin.h - -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index e0f91de..69f3d50 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -20,6 +20,7 @@ remove_definitions( - - set(dolphinvcs_LIB_SRCS - views/versioncontrol/kversioncontrolplugin.cpp -+ views/versioncontrol/koverlayiconplugin.cpp - ) - - add_library(dolphinvcs ${dolphinvcs_LIB_SRCS}) -@@ -40,6 +41,7 @@ set_target_properties(dolphinvcs PROPERTIES - ecm_generate_headers(dolphinvcs_LIB_HEADERS - HEADER_NAMES - KVersionControlPlugin -+ KOverlayIconPlugin - - RELATIVE "views/versioncontrol" - REQUIRED_HEADERS dolphinvcs_LIB_HEADERS -@@ -47,7 +49,7 @@ ecm_generate_headers(dolphinvcs_LIB_HEADERS - - install(TARGETS dolphinvcs EXPORT DolphinVcsTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) - --install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR}) -+install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop views/versioncontrol/koverlayiconplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dolphin_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR} COMPONENT Devel) - install(FILES ${dolphinvcs_LIB_HEADERS} DESTINATION "${KDE_INSTALL_INCLUDEDIR}/Dolphin" COMPONENT Devel) - -diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp -index b03fd9c..ed24587 100644 ---- a/src/kitemviews/kfileitemmodelrolesupdater.cpp -+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp -@@ -29,6 +29,7 @@ - #include - #include - #include -+#include - - #include "private/kpixmapmodifier.h" - #include "private/kdirectorycontentscounter.h" -@@ -129,6 +130,19 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO - m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this); - connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result, - this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived); -+ -+ const KService::List pluginServices = KServiceTypeTrader::self()->query("KOverlayIconPlugin"); -+ -+ for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) { -+ QString error; -+ KOverlayIconPlugin* plugin = (*it)->createInstance(this, QVariantList(), &error); -+ if (plugin) { -+ m_overlayIconsPlugin.append(plugin); -+ connect(plugin, &KOverlayIconPlugin::overlaysChanged, this, &KFileItemModelRolesUpdater::slotOverlaysChanged); -+ } /*else { -+ qWarning() << "Could not load plugin " << (*it)->name() << ":" << error; -+ }*/ -+ } - } - - KFileItemModelRolesUpdater::~KFileItemModelRolesUpdater() -@@ -1065,7 +1079,11 @@ QHash KFileItemModelRolesUpdater::rolesData(const KFileIte - data.insert("type", item.mimeComment()); - } - -- data.insert("iconOverlays", item.overlays()); -+ QStringList overlays = item.overlays(); -+ foreach(KOverlayIconPlugin *it, m_overlayIconsPlugin) { -+ overlays.append(it->getOverlays(item)); -+ } -+ data.insert("iconOverlays", overlays); - - #ifdef HAVE_BALOO - if (m_balooFileMonitor) { -@@ -1076,6 +1094,21 @@ QHash KFileItemModelRolesUpdater::rolesData(const KFileIte - return data; - } - -+void KFileItemModelRolesUpdater::slotOverlaysChanged(const QUrl& url, const QStringList &) -+{ -+ KFileItem item = m_model->fileItem(url); -+ if (item.isNull()) -+ return; -+ int index = m_model->index(item); -+ QHash data = m_model->data(index); -+ QStringList overlays = item.overlays(); -+ foreach (KOverlayIconPlugin *it, m_overlayIconsPlugin) { -+ overlays.append(it->getOverlays(item)); -+ } -+ data.insert("iconOverlays", overlays); -+ m_model->setData(index, data); -+} -+ - void KFileItemModelRolesUpdater::updateAllPreviews() - { - if (m_state == Paused) { -diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h -index 216b0a5..98fb305 100644 ---- a/src/kitemviews/kfileitemmodelrolesupdater.h -+++ b/src/kitemviews/kfileitemmodelrolesupdater.h -@@ -24,6 +24,7 @@ - - #include - #include -+#include "views/versioncontrol/koverlayiconplugin.h" - - #include "dolphin_export.h" - -@@ -183,6 +184,11 @@ private slots: - void slotPreviewJobFinished(); - - /** -+ * Is invoked when one of the KOverlayIconPlugin emit the signal that an overlay has changed -+ */ -+ void slotOverlaysChanged(const QUrl& url, const QStringList&); -+ -+ /** - * Resolves the sort role of the next item in m_pendingSortRole, applies it - * to the model, and invokes itself if there are any pending items left. If - * that is not the case, \a startUpdating() is called. -@@ -333,6 +339,8 @@ private: - - KDirectoryContentsCounter* m_directoryContentsCounter; - -+ QList m_overlayIconsPlugin; -+ - #ifdef HAVE_BALOO - Baloo::FileMonitor* m_balooFileMonitor; - #endif -diff --git a/src/views/versioncontrol/koverlayiconplugin.cpp b/src/views/versioncontrol/koverlayiconplugin.cpp -new file mode 100644 -index 0000000..1ff7914 ---- /dev/null -+++ b/src/views/versioncontrol/koverlayiconplugin.cpp -@@ -0,0 +1,29 @@ -+/***************************************************************************** -+ * Copyright (C) 2014 by Olivier Goffart * -+ * * -+ * This library is free software; you can redistribute it and/or * -+ * modify it under the terms of the GNU Library General Public * -+ * License version 2 as published by the Free Software Foundation. * -+ * * -+ * This library is distributed in the hope that it will be useful, * -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of * -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * -+ * Library General Public License for more details. * -+ * * -+ * You should have received a copy of the GNU Library General Public License * -+ * along with this library; see the file COPYING.LIB. If not, write to * -+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -+ * Boston, MA 02110-1301, USA. * -+ *****************************************************************************/ -+ -+#include "koverlayiconplugin.h" -+ -+KOverlayIconPlugin::KOverlayIconPlugin(QObject* parent) : QObject(parent) -+{ -+} -+ -+KOverlayIconPlugin::~KOverlayIconPlugin() -+{ -+} -+ -+#include "koverlayiconplugin.moc" -diff --git a/src/views/versioncontrol/koverlayiconplugin.desktop b/src/views/versioncontrol/koverlayiconplugin.desktop -new file mode 100644 -index 0000000..65a1170 ---- /dev/null -+++ b/src/views/versioncontrol/koverlayiconplugin.desktop -@@ -0,0 +1,4 @@ -+[Desktop Entry] -+Type=ServiceType -+X-KDE-ServiceType=KOverlayIconPlugin -+Comment=Plugin to add overlay icons in Dolphin -diff --git a/src/views/versioncontrol/koverlayiconplugin.h b/src/views/versioncontrol/koverlayiconplugin.h -new file mode 100644 -index 0000000..889bf30 ---- /dev/null -+++ b/src/views/versioncontrol/koverlayiconplugin.h -@@ -0,0 +1,57 @@ -+/***************************************************************************** -+ * Copyright (C) 2014 by Olivier Goffart * -+ * * -+ * This library is free software; you can redistribute it and/or * -+ * modify it under the terms of the GNU Library General Public * -+ * License version 2 as published by the Free Software Foundation. * -+ * * -+ * This library is distributed in the hope that it will be useful, * -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of * -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * -+ * Library General Public License for more details. * -+ * * -+ * You should have received a copy of the GNU Library General Public License * -+ * along with this library; see the file COPYING.LIB. If not, write to * -+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -+ * Boston, MA 02110-1301, USA. * -+ *****************************************************************************/ -+ -+ -+#ifndef OverlayIconPlugin_H -+#define OverlayIconPlugin_H -+ -+#include -+#include -+ -+class KUrl; -+class KFileItem; -+ -+/** -+ * @brief Base class for overlay icon plugins. -+ * -+ * Enables the file manager to show custom overlay icons on files. -+ * -+ * To write a custom plugin you need to create a .desktop file for your plugin with -+ * KDE-ServiceTypes=KOverlayIconPlugin -+ */ -+class DOLPHIN_EXPORT KOverlayIconPlugin : public QObject { -+ Q_OBJECT -+ void *d; -+public: -+ explicit KOverlayIconPlugin(QObject *parent = 0); -+ ~KOverlayIconPlugin(); -+ -+ /** -+ * Returns a list of overlay pixmap to add to a file -+ * This can be a path to an icon, or the icon name -+ */ -+ virtual QStringList getOverlays(const KFileItem &item) = 0; -+signals: -+ -+ /** -+ * Emit this signal when the list of overlay icon changed for a given URL -+ */ -+ void overlaysChanged(const QUrl &url, const QStringList &overlays); -+}; -+ -+#endif --- -2.5.1 - diff --git a/shell_integration/dolphin_kf5/CMakeLists.txt b/shell_integration/dolphin_kf5/CMakeLists.txt index 23286c1a6..fdcf5eaac 100644 --- a/shell_integration/dolphin_kf5/CMakeLists.txt +++ b/shell_integration/dolphin_kf5/CMakeLists.txt @@ -3,18 +3,15 @@ project(dolphin-owncloud) cmake_minimum_required(VERSION 2.8.12) include(FeatureSummary) set(QT_MIN_VERSION "5.3.0") -set(KF5_MIN_VERSION "5.0.0") +set(KF5_MIN_VERSION "5.16.0") find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Network) find_package(ECM 1.2.0 REQUIRED CONFIG) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS CoreAddons KIO) - - set_package_properties(DolphinVcs PROPERTIES DESCRIPTION "the Dolphin plugin library" URL "http://dolphin.kde.org/" @@ -26,17 +23,24 @@ include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings) include(ECMMarkNonGuiExecutable) +include(GenerateExportHeader) include_directories(${CMAKE_CURRENT_BINARY_DIR}) - - add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) -kcoreaddons_add_plugin(ownclouddolphinplugin INSTALL_NAMESPACE "kf5/overlayicon" JSON ownclouddolphinplugin.json - SOURCES ownclouddolphinplugin.cpp ownclouddolphinpluginhelper.cpp) -target_link_libraries(ownclouddolphinplugin Qt5::Network KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets) - -add_library(ownclouddolphinpluginaction MODULE ownclouddolphinpluginaction.cpp ownclouddolphinpluginhelper.cpp) -target_link_libraries(ownclouddolphinpluginaction Qt5::Network KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets) -install(FILES ownclouddolphinpluginaction.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) -install(TARGETS ownclouddolphinpluginaction DESTINATION ${KDE_INSTALL_PLUGINDIR}) +#---HELPER--- +add_library(ownclouddolphinpluginhelper SHARED ownclouddolphinpluginhelper.cpp) +target_link_libraries(ownclouddolphinpluginhelper Qt5::Network) +generate_export_header(ownclouddolphinpluginhelper) +install(TARGETS ownclouddolphinpluginhelper LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +#---OVERLAY PLUGIN--- +kcoreaddons_add_plugin(ownclouddolphinoverlayplugin INSTALL_NAMESPACE "kf5/overlayicon" + JSON ownclouddolphinoverlayplugin.json SOURCES ownclouddolphinoverlayplugin.cpp) +target_link_libraries(ownclouddolphinoverlayplugin KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets ownclouddolphinpluginhelper) + +#---ACTION PLUGIN--- +add_library(ownclouddolphinactionplugin MODULE ownclouddolphinactionplugin.cpp) +target_link_libraries(ownclouddolphinactionplugin KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets ownclouddolphinpluginhelper) +install(FILES ownclouddolphinactionplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) +install(TARGETS ownclouddolphinactionplugin DESTINATION ${KDE_INSTALL_PLUGINDIR}) diff --git a/shell_integration/dolphin_kf5/README b/shell_integration/dolphin_kf5/README index e95c0e1d4..8dc789781 100644 --- a/shell_integration/dolphin_kf5/README +++ b/shell_integration/dolphin_kf5/README @@ -1,9 +1,6 @@ -- The patch 0001-KOverlayIconPlugin.patch should be applied to kde-baseapps git repository -(It should applies to frameworks branch) - -- Recompile and install dolphin (frameworks branch) +- Recompile and install recent enough version of dolphin and kio (git from oct 2015) - Build and install the plugin diff --git a/shell_integration/dolphin_kf5/ownclouddolphinpluginaction.cpp b/shell_integration/dolphin_kf5/ownclouddolphinactionplugin.cpp similarity index 98% rename from shell_integration/dolphin_kf5/ownclouddolphinpluginaction.cpp rename to shell_integration/dolphin_kf5/ownclouddolphinactionplugin.cpp index 9299156e9..f39e069c5 100644 --- a/shell_integration/dolphin_kf5/ownclouddolphinpluginaction.cpp +++ b/shell_integration/dolphin_kf5/ownclouddolphinactionplugin.cpp @@ -64,4 +64,4 @@ public: K_PLUGIN_FACTORY(OwncloudDolphinPluginActionFactory, registerPlugin();) K_EXPORT_PLUGIN(OwncloudDolphinPluginActionFactory("ownclouddolhpinpluginaction")) -#include "ownclouddolphinpluginaction.moc" +#include "ownclouddolphinactionplugin.moc" diff --git a/shell_integration/dolphin_kf5/ownclouddolphinpluginaction.desktop b/shell_integration/dolphin_kf5/ownclouddolphinactionplugin.desktop similarity index 76% rename from shell_integration/dolphin_kf5/ownclouddolphinpluginaction.desktop rename to shell_integration/dolphin_kf5/ownclouddolphinactionplugin.desktop index 5cc4589a0..bf60f79da 100644 --- a/shell_integration/dolphin_kf5/ownclouddolphinpluginaction.desktop +++ b/shell_integration/dolphin_kf5/ownclouddolphinactionplugin.desktop @@ -3,4 +3,4 @@ Type=Service Name=OwncloudAction ServiceTypes=KFileItemAction/Plugin MimeType=application/octet-stream;inode/directory; -X-KDE-Library=ownclouddolphinpluginaction +X-KDE-Library=ownclouddolphinactionplugin diff --git a/shell_integration/dolphin_kf5/ownclouddolphinplugin.cpp b/shell_integration/dolphin_kf5/ownclouddolphinoverlayplugin.cpp similarity index 97% rename from shell_integration/dolphin_kf5/ownclouddolphinplugin.cpp rename to shell_integration/dolphin_kf5/ownclouddolphinoverlayplugin.cpp index 983cb9628..f949a38a9 100644 --- a/shell_integration/dolphin_kf5/ownclouddolphinplugin.cpp +++ b/shell_integration/dolphin_kf5/ownclouddolphinoverlayplugin.cpp @@ -26,7 +26,7 @@ class OwncloudDolphinPlugin : public KOverlayIconPlugin { - Q_PLUGIN_METADATA(IID "com.owncloud.ovarlayiconplugin" FILE "ownclouddolphinplugin.json"); + Q_PLUGIN_METADATA(IID "com.owncloud.ovarlayiconplugin" FILE "ownclouddolphinoverlayplugin.json"); Q_OBJECT typedef QHash StatusMap; @@ -94,4 +94,4 @@ private: } }; -#include "ownclouddolphinplugin.moc" +#include "ownclouddolphinoverlayplugin.moc" diff --git a/shell_integration/dolphin_kf5/ownclouddolphinplugin.json b/shell_integration/dolphin_kf5/ownclouddolphinoverlayplugin.json similarity index 100% rename from shell_integration/dolphin_kf5/ownclouddolphinplugin.json rename to shell_integration/dolphin_kf5/ownclouddolphinoverlayplugin.json diff --git a/shell_integration/dolphin_kf5/ownclouddolphinpluginhelper.h b/shell_integration/dolphin_kf5/ownclouddolphinpluginhelper.h index e8386df77..26762caaf 100644 --- a/shell_integration/dolphin_kf5/ownclouddolphinpluginhelper.h +++ b/shell_integration/dolphin_kf5/ownclouddolphinpluginhelper.h @@ -21,8 +21,9 @@ #include #include #include +#include "ownclouddolphinpluginhelper_export.h" -class OwncloudDolphinPluginHelper : public QObject { +class OWNCLOUDDOLPHINPLUGINHELPER_EXPORT OwncloudDolphinPluginHelper : public QObject { Q_OBJECT public: static OwncloudDolphinPluginHelper *instance(); -- 2.30.2