Commit 020ac2de authored by Volker Krause's avatar Volker Krause
Browse files

Implement calendar plugin loading for non-Android

parent fb75ffb9
Pipeline #192012 passed with stage
in 5 minutes and 32 seconds
......@@ -9,6 +9,10 @@
#include "androidcalendarplugin.h"
#endif
#include <QCoreApplication>
#include <QDirIterator>
#include <QPluginLoader>
using namespace KCalendarCore;
struct PluginLoader {
......@@ -21,7 +25,21 @@ PluginLoader::PluginLoader()
#ifdef Q_OS_ANDROID
plugin.reset(new AndroidCalendarPlugin(nullptr, {}));
#else
// TODO
QStringList searchPaths(QCoreApplication::applicationDirPath());
searchPaths += QCoreApplication::libraryPaths();
for (const auto &searchPath : std::as_const(searchPaths)) {
const QString pluginPath = searchPath + QLatin1String("/kf" QT_STRINGIFY(QT_VERSION_MAJOR) "/org.kde.kcalendarcore.calendars");
for (QDirIterator it(pluginPath, QDir::Files); it.hasNext() && !plugin;) {
it.next();
QPluginLoader loader(it.fileInfo().absoluteFilePath());
if (loader.load()) {
plugin.reset(qobject_cast<KCalendarCore::CalendarPlugin*>(loader.instance()));
} else {
qDebug() << loader.errorString();
}
}
}
#endif
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment