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
22 * \inmodule KConfigCore
23 *
24 * \brief Notifies when another client has updated this config file with the Notify flag set.
25 * \since 5.51
26 */
27class KCONFIGCORE_EXPORT KConfigWatcher : public QObject
28{
29 Q_OBJECT
30public:
31 /*!
32 * \typedef KConfigWatcher::Ptr
33 */
34 typedef QSharedPointer<KConfigWatcher> Ptr;
35
36 /*!
37 * Instantiate a ConfigWatcher for a given config
38 *
39 * \note any additional config sources should be set before this point.
40 */
41 static Ptr create(const KSharedConfig::Ptr &config);
42
43 ~KConfigWatcher() override;
44
45 /*!
46 * Returns the config being watched
47 * \since 5.66
48 */
49 KSharedConfig::Ptr config() const;
50
51Q_SIGNALS:
52 /*!
53 * Emitted when a config group has changed
54 * The config will be reloaded before this signal is emitted
55 *
56 * \a group the config group that has changed
57 *
58 * \a names a list of entries that have changed within that group (UTF-8 encoded)
59 */
60 void configChanged(const KConfigGroup &group, const QByteArrayList &names);
61
62private Q_SLOTS:
63 KCONFIGCORE_NO_EXPORT void onConfigChangeNotification(const QHash<QString, QByteArrayList> &changes);
64
65private:
66 KCONFIGCORE_NO_EXPORT explicit KConfigWatcher(const KSharedConfig::Ptr &config);
67 Q_DISABLE_COPY(KConfigWatcher)
68 const QScopedPointer<KConfigWatcherPrivate> d;
69};
70
71#endif
72

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