KCoreAddons

kpluginmetadata.h
1 /*
2  This file is part of the KDE project
3 
4  SPDX-FileCopyrightText: 2014 Alex Richardson <[email protected]>
5  SPDX-FileCopyrightText: 2021 Alexander Lohnau <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #ifndef KPLUGINMETADATA_H
11 #define KPLUGINMETADATA_H
12 
13 #include "kcoreaddons_export.h"
14 
15 #include <QExplicitlySharedDataPointer>
16 #include <QJsonObject>
17 #include <QMetaType>
18 #include <QString>
19 #include <QStringList>
20 
21 #include <functional>
22 
23 class KPluginLoader;
24 class KPluginFactory;
25 class QPluginLoader;
26 class KPluginMetaDataPrivate;
27 class KAboutPerson;
28 class QObject;
29 class QStaticPlugin;
30 /**
31  * @class KPluginMetaData kpluginmetadata.h KPluginMetaData
32  *
33  * This class allows easily accessing some standardized values from the JSON metadata that
34  * can be embedded into Qt plugins. Additional plugin-specific metadata can be retrieved by
35  * directly reading from the QJsonObject returned by KPluginMetaData::rawData().
36  *
37  * This class can be used instead of KPluginInfo from KService for applications that only load
38  * Qt C++ plugins.
39  *
40  * The following keys will be read from an object "KPlugin" inside the metadata JSON:
41  *
42  * Key | Accessor function | JSON Type
43  * -------------------| -------------------- | ---------------------
44  * Name | name() | string
45  * Description | description() | string
46  * ExtraInformation | extraInformation() | string
47  * Icon | iconName() | string
48  * Authors | authors() | object array (KAboutPerson)
49  * Category | category() | string
50  * License | license() | string
51  * Copyright | copyrightText() | string
52  * Id | pluginId() | string
53  * Version | version() | string
54  * Website | website() | string
55  * EnabledByDefault | isEnabledByDefault() | bool
56  * ServiceTypes | serviceTypes() | string array
57  * MimeTypes | mimeTypes() | string array
58  * FormFactors | formFactors() | string array
59  * Translators | translators() | object array (KAboutPerson)
60  * OtherContributors | otherContributors() | object array (KAboutPerson)
61  *
62  * The Authors, Translators and OtherContributors keys are expected to be
63  * list of objects that match the structure expected by KAboutPerson::fromJSON().
64  *
65  * An example metadata json file could look like this:
66  * @verbatim
67  {
68  "KPlugin": {
69  "Name": "Date and Time",
70  "Description": "Date and time by timezone",
71  "Icon": "preferences-system-time",
72  "Authors": [ { "Name": "Aaron Seigo", "Email": "[email protected]" } ],
73  "Category": "Date and Time",
74  "EnabledByDefault": "true",
75  "License": "LGPL",
76  "Id": "time",
77  "Version": "1.0",
78  "Website": "https://plasma.kde.org/"
79  }
80  }
81  @endverbatim
82  *
83  * @sa KAboutPerson::fromJSON()
84  * @since 5.1
85  */
86 class KCOREADDONS_EXPORT KPluginMetaData
87 {
88  Q_GADGET
89  Q_PROPERTY(bool isValid READ isValid CONSTANT)
90  Q_PROPERTY(bool isHidden READ isHidden CONSTANT)
91  Q_PROPERTY(QString fileName READ fileName CONSTANT)
92  Q_PROPERTY(QString metaDataFileName READ metaDataFileName CONSTANT)
93  Q_PROPERTY(QJsonObject rawData READ rawData CONSTANT)
94  Q_PROPERTY(QString name READ name CONSTANT)
95  Q_PROPERTY(QString description READ description CONSTANT)
96 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 87)
97  Q_PROPERTY(QString extraInformation READ extraInformation CONSTANT)
98 #endif
99  Q_PROPERTY(QVariantList authors READ authorsVariant CONSTANT)
100  Q_PROPERTY(QVariantList translators READ translatorsVariant CONSTANT)
101  Q_PROPERTY(QVariantList otherContributors READ otherContributorsVariant CONSTANT)
102  Q_PROPERTY(QString category READ category CONSTANT)
103  Q_PROPERTY(QString iconName READ iconName CONSTANT)
104  Q_PROPERTY(QString license READ license CONSTANT)
105  Q_PROPERTY(QString licenseText READ licenseText CONSTANT)
106  Q_PROPERTY(QString copyrightText READ copyrightText CONSTANT)
107  Q_PROPERTY(QString pluginId READ pluginId CONSTANT)
108  Q_PROPERTY(QString version READ version CONSTANT)
109  Q_PROPERTY(QString website READ website CONSTANT)
110 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 79)
111  Q_PROPERTY(QStringList dependencies READ dependencies CONSTANT)
112 #endif
113 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 89)
114  Q_PROPERTY(QStringList serviceTypes READ serviceTypes CONSTANT)
115 #endif
116  Q_PROPERTY(QStringList mimeTypes READ mimeTypes CONSTANT)
117  Q_PROPERTY(QStringList formFactors READ formFactors CONSTANT)
118  Q_PROPERTY(bool isEnabledByDefault READ isEnabledByDefault CONSTANT)
119  Q_PROPERTY(int initialPreference READ isEnabledByDefault CONSTANT)
120 
121 public:
122  /**
123  * Options for creating a KPluginMetaData object.
124  * @since 5.91
125  */
127  DoNotAllowEmptyMetaData, /// Plugins with empty metaData are considered invalid
128  AllowEmptyMetaData, /// Plugins with empty metaData are considered valid
129  };
130 
131  /** Creates an invalid KPluginMetaData instance */
132  KPluginMetaData();
133 
134 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 86)
135  /**
136  * Reads the plugin metadata from a KPluginLoader instance. You must call KPluginLoader::setFileName()
137  * or use the appropriate constructor on @p loader before calling this.
138  */
139  KCOREADDONS_DEPRECATED_VERSION(5, 86, "Use KPluginMetaData(QPluginLoader) instead")
140  KPluginMetaData(const KPluginLoader &loader);
141 #endif
142 
143  /**
144  * Reads the plugin metadata from a QPluginLoader instance. You must call QPluginLoader::setFileName()
145  * or use the appropriate constructor on @p loader before calling this.
146  */
147  KPluginMetaData(const QPluginLoader &loader);
148 
149  /**
150  * Reads the plugin metadata from a plugin or .desktop which can be loaded from @p file.
151  *
152  * For plugins, platform-specific library suffixes may be omitted since @p file will be resolved
153  * using the same logic as QPluginLoader.
154  *
155  * If the file name ends with ".desktop", the .desktop file will be parsed instead of
156  * reading the metadata from the QPluginLoader. This is the same as calling
157  * KPluginMetaData::fromDesktopFile() without the serviceTypes parameter.
158  *
159  * If @p file ends with .json, the file will be loaded as the QJsonObject metadata.
160  *
161  * @note Using this constructor for metadata files is deprecated..
162  * Use KPluginMetaData::fromDesktopFile or KPluginMetaData::fromJsonFile instead.
163  *
164  * @see QPluginLoader::setFileName()
165  * @see KPluginMetaData::fromDesktopFile()
166  * @see KPluginMetaData::fromJsonFile()
167  */
168  KPluginMetaData(const QString &file);
169 
170  /**
171  * Overload which takes an option parameter that gets used when creating the KPluginMetaData instances
172  * @since 5.91
173  */
174  KPluginMetaData(const QString &file, KPluginMetaDataOption option);
175 
176  /**
177  * Creates a KPluginMetaData from a QJsonObject holding the metadata and a file name
178  * This can be used if the data is not retrieved from a Qt C++ plugin library but from some
179  * other source.
180  * @see KPluginMetaData(const QJsonObject &, const QString &, const QString &)
181  */
182  KPluginMetaData(const QJsonObject &metaData, const QString &file);
183 
184  // TODO: KF6: merge with the above and make metaDataFile default to QString()
185  /**
186  * Creates a KPluginMetaData
187  * @param metaData the JSON metadata to use for this object
188  * @param pluginFile the file that the plugin can be loaded from
189  * @param metaDataFile the file that the JSON metadata was read from
190  *
191  * This can be used if the data is not retrieved from a Qt C++ plugin library but from some
192  * other source.
193  *
194  * @since 5.5
195  */
196  KPluginMetaData(const QJsonObject &metaData, const QString &pluginFile, const QString &metaDataFile);
197 
198  /*
199  * Constructs a KPluginMetaData from the static plugin.
200  * If it does not have any meta data the @p metaData value is used
201  *
202  * @see KPluginFactory::loadFactory
203  * @see KPluginFactory::instantiatePlugin
204  *
205  * @since 5.89
206  */
207  KPluginMetaData(QStaticPlugin plugin, const QJsonObject &metaData = {});
208 
209  /**
210  * Copy contructor
211  */
213  /**
214  * Copy assignment
215  */
216  KPluginMetaData &operator=(const KPluginMetaData &);
217  /**
218  * Destructor
219  */
220  ~KPluginMetaData();
221 
222 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 92)
223  /**
224  * Load a KPluginMetaData instance from a .desktop file. Unlike the constructor which takes
225  * a single file parameter this method allows you to specify which service type files should
226  * be parsed to determine the correct type for a given .desktop property.
227  * This ensures that a e.g. comma-separated string list field in the .desktop file will correctly
228  * be converted to a JSON string array.
229  *
230  * @note This function mostly exists for backwards-compatibility. It is recommended
231  * that new applications load JSON files directly instead of using .desktop files for plugin metadata.
232  *
233  * @param file the .desktop file to load
234  * @param serviceTypes a list of files to parse If one of these paths is a relative path it
235  * will be resolved relative to the "kservicetypes5" subdirectory in QStandardPaths::GenericDataLocation.
236  * If the list is empty only the default set of properties will be treated specially and all other entries
237  * will be read as the JSON string type.
238  *
239  * @since 5.16
240  * @deprecated Since 5.92, use json files or embedded json metadata directly.
241  */
242  KCOREADDONS_DEPRECATED_VERSION(5, 92, "Use json files or embedded json metadata directly")
243  static KPluginMetaData fromDesktopFile(const QString &file, const QStringList &serviceTypes = QStringList());
244 #endif
245 
246  /**
247  * Load a KPluginMetaData instance from a .json file. Unlike the constructor with a single file argument,
248  * this ensure that only JSON format plugins are loaded and any other type is rejected.
249  *
250  * @param jsonFile the .json file to load
251  * @since 5.91
252  */
253  static KPluginMetaData fromJsonFile(const QString &jsonFile);
254 
255  /**
256  * @param directory The directory to search for plugins. If a relative path is given for @p directory,
257  * all entries of QCoreApplication::libraryPaths() will be checked with @p directory appended as a
258  * subdirectory. If an absolute path is given only that directory will be searched.
259  * @note Check if the returned KPluginMetaData is valid before continuing to use it.
260  *
261  * @param pluginId The Id of the plugin. The id should be the same as the filename, see KPluginMetaData::pluginId()
262  * @since 5.84
263  */
264  static KPluginMetaData findPluginById(const QString &directory, const QString &pluginId);
265 
266  /**
267  * Find all plugins inside @p directory. Only plugins which have JSON metadata will be considered.
268  *
269  * @param directory The directory to search for plugins. If a relative path is given for @p directory,
270  * all entries of QCoreApplication::libraryPaths() will be checked with @p directory appended as a
271  * subdirectory. If an absolute path is given only that directory will be searched.
272  *
273  * @param filter a callback function that returns @c true if the found plugin should be loaded
274  * and @c false if it should be skipped. If this argument is omitted all plugins will be loaded
275  *
276  * @return all plugins found in @p directory that fulfil the constraints of @p filter
277  * @since 5.86
278  */
279  static QVector<KPluginMetaData> findPlugins(const QString &directory, std::function<bool(const KPluginMetaData &)> filter = {});
280 
281  /**
282  * @since 5.91
283  */
284  static QVector<KPluginMetaData> findPlugins(const QString &directory, std::function<bool(const KPluginMetaData &)> filter, KPluginMetaDataOption option);
285 
286  /**
287  * @return whether this object holds valid information about a plugin.
288  * If this is @c true pluginId() will return a non-empty string.
289  */
290  bool isValid() const;
291 
292  /**
293  * @return whether this object should be hidden, this is usually not used for binary
294  * plugins, when loading a KPluginMetaData from a .desktop file, this will reflect
295  * the value of the "Hidden" key.
296  *
297  * @since 5.8
298  */
299  bool isHidden() const;
300 
301  /**
302  * @return the path to the plugin. This string can be passed to the KPluginLoader
303  * or QPluginLoader constructors in order to attempt to load this plugin.
304  * @note It is not guaranteed that this is a valid path to a shared library (i.e. loadable
305  * by QPluginLoader) since the metadata could also refer to a non-C++ plugin.
306  */
307  QString fileName() const;
308 
309  /**
310  * @return the file that the metadata was read from. This is not necessarily the same as
311  * fileName(), since not all plugins have the metadata embedded. The metadata could also be
312  * stored in a separate .desktop file.
313  *
314  * @since 5.5
315  */
316  QString metaDataFileName() const;
317 
318  /**
319  * @return the full metadata stored inside the plugin file.
320  */
321  QJsonObject rawData() const;
322 
323 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 86)
324  /**
325  * Tries to instantiate this plugin using KPluginMetaData::fileName().
326  * @note The value of KPluginMetaData::dependencies() is not used here, dependencies must be
327  * resolved manually.
328  *
329  * @return The plugin root object or @c nullptr if it could not be loaded
330  * @see QPluginLoader::instance(), KPluginFactory::loadFactory, KPluginFactory::instantiatePlugin
331  * @deprecated Since 5.86, use @ref KPluginFactory::loadFactory or @ref KPluginFactory::instantiatePlugin when using
332  * KPluginFactory. Otherwise use QPluginLoader::instance() instead.
333  */
334  KCOREADDONS_DEPRECATED_VERSION(5, 86, "See API docs")
335  QObject *instantiate() const;
336 #endif
337 
338  /**
339  * @return the user visible name of the plugin.
340  */
341  QString name() const;
342 
343  /**
344  * @return a short description of the plugin.
345  */
346  QString description() const;
347 
348 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 87)
349  /**
350  * @return additional information about this plugin (e.g. for use in an "about plugin" dialog)
351  *
352  * @since 5.18
353  * @deprecated Since 5.87, deprecate for lack of usage. Use a meaningful custom key in the json metadata instead
354  */
355  KCOREADDONS_DEPRECATED_VERSION(5, 87, "Deprecate for lack of usage, use a meaningful custom key in the json metadata instead")
356  QString extraInformation() const;
357 #endif
358 
359  /**
360  * @return the author(s) of this plugin.
361  */
362  QList<KAboutPerson> authors() const;
363 
364  /**
365  * @return the translator(s) of this plugin.
366  *
367  * @since 5.18
368  */
369  QList<KAboutPerson> translators() const;
370 
371  /**
372  * @return a list of people that contributed to this plugin (other than the authors and translators).
373  *
374  * @since 5.18
375  */
376  QList<KAboutPerson> otherContributors() const;
377 
378  /**
379  * @return the categories of this plugin (e.g. "playlist/skin").
380  */
381  QString category() const;
382 
383  /**
384  * @return the icon name for this plugin
385  * @see QIcon::fromTheme()
386  */
387  QString iconName() const;
388 
389  /**
390  * @return the short license identifier (e.g. LGPL).
391  * @see KAboutLicense::byKeyword() for retrieving the full license information
392  */
393  QString license() const;
394 
395  /**
396  * @return the text of the license, equivalent to KAboutLicense::byKeyword(license()).text()
397  * @since 5.73
398  */
399  QString licenseText() const;
400 
401  /**
402  * @return a short copyright statement
403  *
404  * @since 5.18
405  */
406  QString copyrightText() const;
407 
408  /**
409  * @return the internal name of the plugin
410  * If the Id property is not set in the metadata, this will return the
411  * plugin file name without the file extension.
412  */
413  QString pluginId() const;
414 
415  /**
416  * @return the version of the plugin.
417  */
418  QString version() const;
419 
420  /**
421  * @return the website of the plugin.
422  */
423  QString website() const;
424 
425 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 79)
426  /**
427  * @return a list of plugins that this plugin depends on so that it can function properly
428  * @see KJsonPluginInfo::pluginId()
429  * @deprecated Since 5.79, plugin dependencies are deprecated and will be removed in KF6
430  */
431  KCOREADDONS_DEPRECATED_VERSION(5, 79, "Plugin dependencies are deprecated and will be removed in KF6")
432  QStringList dependencies() const;
433 #endif
434 
435 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 89)
436  /**
437  * Returns the service types that this plugin implements.
438  *
439  * This is mostly for historical / compatibility purposes.
440  * As a general rule, instead of opening many plugins to then filter by servicetype,
441  * put all plugins of the same type in a subdirectory, that you can pass to findPlugins directly.
442  * No point in opening 20 plugins to pick out only 3, when the filesystem can do that filtering for you.
443  *
444  * @note Unlike KService this does not contain the MIME types. To get the handled MIME types
445  * use the KPluginMetaData::mimeTypes() function.
446  * @return a list of service types this plugin implements (e.g. "Plasma/DataEngine")
447  * @dprecated Since 5.89, use dedicated plugin namespaces instead to filter plugins of a specific type
448  */
449  KCOREADDONS_DEPRECATED_VERSION(5, 89, "See API docs")
450  QStringList serviceTypes() const;
451 #endif
452 
453  /**
454  * @return a list of MIME types this plugin can handle (e.g. "application/pdf", "image/png", etc.)
455  * @since 5.16
456  */
457  QStringList mimeTypes() const;
458 
459  /**
460  * @return true if this plugin can handle the given mimetype
461  * This is more accurate than mimeTypes().contains(mimeType) because it also
462  * takes MIME type inheritance into account.
463  * @since 5.66
464  */
465  bool supportsMimeType(const QString &mimeType) const;
466 
467  /**
468  * @return A string list of formfactors this plugin is useful for, e.g. desktop, tablet,
469  * handset, mediacenter, etc.
470  * The keys for this are not formally defined.
471  *
472  * @since 5.12
473  */
474  QStringList formFactors() const;
475 
476  /**
477  * @return whether the plugin should be enabled by default.
478  * This is only a recommendation, applications can ignore this value if they want to.
479  */
480  bool isEnabledByDefault() const;
481 
482  /**
483  * @return the initial preference of the plugin.
484  * This is the preference to associate with this plugin initially (before
485  * the user has had any chance to define preferences for it).
486  * Higher values indicate stronger preference.
487  * @since 5.67
488  */
489  int initialPreference() const;
490 
491  /**
492  * Returns @c true if the plugin is enabled in @p config, otherwise returns isEnabledByDefault().
493  * This can be used in conjunctionwith KPluginWidget/KPluginSelector.
494  *
495  * The @p config param should be a KConfigGroup object, because KCoreAddons can not depend
496  * on KConfig directly, this parameter is a template.
497  * @param config KConfigGroup where the enabled state is stored
498  * @since 5.89
499  */
500  template<typename T>
501  bool isEnabled(const T &config) const
502  {
503  Q_ASSERT(config.isValid());
504  return config.readEntry(pluginId() + QLatin1String("Enabled"), isEnabledByDefault());
505  }
506 
507  /**
508  * @return the value for @p key from the metadata or @p defaultValue if the key does not exist
509  * or the value for @p key is not of type string
510  *
511  * @see KPluginMetaData::rawData() if QString is not the correct type for @p key
512  */
513  QString value(const QString &key, const QString &defaultValue = QString()) const;
514 
515 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 88)
516  /**
517  * Overload to make sure the bool overload is not taken by accident
518  * @overload
519  * @since 5.88
520  */
521  KCOREADDONS_DEPRECATED_VERSION(5, 88, "Construct a QString instead of using a char array, otherwise there the bool overload could be chosen by accident")
522  QString value(const QString &key, const char *ch) const
523  {
524  return value(key, QString::fromLatin1(ch));
525  }
526 #else
527  QString value(const QString &key, const char *ch) const = delete;
528 #endif
529 
530  /**
531  * @overload
532  * @since 5.88
533  */
534  bool value(const QString &key, bool defaultValue) const;
535 
536  /**
537  * @overload
538  * @since 5.88
539  */
540  int value(const QString &key, int defaultValue) const;
541 
542  /** @return the value for @p key inside @p jo as a string list. If the type of @p key is string, a list with containing
543  * just that string will be returned, if it is an array the list will contain one entry for each array member.
544  * If the key cannot be found an empty list will be returned.
545  * @overload
546  * @since 5.88
547  */
548  QStringList value(const QString &key, const QStringList &defaultValue) const;
549 
550 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 88)
551  /** @return the value for @p key inside @p jo as a string list. If the type of @p key is string, a list with containing
552  * just that string will be returned, if it is an array the list will contain one entry for each array member.
553  * If the key cannot be found an empty list will be returned.
554  * @deprecated Since 5.88, use @p value(QString, QStringList) on KPluginMetaData instance instead
555  */
556  KCOREADDONS_DEPRECATED_VERSION(5, 88, "Use value(QString, QStringList) on KPluginMetaData instance instead")
557  static QStringList readStringList(const QJsonObject &jo, const QString &key);
558 #endif
559 
560 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 88)
561  /**
562  * Reads a value from @p jo but unlike QJsonObject::value() it allows different entries for each locale
563  * This is done by appending the locale identifier in brackets to the key (e.g. "[de_DE]" or "[es]")
564  * When looking for a key "foo" with German (Germany) locale we will first attempt to read "foo[de_DE]",
565  * if that does not exist "foo[de]", finally falling back to "foo" if that also doesn't exist.
566  * @return the translated value for @p key from @p jo or @p defaultValue if @p key was not found
567  * @deprecated Since 5.88, use KJsonUtils::readTranslatedValue instead
568  */
569  KCOREADDONS_DEPRECATED_VERSION(5, 88, "Use KJsonUtils::readTranslatedValue instead")
570  static QJsonValue readTranslatedValue(const QJsonObject &jo, const QString &key, const QJsonValue &defaultValue = QJsonValue());
571 #endif
572 
573 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 88)
574  /**
575  * @return the translated value of @p key from @p jo as a string or @p defaultValue if @p key was not found
576  * or the value for @p key is not of type string
577  * @see KPluginMetaData::readTranslatedValue(const QJsonObject &jo, const QString &key)
578  * @deprecated Since 5.88, use KJsonUtils::readTranslatedString instead
579  */
580  KCOREADDONS_DEPRECATED_VERSION(5, 88, "Use KJsonUtils::readTranslatedString instead")
581  static QString readTranslatedString(const QJsonObject &jo, const QString &key, const QString &defaultValue = QString());
582 #endif
583 
584  /**
585  * @return @c true if this object is equal to @p other, otherwise @c false
586  */
587  bool operator==(const KPluginMetaData &other) const;
588 
589  /**
590  * @return @c true if this object is not equal to @p other, otherwise @c false.
591  */
592  inline bool operator!=(const KPluginMetaData &other) const
593  {
594  return !(*this == other);
595  }
596 
597  /**
598  * @note for loading plugin the plugin independently of it being static/dynamic
599  * use @ref KPluginFactory::loadFactory or @ref KPluginFactory::instantiatePlugin.
600  * @return true if the instance represents a static plugin
601  * @since 5.89
602  */
603  bool isStaticPlugin() const;
604 
605 private:
606  QJsonObject rootObject() const;
607 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 92)
608  void loadFromDesktopFile(const QString &file, const QStringList &serviceTypes);
609 #endif
610  void loadFromJsonFile(const QString &file);
611 
612 private:
613  QVariantList authorsVariant() const;
614  QVariantList translatorsVariant() const;
615  QVariantList otherContributorsVariant() const;
616  QStaticPlugin staticPlugin() const;
617  QString requestedFileName() const;
618 
619  QJsonObject m_metaData;
620  QString m_fileName;
621  QExplicitlySharedDataPointer<KPluginMetaDataPrivate> d; // for future binary compatible extensions
622  friend class KPluginFactory;
623 };
624 
625 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
626 inline size_t qHash(const KPluginMetaData &md, size_t seed)
627 #else
628 inline uint qHash(const KPluginMetaData &md, uint seed)
629 #endif
630 {
631  return qHash(md.pluginId(), seed);
632 }
633 
634 Q_DECLARE_METATYPE(KPluginMetaData)
635 
636 #endif // KPLUGINMETADATA_H
bool operator!=(const KPluginMetaData &other) const
KPluginMetaDataOption
Options for creating a KPluginMetaData object.
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
virtual QVariant rootObject()
This class is used to store information about a person or developer.
Definition: kaboutdata.h:61
@ AllowEmptyMetaData
Plugins with empty metaData are considered invalid.
unsigned int version()
Returns a numerical version number of KCoreAddons at run-time in the form 0xMMNNPP (MM = major,...
Definition: kcoreaddons.cpp:18
QString fromLatin1(const char *str, int size)
bool isValid(QStringView ifopt)
QString name(StandardShortcut id)
QStringList mimeTypes(Mode mode=Writing)
Category category(StandardShortcut id)
bool isEnabled(const T &config) const
Returns true if the plugin is enabled in config, otherwise returns isEnabledByDefault().
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Jul 4 2022 04:07:21 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.