KCMUtils

kcmoduleinfo.h
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 1999 Matthias Hoelzer-Kluepfel <[email protected]>
4  SPDX-FileCopyrightText: 2000 Matthias Elter <[email protected]>
5  SPDX-FileCopyrightText: 2003 Daniel Molkentin <[email protected]>
6  SPDX-FileCopyrightText: 2003, 2006 Matthias Kretz <[email protected]>
7 
8  SPDX-License-Identifier: LGPL-2.0-only
9 */
10 
11 #ifndef KCMODULEINFO_H
12 #define KCMODULEINFO_H
13 
14 #include <KService>
15 #include <kcmutils_export.h>
16 
17 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88)
18 class KPluginInfo;
19 class QString;
20 class QStringList;
21 
22 /**
23  * A class that provides information about a KCModule
24  *
25  * KCModuleInfo provides various technical information, such as icon, library
26  * etc. about a KCModule.
27  * @note Any values set with the set* functions are not
28  * written back, KCModuleInfo only reads values from the desktop file.
29  *
30  * @internal
31  * @author Matthias Hoelzer-Kluepfel <[email protected]>
32  * @author Matthias Elter <[email protected]>
33  * @author Daniel Molkentin <[email protected]>
34  *
35  */
36 class KCMUTILS_EXPORT KCModuleInfo // krazy:exclude=dpointer (implicitly shared)
37 {
38 public:
39  /**
40  * Constructs a KCModuleInfo.
41  * @note a KCModuleInfo object will have to be manually deleted, it is not
42  * done automatically for you.
43  * @param desktopFile the desktop file representing the module, or
44  * the name of the module.
45  * @deprecated Since 5.88, use KPluginMetaData API instead
46  */
47  KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginMetaData API instead")
48  KCModuleInfo(const QString &desktopFile);
49 
50  /**
51  * Same as above but takes a KPluginInfo as argument.
52  * This allows to encapsulate both the case of KService (desktop file)
53  * and the case of KPluginMetaData (JSon data in .so file) under the same API.
54  *
55  * @param pluginInfo specifies the module
56  * @since 5.70
57  * @deprecated Since 5.88, use KPluginMetaData API instead
58  */
59  KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginMetaData API instead")
60  KCModuleInfo(const KPluginInfo &pluginInfo);
61 
62  /**
63  * Same as above but takes a KService::Ptr as argument.
64  *
65  * @note @p moduleInfo must be a valid pointer.
66  *
67  * @param moduleInfo specifies the module
68  * @deprecated Since 5.88, use KPluginMetaData API instead
69  */
70  KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginMetaData API instead")
71  KCModuleInfo(KService::Ptr moduleInfo);
72 
73  /**
74  * Copy constructor
75  * @param rhs specifies the module info to copy
76  * @deprecated Since 5.88, use KPluginMetaData API instead
77  */
78  KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginMetaData API instead")
79  KCModuleInfo(const KCModuleInfo &rhs);
80 
81  /**
82  * Same as above but creates an empty KCModuleInfo.
83  * You should not normally call this.
84  */
85  KCModuleInfo();
86 
87  /**
88  * Assignment operator
89  */
90  KCModuleInfo &operator=(const KCModuleInfo &rhs);
91 
92  /**
93  * Returns true if @p rhs describes the same KCModule as this object.
94  */
95  bool operator==(const KCModuleInfo &rhs) const;
96 
97  /**
98  * @return true if @p rhs is not the same KCModule as this object.
99  */
100  bool operator!=(const KCModuleInfo &rhs) const;
101 
102  /**
103  * Default destructor.
104  */
105  ~KCModuleInfo();
106 
107  /**
108  * Returns true if the KCM was found
109  * @since 5.71
110  */
111  bool isValid() const;
112 
113  /**
114  * @return the filename of the .desktop file that describes the KCM
115  */
116  QString fileName() const;
117 
118  /**
119  * @return the keywords associated with this KCM.
120  */
121  QStringList keywords() const;
122 
123  /**
124  * @return the module\'s (translated) name
125  */
126  QString moduleName() const;
127 
128  /**
129  * @return a QExplicitlySharedDataPointer to KService created from the modules .desktop file
130  * @warning This will be null if this KCModuleInfo was created from a KPluginInfo coming from KPluginMetaData.
131  * Prefer using pluginInfo() instead, which works for both kinds.
132  */
133  KService::Ptr service() const; // TODO KF6 REMOVE
134 
135  /**
136  * @return the KPluginInfo containing more information about this module
137  * @since 5.70
138  */
139  KPluginInfo pluginInfo() const;
140 
141  /**
142  * @return the module's (translated) comment field
143  */
144  QString comment() const;
145 
146  /**
147  * @return the module's icon name
148  */
149  QString icon() const;
150 
151  /**
152  * @return the path of the module's documentation
153  */
154  QString docPath() const;
155 
156  /**
157  * @return the library name
158  */
159  QString library() const;
160 
161 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 85)
162  /**
163  * @return a handle (the contents of the X-KDE-FactoryName field if it exists,
164  * else the same as the library name)
165  * @deprecated Since 5.85, use KPluginMetaData::pluginId or KCModuleInfo::library instead
166  */
167  KCMUTILS_DEPRECATED_VERSION(5, 85, "Use KPluginMetaData::pluginId or KCModuleInfo::library instead")
168  QString handle() const;
169 #endif
170 
171  /**
172  * @return the weight of the module which determines the order of the pages in
173  * the KCMultiDialog. It's set by the X-KDE-Weight field.
174  * @deprecated Since 5.88, read X-KDE-Weight from KPluginMetaData instance instead
175  */
176  KCMUTILS_DEPRECATED_VERSION(5, 88, "read X-KDE-Weight from KPluginMetaData instance instead")
177  int weight() const;
178 
179  /**
180  * @return The value associated to the @p key. You can use it if you
181  * want to read custom values. To do this you need to define
182  * your own servicetype and add it to the ServiceTypes keys.
183  * @since 5.71
184  */
185  QVariant property(const QString &key) const;
186 
187 private:
188  class Private;
189  Private *d;
190 };
191 
192 #endif
193 #endif // KCMODULEINFO_H
A class that provides information about a KCModule.
Definition: kcmoduleinfo.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:17:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.