mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-23 21:05:44 +03:00
Dolphin shell integration: Renames the plugins
And put the helper in a shared library so it is shared accross both plugins
This commit is contained in:
parent
82d1d04774
commit
184412d88e
8 changed files with 24 additions and 279 deletions
|
@ -1,257 +0,0 @@
|
|||
From 47d99986d97a69582485e6b23c8c0b9018e8f2d5 Mon Sep 17 00:00:00 2001
|
||||
From: Olivier Goffart <ogoffart@woboq.com>
|
||||
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 <KJobWidgets>
|
||||
#include <KIO/JobUiDelegate>
|
||||
#include <KIO/PreviewJob>
|
||||
+#include <KServiceTypeTrader>
|
||||
|
||||
#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<KOverlayIconPlugin>(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<QByteArray, QVariant> 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<QByteArray, QVariant> 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 <QByteArray, QVariant> 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 <KFileItem>
|
||||
#include <kitemviews/kitemmodelbase.h>
|
||||
+#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<KOverlayIconPlugin*> 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 <ogoffart@woboq.com> *
|
||||
+ * *
|
||||
+ * 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 <ogoffart@woboq.com> *
|
||||
+ * *
|
||||
+ * 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 <dolphin_export.h>
|
||||
+#include <QtCore/QObject>
|
||||
+
|
||||
+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
|
||||
|
|
@ -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)
|
||||
#---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})
|
||||
|
||||
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})
|
||||
#---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})
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -64,4 +64,4 @@ public:
|
|||
K_PLUGIN_FACTORY(OwncloudDolphinPluginActionFactory, registerPlugin<OwncloudDolphinPluginAction>();)
|
||||
K_EXPORT_PLUGIN(OwncloudDolphinPluginActionFactory("ownclouddolhpinpluginaction"))
|
||||
|
||||
#include "ownclouddolphinpluginaction.moc"
|
||||
#include "ownclouddolphinactionplugin.moc"
|
|
@ -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
|
|
@ -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<QByteArray, QByteArray> StatusMap;
|
||||
|
@ -94,4 +94,4 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
#include "ownclouddolphinplugin.moc"
|
||||
#include "ownclouddolphinoverlayplugin.moc"
|
|
@ -21,8 +21,9 @@
|
|||
#include <QObject>
|
||||
#include <QBasicTimer>
|
||||
#include <QLocalSocket>
|
||||
#include "ownclouddolphinpluginhelper_export.h"
|
||||
|
||||
class OwncloudDolphinPluginHelper : public QObject {
|
||||
class OWNCLOUDDOLPHINPLUGINHELPER_EXPORT OwncloudDolphinPluginHelper : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static OwncloudDolphinPluginHelper *instance();
|
||||
|
|
Loading…
Reference in a new issue