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_DISPATCHER_H
0009 #define KSETTINGS_DISPATCHER_H
0010 
0011 #include <KSharedConfig>
0012 #include <QObject>
0013 #include <kcmutils_export.h>
0014 
0015 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 85)
0016 namespace KSettings
0017 {
0018 /**
0019  * @short Dispatch change notifications from the KCMs to the program.
0020  *
0021  * Since your program does not have direct control over the KCMs that get loaded
0022  * into KSettings::Dialog you need a way to get notified. This is what you do:
0023  * \code
0024  * Dispatcher::registerComponent(componentData(), this, "loadSettings");
0025  * \endcode
0026  *
0027  * @author Matthias Kretz <kretz@kde.org>
0028  */
0029 namespace Dispatcher
0030 {
0031 /**
0032  * Register a slot to be called when the configuration for the componentData
0033  * has changed. @p componentName is the string that is passed to KPluginFactory (if it is used).
0034  * You can query it with MyPluginFactory::componentName(), or from a KAboutData.
0035  * componentName is also the same name that is put into the
0036  * .desktop file of the KCMs for the X-KDE-ParentComponents.
0037  *
0038  * @param componentName     The name of the component
0039  * @param recv         The object that should receive the signal
0040  * @param slot         The slot to be called: "slotName"
0041  * @deprecated Since 5.85, connect to the @ref KCMultiDialog::configCommitted() signal of the dialog instead and check the componentName
0042  */
0043 
0044 KCMUTILS_DEPRECATED_VERSION(5, 85, "Connect to the KCMultiDialog::configCommitted() signal of the dialog instead and check the componentName")
0045 KCMUTILS_EXPORT void registerComponent(const QString &componentName, QObject *recv, const char *slot);
0046 
0047 /**
0048  * @return the KConfig object that belongs to the componentName
0049  * @deprecated Since 5.85, use KSharedConfig::openConfig(componentName + QStringLiteral("rc")) instaed
0050  */
0051 KCMUTILS_DEPRECATED_VERSION(5, 85, "Use KSharedConfig::openConfig(componentName + QStringLiteral(\"rc\")) instaed")
0052 KCMUTILS_EXPORT KSharedConfig::Ptr configForComponentName(const QString &componentName);
0053 
0054 /**
0055  * @return a list of all the componentData names that are currently
0056  * registered
0057  * @deprecated Since 5.85, this method is obsolete, see @p registerComponent API docs.
0058  */
0059 KCMUTILS_DEPRECATED_VERSION(5, 85, "method is obsolete, see KSettings::registerComponent API docs")
0060 KCMUTILS_EXPORT QList<QString> componentNames();
0061 
0062 /**
0063  * Call this function when the configuration belonging to the associated
0064  * componentData name has changed. The registered slot will be called.
0065  *
0066  * @param componentName The value of X-KDE-ParentComponents.
0067  * @deprecated Since 5.85, manually reparse the config instead
0068  */
0069 KCMUTILS_DEPRECATED_VERSION(5, 85, "Manually reparse the config instead")
0070 KCMUTILS_EXPORT void reparseConfiguration(const QString &componentName);
0071 
0072 /**
0073  * When this function is called the KConfig objects of all the registered
0074  * instances are sync()ed. This is useful when some other KConfig
0075  * objects will read/write from/to the same config file, so that you
0076  * can first write out the current state of the KConfig objects.
0077  * @deprecated Since 5.85, manually sync the config instead
0078  */
0079 KCMUTILS_DEPRECATED_VERSION(5, 85, "Manually sync the config instead")
0080 KCMUTILS_EXPORT void syncConfiguration();
0081 } // namespace Dispatcher
0082 
0083 }
0084 #endif // KSETTINGS_DISPATCHER_H
0085 #endif