summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Pescosta <[email protected]>2015-02-25 12:17:11 +0100
committerEmmanuel Pescosta <[email protected]>2015-02-26 14:43:20 +0100
commit37e6cdc3c6610a4908b171a6962a98f6c3d63486 (patch)
treec108baf1e0f1555a89957ff7e676bb9621565caf
parent8e77acc012e085d2f6cf30f1031af27292a6523d (diff)
Port the dolphin drobox plugin to Dolphin's KVersionControl interface and KF5
REVIEW: 122688
-rw-r--r--CMakeLists.txt66
-rw-r--r--dropbox/CMakeLists.txt19
-rw-r--r--dropbox/fileviewdropboxplugin.cpp25
-rw-r--r--dropbox/fileviewdropboxplugin.h20
4 files changed, 82 insertions, 48 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b400ef5..b02cfdd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,21 +1,47 @@
-cmake_minimum_required(VERSION 2.6)
project(dolphin-plugins)
-find_package(KDE4 REQUIRED)
-include(KDE4Defaults)
-include(MacroLibrary)
-
-add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
-add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
-include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${KDEPIMLIBS_INCLUDE_DIR})
-
-macro_optional_find_package(LibKonq REQUIRED)
-macro_log_feature(LIBKONQ_FOUND "KDE-Base/LibKonq" "Provides high-level file management functions." "http://dolphin.kde.org/" FALSE "" "Required to build the Dolphin version control plugins.")
-
-if(LIBKONQ_FOUND)
- macro_optional_add_subdirectory(svn)
- macro_optional_add_subdirectory(git)
- macro_optional_add_subdirectory(hg)
- macro_optional_add_subdirectory(bazaar)
- macro_optional_add_subdirectory(dropbox)
-endif(LIBKONQ_FOUND)
-macro_display_feature_log()
+
+cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
+
+include(FeatureSummary)
+
+set(QT_MIN_VERSION "5.0.0")
+set(KF5_MIN_VERSION "5.0.0")
+set(ECM_MIN_VERSION "0.0.11")
+
+find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+ Core
+ Widgets
+ Network
+)
+
+find_package(ECM ${ECM_MIN_VERSION} REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
+ XmlGui
+ I18n
+ KIO
+)
+
+find_package(DolphinVcs)
+set_package_properties(DolphinVcs PROPERTIES
+ DESCRIPTION "the Dolphin version control plugin library"
+ URL "http://dolphin.kde.org/"
+ TYPE REQUIRED
+ PURPOSE "Provides the version control plugin interface."
+)
+
+include(KDEInstallDirs)
+include(KDECMakeSettings)
+include(KDECompilerSettings)
+include(ECMMarkNonGuiExecutable)
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+#add_subdirectory(svn)
+#add_subdirectory(git)
+#add_subdirectory(hg)
+#add_subdirectory(bazaar)
+add_subdirectory(dropbox)
+
+feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
diff --git a/dropbox/CMakeLists.txt b/dropbox/CMakeLists.txt
index 4733f5a..83f2512 100644
--- a/dropbox/CMakeLists.txt
+++ b/dropbox/CMakeLists.txt
@@ -1,12 +1,21 @@
project(fileviewdropboxplugin)
-include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ${LIBKONQ_INCLUDE_DIR} )
+add_definitions(-DTRANSLATION_DOMAIN=\"fileviewdropboxplugin\")
set(fileviewdropboxplugin_SRCS
fileviewdropboxplugin.cpp
)
-kde4_add_plugin(fileviewdropboxplugin ${fileviewdropboxplugin_SRCS})
-target_link_libraries(fileviewdropboxplugin ${KDE4_KIO_LIBS} ${LIBKONQ_LIBRARY})
-install(FILES fileviewdropboxplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
-install(TARGETS fileviewdropboxplugin DESTINATION ${PLUGIN_INSTALL_DIR}) \ No newline at end of file
+add_library(fileviewdropboxplugin MODULE ${fileviewdropboxplugin_SRCS})
+target_link_libraries(fileviewdropboxplugin
+ Qt5::Core
+ Qt5::Widgets
+ Qt5::Network
+ KF5::I18n
+ KF5::XmlGui
+ KF5::KIOCore
+ DolphinVcs
+)
+
+install(FILES fileviewdropboxplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
+install(TARGETS fileviewdropboxplugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
diff --git a/dropbox/fileviewdropboxplugin.cpp b/dropbox/fileviewdropboxplugin.cpp
index 3496ce1..e54547a 100644
--- a/dropbox/fileviewdropboxplugin.cpp
+++ b/dropbox/fileviewdropboxplugin.cpp
@@ -20,7 +20,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
*****************************************************************************/
-#include <KAction>
#include <KFileItem>
#include <KFileItemListProperties>
#include <KLocalizedString>
@@ -31,11 +30,11 @@
#include <QPointer>
#include <QLocalSocket>
#include <QFileSystemWatcher>
+#include <QStringBuilder>
#include "fileviewdropboxplugin.h"
K_PLUGIN_FACTORY(FileViewDropboxPluginFactory, registerPlugin<FileViewDropboxPlugin>();)
-K_EXPORT_PLUGIN(FileViewDropboxPluginFactory("fileviewdropboxplugin"))
class FileViewDropboxPlugin::Private
{
@@ -57,19 +56,19 @@ public:
QPointer<KActionCollection> contextActions;
};
-QMap<QString, KVersionControlPlugin2::ItemVersion> FileViewDropboxPlugin::m_itemVersions;
+QMap<QString, KVersionControlPlugin::ItemVersion> FileViewDropboxPlugin::m_itemVersions;
FileViewDropboxPlugin::FileViewDropboxPlugin(QObject* parent, const QVariantList& args):
- KVersionControlPlugin2(parent),
+ KVersionControlPlugin(parent),
d(new Private(this))
{
Q_UNUSED(args);
if (m_itemVersions.isEmpty()) {
- m_itemVersions.insert("up to date", KVersionControlPlugin2::NormalVersion);
- m_itemVersions.insert("syncing", KVersionControlPlugin2::UpdateRequiredVersion);
- m_itemVersions.insert("unsyncable", KVersionControlPlugin2::ConflictingVersion);
- m_itemVersions.insert("unwatched", KVersionControlPlugin2::UnversionedVersion);
+ m_itemVersions.insert("up to date", KVersionControlPlugin::NormalVersion);
+ m_itemVersions.insert("syncing", KVersionControlPlugin::UpdateRequiredVersion);
+ m_itemVersions.insert("unsyncable", KVersionControlPlugin::ConflictingVersion);
+ m_itemVersions.insert("unwatched", KVersionControlPlugin::UnversionedVersion);
}
const QString dropboxDir = QDir::home().path() % QDir::separator() % fileName() % QDir::separator();
@@ -105,16 +104,16 @@ bool FileViewDropboxPlugin::beginRetrieval(const QString& directory)
return connectWithDropbox(d->itemStateSocket, LongTimeout);
}
-KVersionControlPlugin2::ItemVersion FileViewDropboxPlugin::itemVersion(const KFileItem& item) const
+KVersionControlPlugin::ItemVersion FileViewDropboxPlugin::itemVersion(const KFileItem& item) const
{
const QStringList reply = sendCommand("icon_overlay_file_status\npath\t", QStringList() << QDir(item.localPath()).canonicalPath(),
d->itemStateSocket, WaitForReply, LongTimeout);
if(reply.count() < 2) {
// file/dir is not served by dropbox
- return KVersionControlPlugin2::UnversionedVersion;
+ return KVersionControlPlugin::UnversionedVersion;
}
- return m_itemVersions.value(reply.at(1), KVersionControlPlugin2::UnversionedVersion);
+ return m_itemVersions.value(reply.at(1), KVersionControlPlugin::UnversionedVersion);
}
void FileViewDropboxPlugin::endRetrieval()
@@ -150,10 +149,10 @@ QList<QAction*> FileViewDropboxPlugin::actions(const KFileItemList& items) const
const QStringList options = replyLine.split("~");
if (options.count() > 2) {
- KAction* action = d->contextActions->addAction(options.at(2));
+ QAction* action = d->contextActions->addAction(options.at(2));
action->setText(options.at(0));
action->setToolTip(options.at(1));
- action->setIcon(KIcon("dropbox"));
+ action->setIcon(QIcon::fromTheme("dropbox"));
}
}
diff --git a/dropbox/fileviewdropboxplugin.h b/dropbox/fileviewdropboxplugin.h
index 162e035..700d05a 100644
--- a/dropbox/fileviewdropboxplugin.h
+++ b/dropbox/fileviewdropboxplugin.h
@@ -23,7 +23,7 @@
#ifndef FILEVIEWDROPBOXPLUGIN_H
#define FILEVIEWDROPBOXPLUGIN_H
-#include <kversioncontrolplugin2.h>
+#include <Dolphin/KVersionControlPlugin>
#include <QMap>
@@ -34,9 +34,9 @@ class QLocalSocket;
//Thanks Steffen Schuldenzucker!
/**
- * @brief Dropbox implementation for the KVersionControlPlugin2 interface.
+ * @brief Dropbox implementation for the KVersionControlPlugin interface.
*/
-class FileViewDropboxPlugin : public KVersionControlPlugin2
+class FileViewDropboxPlugin : public KVersionControlPlugin
{
Q_OBJECT
@@ -55,15 +55,15 @@ private:
public:
FileViewDropboxPlugin(QObject* parent, const QVariantList& args);
- virtual ~FileViewDropboxPlugin();
+ ~FileViewDropboxPlugin() override;
- virtual QString fileName() const;
+ QString fileName() const override;
- virtual bool beginRetrieval(const QString& directory);
- virtual KVersionControlPlugin2::ItemVersion itemVersion(const KFileItem& item) const;
- virtual void endRetrieval();
+ bool beginRetrieval(const QString& directory) override;
+ KVersionControlPlugin::ItemVersion itemVersion(const KFileItem& item) const override;
+ void endRetrieval() override;
- virtual QList<QAction*> actions(const KFileItemList& items) const;
+ QList<QAction*> actions(const KFileItemList& items) const override;
private slots:
void handleContextAction(QAction* action);
@@ -81,7 +81,7 @@ private:
class Private;
Private* const d;
- static QMap<QString, KVersionControlPlugin2::ItemVersion> m_itemVersions;
+ static QMap<QString, KVersionControlPlugin::ItemVersion> m_itemVersions;
};
#endif // FILEVIEWDROPBOXPLUGIN_H