File indexing completed on 2024-05-05 16:05:44
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2003 Matthias Kretz <kretz@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef KSETTINGS_PLUGINPAGE_H 0009 #define KSETTINGS_PLUGINPAGE_H 0010 0011 #include <KCModule> 0012 #include <kcmutils_export.h> 0013 0014 class KPluginSelector; 0015 0016 namespace KSettings 0017 { 0018 class PluginPagePrivate; 0019 0020 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 76) 0021 0022 /** 0023 * @short Convenience KCModule for creating a plugins config page. 0024 * 0025 * This class makes it very easy to create a plugins configuration page to your 0026 * program. All you need to do is create a class that is derived from 0027 * PluginPage and add the appropriate plugin information to the KPluginSelector. 0028 * This is done using the pluginSelector() method: 0029 * \code 0030 * K_PLUGIN_FACTORY(MyAppPluginConfigFactory, 0031 * registerPlugin<MyAppPluginConfig>(); 0032 * ) 0033 * 0034 * MyAppPluginConfig(QWidget * parent, const QVariantList & args) 0035 * : PluginPage(MyAppPluginConfigFactory::componentData(), parent, args) 0036 * { 0037 * pluginSelector()->addPlugins( QCoreApplication::instance()->applicationName(), i18n( "General Plugins" ), "General" ); 0038 * pluginSelector()->addPlugins( QCoreApplication::instance()->applicationName(), i18n( "Effects" ), "Effects" ); 0039 * } 0040 * \endcode 0041 * 0042 * All that remains to be done is to create the appropriate .desktop file 0043 * \verbatim 0044 [Desktop Entry] 0045 Icon=plugin 0046 Type=Service 0047 X-KDE-ServiceTypes=KCModule 0048 0049 X-KDE-Library=myapppluginconfig 0050 X-KDE-FactoryName=MyAppPluginConfigFactory 0051 X-KDE-ParentApp=myapp 0052 X-KDE-ParentComponents=myapp 0053 0054 Name=Plugins 0055 Comment=Select and configure your plugins: 0056 \endverbatim 0057 * 0058 * @author Matthias Kretz <kretz@kde.org> 0059 * @deprecated since 5.76, use KPluginWidget instead. 0060 */ 0061 class KCMUTILS_EXPORT PluginPage : public KCModule 0062 { 0063 Q_OBJECT 0064 Q_DECLARE_PRIVATE(PluginPage) 0065 public: 0066 /** 0067 * Standard KCModule constructor. 0068 * Automatically creates the KPluginSelector widget. 0069 */ 0070 KCMUTILS_DEPRECATED_VERSION(5, 76, "Use KPluginWidget instead") 0071 explicit PluginPage(const KAboutData *aboutData, QWidget *parent = nullptr, const QVariantList &args = QVariantList()); 0072 0073 ~PluginPage() override; 0074 0075 /** 0076 * @return a reference to the KPluginSelector. 0077 */ 0078 KPluginSelector *pluginSelector(); 0079 0080 /** 0081 * Load the state of the plugins (selected or not) from the KPluginInfo 0082 * objects. For KParts plugins everything should work automatically. For 0083 * your own type of plugins you might need to reimplement the 0084 * KPluginInfo::pluginLoaded() method. If that doesn't fit your needs 0085 * you can also reimplement this method. 0086 */ 0087 void load() override; 0088 0089 /** 0090 * Save the state of the plugins to KConfig objects 0091 */ 0092 void save() override; 0093 void defaults() override; 0094 0095 protected: 0096 PluginPagePrivate *const d_ptr; 0097 0098 private: 0099 Q_PRIVATE_SLOT(d_func(), void _k_reparseConfiguration(const QByteArray &a)) 0100 }; 0101 0102 #endif 0103 0104 } 0105 0106 #endif // KSETTINGS_PLUGINPAGE_H