File indexing completed on 2025-04-27 04:29:37
0001 /* 0002 SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 0008 #ifndef _K3B_PLUGIN_CONFIG_WIDGET_H_ 0009 #define _K3B_PLUGIN_CONFIG_WIDGET_H_ 0010 0011 #include "k3b_export.h" 0012 0013 #include <KCModule> 0014 #include <KPluginFactory> 0015 0016 class KConfigGroup; 0017 0018 namespace K3b { 0019 /** 0020 * A config widget for a K3b plugin. 0021 * 0022 * Most implementation details for KCModules apply. 0023 * 0024 * Create a desktop file along the lines of: 0025 * 0026 * \code 0027 * [Desktop Entry] 0028 * Name=K3b Lame Mp3 Encoder Config Module 0029 * Type=Service 0030 * X-KDE-ServiceTypes=KCModule 0031 * X-KDE-Library=kcm_k3blameencoder 0032 * X-KDE-ParentComponents=k3blameencoder 0033 * \endcode 0034 * 0035 * X-KDE-ParentComponents is important as it is the only indicator 0036 * for the plugin system to match the config widget to the plugin. 0037 * 0038 * Then implement KCModule::load(), KCModule::save() and KCModule::defaults() 0039 * to handle the configuration. In these methods you may use k3bcore->config() 0040 * to store the configuration in the main K3b config object under a specific 0041 * group. 0042 */ 0043 class LIBK3B_EXPORT PluginConfigWidget : public KCModule 0044 { 0045 Q_OBJECT 0046 0047 public: 0048 explicit PluginConfigWidget( QObject* parent, const KPluginMetaData& metaData, const QVariantList& args); 0049 ~PluginConfigWidget() override; 0050 0051 // TODO: find a nice way to get the plugin name for the config groups 0052 #if 0 0053 public Q_SLOTS: 0054 /** 0055 * reimplemented from KCModule. Do not change. 0056 * implement loadConfig instead. 0057 */ 0058 void defaults(); 0059 0060 /** 0061 * reimplemented from KCModule. Do not change. 0062 * implement loadConfig instead. 0063 */ 0064 void load(); 0065 0066 /** 0067 * reimplemented from KCModule. Do not change. 0068 * implement saveConfig instead. 0069 */ 0070 void save(); 0071 0072 protected: 0073 /** 0074 * Load the config. Implement this instead of KCModule::load and 0075 * KCModule::defaults (the latter case will be handled by loading 0076 * from an invalid KConfigGroup object. 0077 * 0078 * \param config The config group to load the config From 0079 */ 0080 virtual void loadConfig( const KConfigGroup& config ); 0081 0082 /** 0083 * Save the config 0084 */ 0085 virtual void saveConfig( KConfigGroup config ); 0086 #endif 0087 0088 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0089 protected: 0090 QWidget* widget() { return this; } 0091 void setNeedsSave(bool needs) { emit changed(needs); } 0092 #endif 0093 }; 0094 } 0095 0096 #define K3B_EXPORT_PLUGIN_CONFIG_WIDGET( libname, classname ) K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) 0097 0098 #endif