diff options
author | David Edmundson <kde@davidedmundson.co.uk> | 2018-10-10 14:48:49 +0100 |
---|---|---|
committer | David Edmundson <kde@davidedmundson.co.uk> | 2018-10-10 14:51:04 +0100 |
commit | 8579ec54838b7188ed016f7adb4a69bbf2e39712 (patch) | |
tree | b9614b014ba779dae40e96069fc2cadeeecea9de /src/core/kconfigwatcher.h | |
parent | 8e56083463374fa6525b5feff4373b5ab58914bb (diff) | |
download | kconfig-8579ec54838b7188ed016f7adb4a69bbf2e39712.tar.gz kconfig-8579ec54838b7188ed016f7adb4a69bbf2e39712.tar.bz2 |
Add mechanism to notify other clients of config changes over DBus
Summary:
Intention is not to create a registry like system, but to replace
KDElibs4Support::KGlobalSettings and to replace other system settingss
-> some app communication in a more generic way.
writeEntry gains an additional flag Notify which if set, will notify
clients of what has actually changed when we sync.
Rationale to put this into KConfig was so that we could have everything
batched and sychronised to the file sync and to get the fine detailed
exposure of what has actually changed which we don't get with a file
watcher.
Default behaviour remains identical without any broadcast messages.
As it is a new dependency it is purely optional and anything referencing
DBus is not in the public API. Our deployment on platforms without DBus
tend to be standalone applications anyway.
Test Plan: Attached unit test
Reviewers: broulik, dfaure
Reviewed By: broulik, dfaure
Subscribers: dfaure, broulik, zzag, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D13034
Diffstat (limited to 'src/core/kconfigwatcher.h')
-rw-r--r-- | src/core/kconfigwatcher.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/core/kconfigwatcher.h b/src/core/kconfigwatcher.h new file mode 100644 index 00000000..b73d3fc2 --- /dev/null +++ b/src/core/kconfigwatcher.h @@ -0,0 +1,68 @@ +/* + * Copyright 2018 David Edmundson <davidedmundson@kde.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KCONFIGWATCHER_H +#define KCONFIGWATCHER_H + +#include <QObject> + +#include <KSharedConfig> +#include <KConfigGroup> + +#include <kconfigcore_export.h> + +class KConfigWatcherPrivate; + +/* + * Notifies when another client has updated this config file with the Notify flag set. + * @since 5.51 + */ +class KCONFIGCORE_EXPORT KConfigWatcher: public QObject +{ + Q_OBJECT +public: + typedef QSharedPointer<KConfigWatcher> Ptr; + + /* + * Instantiate a ConfigWatcher for a given config + * + * @note any additional config sources should be set before this point. + */ + static Ptr create(const KSharedConfig::Ptr &config); + +Q_SIGNALS: + /** + * Emitted when a config group has changed + * The config will be reloaded before this signal is emitted + * + * @arg group the config group that has changed + * @arg names a list of entries that have changed within that group + */ + void configChanged(const KConfigGroup &group, const QByteArrayList &names); + +private Q_SLOTS: + void onConfigChangeNotification(const QHash<QString, QByteArrayList> &changes); + +private: + KConfigWatcher(const KSharedConfig::Ptr &config); + Q_DISABLE_COPY(KConfigWatcher) + KConfigWatcherPrivate *const d; +}; + +#endif |