1/*
2 SPDX-FileCopyrightText: 2018 David Edmundson <davidedmundson@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KCONFIGWATCHER_H
8#define KCONFIGWATCHER_H
9
10#include <QObject>
11#include <QSharedPointer>
12
13#include <KConfigGroup>
14#include <KSharedConfig>
15
16#include <kconfigcore_export.h>
17
18class KConfigWatcherPrivate;
19
20/**
21 * \class KConfigWatcher kconfigwatcher.h <KConfigWatcher>
22 *
23 * Notifies when another client has updated this config file with the Notify flag set.
24 * @since 5.51
25 */
26class KCONFIGCORE_EXPORT KConfigWatcher : public QObject
27{
28 Q_OBJECT
29public:
30 typedef QSharedPointer<KConfigWatcher> Ptr;
31
32 /**
33 * Instantiate a ConfigWatcher for a given config
34 *
35 * @note any additional config sources should be set before this point.
36 */
37 static Ptr create(const KSharedConfig::Ptr &config);
38
39 ~KConfigWatcher() override;
40
41 /**
42 * Returns the config being watched
43 * @since 5.66
44 */
45 KSharedConfig::Ptr config() const;
46
47Q_SIGNALS:
48 /**
49 * Emitted when a config group has changed
50 * The config will be reloaded before this signal is emitted
51 *
52 * @arg group the config group that has changed
53 * @arg names a list of entries that have changed within that group (UTF-8 encoded)
54 */
55 void configChanged(const KConfigGroup &group, const QByteArrayList &names);
56
57private Q_SLOTS:
58 KCONFIGCORE_NO_EXPORT void onConfigChangeNotification(const QHash<QString, QByteArrayList> &changes);
59
60private:
61 KCONFIGCORE_NO_EXPORT explicit KConfigWatcher(const KSharedConfig::Ptr &config);
62 Q_DISABLE_COPY(KConfigWatcher)
63 const QScopedPointer<KConfigWatcherPrivate> d;
64};
65
66#endif
67

source code of kconfig/src/core/kconfigwatcher.h