File indexing completed on 2024-04-21 14:53:50

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
0004     SPDX-FileCopyrightText: 2000 Matthias Elter <elter@kde.org>
0005     SPDX-FileCopyrightText: 2003 Daniel Molkentin <molkentin@kde.org>
0006     SPDX-FileCopyrightText: 2003, 2006 Matthias Kretz <kretz@kde.org>
0007 
0008     SPDX-License-Identifier: LGPL-2.0-only
0009 */
0010 
0011 #ifndef KCMODULEINFO_H
0012 #define KCMODULEINFO_H
0013 
0014 #include <KService>
0015 #include <kcmutils_export.h>
0016 
0017 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 88)
0018 class KPluginInfo;
0019 class QString;
0020 class QStringList;
0021 
0022 /**
0023  * A class that provides information about a KCModule
0024  *
0025  * KCModuleInfo provides various technical information, such as icon, library
0026  * etc. about a KCModule.
0027  * @note Any values set with the set* functions are not
0028  * written back, KCModuleInfo only reads values from the desktop file.
0029  *
0030  * @internal
0031  * @author Matthias Hoelzer-Kluepfel <mhk@kde.org>
0032  * @author Matthias Elter <elter@kde.org>
0033  * @author Daniel Molkentin <molkentin@kde.org>
0034  *
0035  */
0036 class KCMUTILS_EXPORT KCModuleInfo // krazy:exclude=dpointer (implicitly shared)
0037 {
0038 public:
0039     /**
0040      * Constructs a KCModuleInfo.
0041      * @note a KCModuleInfo object will have to be manually deleted, it is not
0042      * done automatically for you.
0043      * @param desktopFile the desktop file representing the module, or
0044      * the name of the module.
0045      * @deprecated Since 5.88, use KPluginMetaData API instead
0046      */
0047     KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginMetaData API instead")
0048     KCModuleInfo(const QString &desktopFile);
0049 
0050     /**
0051      * Same as above but takes a KPluginInfo as argument.
0052      * This allows to encapsulate both the case of KService (desktop file)
0053      * and the case of KPluginMetaData (JSon data in .so file) under the same API.
0054      *
0055      * @param pluginInfo specifies the module
0056      * @since 5.70
0057      * @deprecated Since 5.88, use KPluginMetaData API instead
0058      */
0059     KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginMetaData API instead")
0060     KCModuleInfo(const KPluginInfo &pluginInfo);
0061 
0062     /**
0063      * Same as above but takes a KService::Ptr as argument.
0064      *
0065      * @note @p moduleInfo must be a valid pointer.
0066      *
0067      * @param moduleInfo specifies the module
0068      * @deprecated Since 5.88, use KPluginMetaData API instead
0069      */
0070     KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginMetaData API instead")
0071     KCModuleInfo(KService::Ptr moduleInfo);
0072 
0073     /**
0074      * Copy constructor
0075      * @param rhs specifies the module info to copy
0076      * @deprecated Since 5.88, use KPluginMetaData API instead
0077      */
0078     KCMUTILS_DEPRECATED_VERSION(5, 88, "use KPluginMetaData API instead")
0079     KCModuleInfo(const KCModuleInfo &rhs);
0080 
0081     /**
0082      * Same as above but creates an empty KCModuleInfo.
0083      * You should not normally call this.
0084      */
0085     KCModuleInfo();
0086 
0087     /**
0088      * Assignment operator
0089      */
0090     KCModuleInfo &operator=(const KCModuleInfo &rhs);
0091 
0092     /**
0093      * Returns true if @p rhs describes the same KCModule as this object.
0094      */
0095     bool operator==(const KCModuleInfo &rhs) const;
0096 
0097     /**
0098      * @return true if @p rhs is not the same KCModule as this object.
0099      */
0100     bool operator!=(const KCModuleInfo &rhs) const;
0101 
0102     /**
0103      * Default destructor.
0104      */
0105     ~KCModuleInfo();
0106 
0107     /**
0108      * Returns true if the KCM was found
0109      * @since 5.71
0110      */
0111     bool isValid() const;
0112 
0113     /**
0114      * @return the filename of the .desktop file that describes the KCM
0115      */
0116     QString fileName() const;
0117 
0118     /**
0119      * @return the keywords associated with this KCM.
0120      */
0121     QStringList keywords() const;
0122 
0123     /**
0124      * @return the module\'s (translated) name
0125      */
0126     QString moduleName() const;
0127 
0128     /**
0129      * @return a QExplicitlySharedDataPointer to KService created from the modules .desktop file
0130      * @warning This will be null if this KCModuleInfo was created from a KPluginInfo coming from KPluginMetaData.
0131      * Prefer using pluginInfo() instead, which works for both kinds.
0132      */
0133     KService::Ptr service() const; // TODO KF6 REMOVE
0134 
0135     /**
0136      * @return the KPluginInfo containing more information about this module
0137      * @since 5.70
0138      */
0139     KPluginInfo pluginInfo() const;
0140 
0141     /**
0142      * @return the module's (translated) comment field
0143      */
0144     QString comment() const;
0145 
0146     /**
0147      * @return the module's icon name
0148      */
0149     QString icon() const;
0150 
0151     /**
0152      * @return the path of the module's documentation
0153      */
0154     QString docPath() const;
0155 
0156     /**
0157      * @return the library name
0158      */
0159     QString library() const;
0160 
0161 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 85)
0162     /**
0163      * @return a handle (the contents of the X-KDE-FactoryName field if it exists,
0164      * else the same as the library name)
0165      * @deprecated Since 5.85, use KPluginMetaData::pluginId or KCModuleInfo::library instead
0166      */
0167     KCMUTILS_DEPRECATED_VERSION(5, 85, "Use KPluginMetaData::pluginId or KCModuleInfo::library instead")
0168     QString handle() const;
0169 #endif
0170 
0171     /**
0172      * @return the weight of the module which determines the order of the pages in
0173      * the KCMultiDialog. It's set by the X-KDE-Weight field.
0174      * @deprecated Since 5.88, read X-KDE-Weight from KPluginMetaData instance instead
0175      */
0176     KCMUTILS_DEPRECATED_VERSION(5, 88, "read X-KDE-Weight from KPluginMetaData instance instead")
0177     int weight() const;
0178 
0179     /**
0180      * @return The value associated to the @p key. You can use it if you
0181      *         want to read custom values. To do this you need to define
0182      *         your own servicetype and add it to the ServiceTypes keys.
0183      * @since 5.71
0184      */
0185     QVariant property(const QString &key) const;
0186 
0187 private:
0188     class Private;
0189     Private *d;
0190 };
0191 
0192 #endif
0193 #endif // KCMODULEINFO_H