Commit 7e1b8f2e authored by Volker Krause's avatar Volker Krause
Browse files

Add KCalendarCore calendar plugin loader

This is only handling Android so far, and there it's using the built-in
platform calendar backend.
parent a567775a
......@@ -5,6 +5,7 @@ add_library(KCalendarCoreExtras)
generate_export_header(KCalendarCoreExtras BASE_NAME KCalendarCoreExtras)
target_sources(KCalendarCoreExtras PRIVATE
calendarmodel.cpp
)
if (ANDROID)
......
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "calendarpluginloader.h"
#ifdef Q_OS_ANDROID
#include "androidcalendarplugin.h"
#endif
using namespace KCalendarCore;
struct PluginLoader {
PluginLoader();
std::unique_ptr<KCalendarCore::CalendarPlugin> plugin;
};
PluginLoader::PluginLoader()
{
#ifdef Q_OS_ANDROID
plugin.reset(new AndroidCalendarPlugin(nullptr, {}));
#else
// TODO
#endif
}
Q_GLOBAL_STATIC(PluginLoader, s_pluginLoader)
bool CalendarPluginLoader::hasPlugin()
{
return (bool)s_pluginLoader->plugin;
}
KCalendarCore::CalendarPlugin* CalendarPluginLoader::plugin()
{
return s_pluginLoader->plugin.get();
}
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KCALENDARCORE_CALENDARPLUGINLOADER_H
#define KCALENDARCORE_CALENDARPLUGINLOADER_H
#include "kcalendarcoreextras_export.h"
#include <KCalendarCore/CalendarPlugin>
namespace KCalendarCore {
/** Access to KCalendarCore::CalendarPlugin instances. */
class KCALENDARCOREEXTRAS_EXPORT CalendarPluginLoader
{
Q_GADGET
Q_PROPERTY(bool hasPlugin READ hasPlugin)
Q_PROPERTY(KCalendarCore::CalendarPlugin* plugin READ plugin)
public:
/** Returns @c true if there is a platform calendar available. */
static bool hasPlugin();
/** Returns the platform calendar plugin. */
static KCalendarCore::CalendarPlugin *plugin();
};
}
#endif // KCALENDARCORE_CALENDARPLUGINLOADER_H
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