KCMUtils

kcmoduleloader.h
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 1999 Matthias Hoelzer-Kluepfel <[email protected]>
4  SPDX-FileCopyrightText: 2002-2003 Daniel Molkentin <[email protected]>
5  SPDX-FileCopyrightText: 2006 Matthias Kretz <[email protected]>
6  SPDX-FileCopyrightText: 2021 Alexander Lohnau <[email protected]>
7 
8  SPDX-License-Identifier: LGPL-2.0-only
9 */
10 
11 #ifndef KCMODULELOADER_H
12 #define KCMODULELOADER_H
13 
14 #include <KCModule>
15 #include <KPluginMetaData>
16 
17 #include <kcmoduledata.h>
18 #include <kcmoduleinfo.h>
19 
20 class QWidget;
21 
22 /**
23  * @short Loads a KControl Module.
24  *
25  * KCModuleLoader tries in several ways
26  * to locate and load a KCModule. If loading fails a
27  * zero pointer is returned. \n
28  * It is very unlikely KCModuleLoader is what you want
29  * and @ref KCModuleProxy suits your needs.
30  *
31  * @author Matthias Hoelzer-Kluepfel <[email protected]>
32  * @author Frans Englich <[email protected]>
33  * @internal
34  **/
35 namespace KCModuleLoader
36 {
37 /**
38  * Determines the way errors are reported
39  */
41  /**
42  * no error reporting is done
43  * */
44  None = 0,
45  /**
46  * the error report is shown instead of the
47  * KCModule that should have * been loaded
48  */
49  Inline = 1,
50  /**
51  * shows a dialog with the error report
52  */
53  Dialog = 2,
54  /**
55  * does both Inline and Dialog
56  */
57  Both = 3,
58 };
59 
60 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88)
61 /**
62  * Loads a @ref KCModule. If loading fails a zero pointer is returned.
63  * @param module what module to load
64  * @param report see ErrorReporting
65  *
66  * @return a pointer to the loaded @ref KCModule
67  * @deprecated Since 5.88, use loadModule(KPluginMetaData, QWidget *, QVariantList) instead
68  */
69 KCMUTILS_DEPRECATED_VERSION(5, 88, "use loadModule(KPluginMetaData, QWidget *, QVariantList) instead")
70 KCMUTILS_EXPORT KCModule *loadModule(const KCModuleInfo &module, ErrorReporting report, QWidget *parent = nullptr, const QStringList &args = QStringList());
71 #endif
72 
73 /**
74  * Loads a @ref KCModule. If loading fails a KCM which displays an error message is returned.
75  * Starting from 5.91, the validity of the @p metaData parameter does not need to be checked when calling this function.
76  *
77  * @param metaData KPluginMetaData for loading the plugin
78  * @return a pointer to the loaded @ref KCModule
79  * @since 5.84
80  */
81 KCMUTILS_EXPORT KCModule *loadModule(const KPluginMetaData &metaData, QWidget *parent = nullptr, const QVariantList &args = {});
82 
83 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88)
84 /**
85  * Loads a @ref KCModule. If loading fails a zero pointer is returned.
86  *
87  * @param module what module to load
88  * @param report see ErrorReporting
89  *
90  * @return a pointer to the loaded @ref KCModule
91  * @deprecated Since 5.88, use loadModule(KPluginMetaData, QWidget *, QVariantList) instead
92  */
93 KCMUTILS_DEPRECATED_VERSION(5, 88, "use loadModule(KPluginMetaData, QWidget *, QVariantList) instead")
94 KCMUTILS_EXPORT KCModule *loadModule(const QString &module, ErrorReporting report, QWidget *parent = nullptr, const QStringList &args = QStringList());
95 #endif
96 
97 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88)
98 /**
99  * Unloads the module's library
100  * @param mod What module to unload for
101  * @deprecated Since 5.88, use QPluginLoader directly
102  */
103 KCMUTILS_DEPRECATED_VERSION(5, 88, "use QPluginLoader directly")
104 KCMUTILS_EXPORT void unloadModule(const KCModuleInfo &mod);
105 #endif
106 
107 /**
108  * Returns a KCModule containing the messages @p report and @p text.
109  *
110  * @param report the type of error reporting, see ErrorReporting
111  * @param text the main message
112  * @param details any additional details
113  *
114  * @internal
115  */
116 KCMUTILS_EXPORT KCModule *reportError(ErrorReporting report, const QString &text, const QString &details, QWidget *parent);
117 
118 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88)
119 /**
120  * 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
121  * @param module what module to load
122  *
123  * @return a boolean representing if module configuration is in default state
124  *
125  * @since 5.74
126  * @deprecated Since 5.88, use KPluginFactory::instantiatePlugin<KCModuleData> and save the result in a QScopedPointer instead
127  */
128 KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginFactory::instantiatePlugin<KCModuleData> and save the result in a QScopedPointer instead")
129 KCMUTILS_EXPORT bool isDefaults(const KCModuleInfo &module, const QStringList &args = QStringList());
130 #endif
131 
132 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88)
133 /**
134  * Loads a @ref KCModuleData. If fails to load, return nullptr.
135  *
136  * @param module what module to load
137  *
138  * @since 5.81
139  * @deprecated Since 5.88, use KPluginFactory::instantiatePlugin<KCModuleData> instead
140  */
141 KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginFactory::instantiatePlugin<KCModuleData> instead")
142 KCMUTILS_EXPORT KCModuleData *loadModuleData(const KCModuleInfo &module, const QStringList &args = QStringList());
143 #endif
144 }
145 
146 #endif // KCMODULELOADER_H
KCMUTILS_EXPORT void unloadModule(const KCModuleInfo &mod)
Unloads the module's library.
Loads a KControl Module.
@ Inline
the error report is shown instead of the KCModule that should have * been loaded
KCMUTILS_EXPORT KCModule * loadModule(const KCModuleInfo &module, ErrorReporting report, QWidget *parent=nullptr, const QStringList &args=QStringList())
Loads a KCModule.
ErrorReporting
Determines the way errors are reported.
@ Both
does both Inline and Dialog
KCMUTILS_EXPORT bool isDefaults(const KCModuleInfo &module, const QStringList &args=QStringList())
For a specified module, return false if configuration is not the default one and true in all other ca...
A base class that offers information about a KCModule state.
Definition: kcmoduledata.h:25
@ None
no error reporting is done
A class that provides information about a KCModule.
Definition: kcmoduleinfo.h:36
KCMUTILS_EXPORT KCModuleData * loadModuleData(const KCModuleInfo &module, const QStringList &args=QStringList())
Loads a KCModuleData.
KCMUTILS_EXPORT KCModule * reportError(ErrorReporting report, const QString &text, const QString &details, QWidget *parent)
Returns a KCModule containing the messages report and text.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 03:51:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.