File indexing completed on 2024-05-05 03:56:26
0001 /* 0002 * SPDX-FileCopyrightText: 2017 by Marco Martin <mart@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIRIGAMI_PLATFORMPLUGINFACTORY_H 0008 #define KIRIGAMI_PLATFORMPLUGINFACTORY_H 0009 0010 #include <QObject> 0011 0012 #include "kirigamiplatform_export.h" 0013 0014 class QQmlEngine; 0015 0016 namespace Kirigami 0017 { 0018 namespace Platform 0019 { 0020 class PlatformTheme; 0021 class Units; 0022 0023 /** 0024 * @class PlatformPluginFactory platformpluginfactory.h <Kirigami/PlatformPluginFactory> 0025 * 0026 * This class is reimpleented by plugins to provide different implementations 0027 * of PlatformTheme 0028 */ 0029 class KIRIGAMIPLATFORM_EXPORT PlatformPluginFactory : public QObject 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 explicit PlatformPluginFactory(QObject *parent = nullptr); 0035 ~PlatformPluginFactory() override; 0036 0037 /** 0038 * Creates an instance of PlatformTheme which can come out from 0039 * an implementation provided by a plugin 0040 * 0041 * If this returns nullptr the PlatformTheme will use a fallback 0042 * implementation that loads a theme definition from a QML file. 0043 * 0044 * @param parent the parent object of the created PlatformTheme 0045 */ 0046 virtual PlatformTheme *createPlatformTheme(QObject *parent) = 0; 0047 0048 /** 0049 * Creates an instance of Units which can come from an implementation 0050 * provided by a plugin 0051 * @param parent the parent of the units object 0052 */ 0053 virtual Units *createUnits(QObject *parent) = 0; 0054 0055 /** 0056 * finds the plugin providing units and platformtheme for the current style 0057 * The plugin pointer is cached, so only the first call is a potentially heavy operation 0058 * @param pluginName The name we want to search for, if empty the name of 0059 * the current QtQuickControls style will be searched 0060 * @return pointer to the PlatformPluginFactory of the current style 0061 */ 0062 static PlatformPluginFactory *findPlugin(const QString &pluginName = {}); 0063 }; 0064 0065 } 0066 } 0067 0068 QT_BEGIN_NAMESPACE 0069 #define PlatformPluginFactory_iid "org.kde.kirigami.PlatformPluginFactory" 0070 Q_DECLARE_INTERFACE(Kirigami::Platform::PlatformPluginFactory, PlatformPluginFactory_iid) 0071 QT_END_NAMESPACE 0072 0073 #endif // PLATFORMPLUGINFACTORY_H