File indexing completed on 2024-04-14 14:18:22
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> 0004 SPDX-FileCopyrightText: 2002-2003 Daniel Molkentin <molkentin@kde.org> 0005 SPDX-FileCopyrightText: 2006 Matthias Kretz <kretz@kde.org> 0006 SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de> 0007 0008 SPDX-License-Identifier: LGPL-2.0-only 0009 */ 0010 0011 #ifndef KCMODULELOADER_H 0012 #define KCMODULELOADER_H 0013 0014 #include <KCModule> 0015 #include <KPluginMetaData> 0016 0017 #include <kcmoduledata.h> 0018 #include <kcmoduleinfo.h> 0019 0020 class QWidget; 0021 0022 /** 0023 * @short Loads a KControl Module. 0024 * 0025 * KCModuleLoader tries in several ways 0026 * to locate and load a KCModule. If loading fails a 0027 * zero pointer is returned. \n 0028 * It is very unlikely KCModuleLoader is what you want 0029 * and @ref KCModuleProxy suits your needs. 0030 * 0031 * @author Matthias Hoelzer-Kluepfel <mhk@kde.org> 0032 * @author Frans Englich <frans.englich@telia.com> 0033 * @internal 0034 **/ 0035 namespace KCModuleLoader 0036 { 0037 /** 0038 * Determines the way errors are reported 0039 */ 0040 enum ErrorReporting { 0041 /** 0042 * no error reporting is done 0043 * */ 0044 None = 0, 0045 /** 0046 * the error report is shown instead of the 0047 * KCModule that should have * been loaded 0048 */ 0049 Inline = 1, 0050 /** 0051 * shows a dialog with the error report 0052 */ 0053 Dialog = 2, 0054 /** 0055 * does both Inline and Dialog 0056 */ 0057 Both = 3, 0058 }; 0059 0060 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88) 0061 /** 0062 * Loads a @ref KCModule. If loading fails a zero pointer is returned. 0063 * @param module what module to load 0064 * @param report see ErrorReporting 0065 * 0066 * @return a pointer to the loaded @ref KCModule 0067 * @deprecated Since 5.88, use loadModule(KPluginMetaData, QWidget *, QVariantList) instead 0068 */ 0069 KCMUTILS_DEPRECATED_VERSION(5, 88, "use loadModule(KPluginMetaData, QWidget *, QVariantList) instead") 0070 KCMUTILS_EXPORT KCModule *loadModule(const KCModuleInfo &module, ErrorReporting report, QWidget *parent = nullptr, const QStringList &args = QStringList()); 0071 #endif 0072 0073 /** 0074 * Loads a @ref KCModule. If loading fails a KCM which displays an error message is returned. 0075 * Starting from 5.91, the validity of the @p metaData parameter does not need to be checked when calling this function. 0076 * 0077 * @param metaData KPluginMetaData for loading the plugin 0078 * @return a pointer to the loaded @ref KCModule 0079 * @since 5.84 0080 */ 0081 KCMUTILS_EXPORT KCModule *loadModule(const KPluginMetaData &metaData, QWidget *parent = nullptr, const QVariantList &args = {}); 0082 0083 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88) 0084 /** 0085 * Loads a @ref KCModule. If loading fails a zero pointer is returned. 0086 * 0087 * @param module what module to load 0088 * @param report see ErrorReporting 0089 * 0090 * @return a pointer to the loaded @ref KCModule 0091 * @deprecated Since 5.88, use loadModule(KPluginMetaData, QWidget *, QVariantList) instead 0092 */ 0093 KCMUTILS_DEPRECATED_VERSION(5, 88, "use loadModule(KPluginMetaData, QWidget *, QVariantList) instead") 0094 KCMUTILS_EXPORT KCModule *loadModule(const QString &module, ErrorReporting report, QWidget *parent = nullptr, const QStringList &args = QStringList()); 0095 #endif 0096 0097 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88) 0098 /** 0099 * Unloads the module's library 0100 * @param mod What module to unload for 0101 * @deprecated Since 5.88, use QPluginLoader directly 0102 */ 0103 KCMUTILS_DEPRECATED_VERSION(5, 88, "use QPluginLoader directly") 0104 KCMUTILS_EXPORT void unloadModule(const KCModuleInfo &mod); 0105 #endif 0106 0107 /** 0108 * Returns a KCModule containing the messages @p report and @p text. 0109 * 0110 * @param report the type of error reporting, see ErrorReporting 0111 * @param text the main message 0112 * @param details any additional details 0113 * 0114 * @internal 0115 */ 0116 KCMUTILS_EXPORT KCModule *reportError(ErrorReporting report, const QString &text, const QString &details, QWidget *parent); 0117 0118 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88) 0119 /** 0120 * For a specified module, return false if configuration is not the default one and true in all other case including if module is not found 0121 * @param module what module to load 0122 * 0123 * @return a boolean representing if module configuration is in default state 0124 * 0125 * @since 5.74 0126 * @deprecated Since 5.88, use KPluginFactory::instantiatePlugin<KCModuleData> and save the result in a QScopedPointer instead 0127 */ 0128 KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginFactory::instantiatePlugin<KCModuleData> and save the result in a QScopedPointer instead") 0129 KCMUTILS_EXPORT bool isDefaults(const KCModuleInfo &module, const QStringList &args = QStringList()); 0130 #endif 0131 0132 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88) 0133 /** 0134 * Loads a @ref KCModuleData. If fails to load, return nullptr. 0135 * 0136 * @param module what module to load 0137 * 0138 * @since 5.81 0139 * @deprecated Since 5.88, use KPluginFactory::instantiatePlugin<KCModuleData> instead 0140 */ 0141 KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginFactory::instantiatePlugin<KCModuleData> instead") 0142 KCMUTILS_EXPORT KCModuleData *loadModuleData(const KCModuleInfo &module, const QStringList &args = QStringList()); 0143 #endif 0144 } 0145 0146 #endif // KCMODULELOADER_H