1/*
2 * SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef KIRIGAMI_PLATFORMPLUGINFACTORY_H
8#define KIRIGAMI_PLATFORMPLUGINFACTORY_H
9
10#include <QObject>
11
12#include "kirigamiplatform_export.h"
13
14class QQmlEngine;
15
16namespace Kirigami
17{
18namespace Platform
19{
20class PlatformTheme;
21class Units;
22
23/*!
24 * \class Kirigami::Platform::PlatformPluginFactory
25 * \inheaderfile Kirigami/Platform/PlatformPluginFactory
26 * \inmodule KirigamiPlatform
27 *
28 * \brief This class is reimplemented by plugins to provide different implementations
29 * of PlatformTheme.
30 */
31class KIRIGAMIPLATFORM_EXPORT PlatformPluginFactory : public QObject
32{
33 Q_OBJECT
34
35public:
36 explicit PlatformPluginFactory(QObject *parent = nullptr);
37 ~PlatformPluginFactory() override;
38
39 /*!
40 * Creates an instance of PlatformTheme which can come out from
41 * an implementation provided by a plugin.
42 *
43 * If this returns nullptr the PlatformTheme will use a fallback
44 * implementation that loads a theme definition from a QML file.
45 *
46 * \a parent The parent object of the created PlatformTheme
47 */
48 virtual PlatformTheme *createPlatformTheme(QObject *parent) = 0;
49
50 /*!
51 * Creates an instance of Units which can come from an implementation
52 * provided by a plugin
53 *
54 * \a parent The parent of the units object
55 */
56 virtual Units *createUnits(QObject *parent) = 0;
57
58 /*!
59 * Finds the plugin providing units and platformtheme for the current style
60 * The plugin pointer is cached, so only the first call is a potentially heavy operation
61 *
62 * \a pluginName The name we want to search for, if empty the name of
63 * the current QtQuickControls style will be searched.
64 *
65 * Returns a pointer to the PlatformPluginFactory of the current style.
66 */
67 static PlatformPluginFactory *findPlugin(const QString &pluginName = {});
68};
69
70}
71}
72
73QT_BEGIN_NAMESPACE
74#define PlatformPluginFactory_iid "org.kde.kirigami.PlatformPluginFactory"
75Q_DECLARE_INTERFACE(Kirigami::Platform::PlatformPluginFactory, PlatformPluginFactory_iid)
76QT_END_NAMESPACE
77
78#endif // PLATFORMPLUGINFACTORY_H
79

source code of kirigami/src/platform/platformpluginfactory.h