Changeset View
Changeset View
Standalone View
Standalone View
src/core/kconfigwatcher.cpp
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 81 | QDBusConnection::sessionBus().connect(QString(), | |||
---|---|---|---|---|---|
85 | this, | 85 | this, | ||
86 | SLOT(onConfigChangeNotification(QHash<QString,QByteArrayList>))); | 86 | SLOT(onConfigChangeNotification(QHash<QString,QByteArrayList>))); | ||
87 | } | 87 | } | ||
88 | #else | 88 | #else | ||
89 | qCWarning(KCONFIG_CORE_LOG) << "Use of KConfigWatcher without DBus support. You will not receive updates"; | 89 | qCWarning(KCONFIG_CORE_LOG) << "Use of KConfigWatcher without DBus support. You will not receive updates"; | ||
90 | #endif | 90 | #endif | ||
91 | } | 91 | } | ||
92 | 92 | | |||
93 | KConfigWatcher::~KConfigWatcher() = default; | ||||
94 | | ||||
93 | void KConfigWatcher::onConfigChangeNotification(const QHash<QString, QByteArrayList> &changes) | 95 | void KConfigWatcher::onConfigChangeNotification(const QHash<QString, QByteArrayList> &changes) | ||
94 | { | 96 | { | ||
95 | //should we ever need it we can determine the file changed with QDbusContext::message().path(), but it doesn't seem too useful | 97 | //should we ever need it we can determine the file changed with QDbusContext::message().path(), but it doesn't seem too useful | ||
96 | 98 | | |||
97 | d->m_config->reparseConfiguration(); | 99 | d->m_config->reparseConfiguration(); | ||
98 | 100 | | |||
99 | for(auto it = changes.constBegin(); it != changes.constEnd(); it++) { | 101 | for(auto it = changes.constBegin(); it != changes.constEnd(); it++) { | ||
100 | KConfigGroup group = d->m_config->group(QString());//top level group | 102 | KConfigGroup group = d->m_config->group(QString());//top level group | ||
101 | const auto parts = it.key().split(QLatin1Char('\x1d')); //magic char, see KConfig | 103 | const auto parts = it.key().split(QLatin1Char('\x1d')); //magic char, see KConfig | ||
102 | for(const QString &groupName: parts) { | 104 | for(const QString &groupName: parts) { | ||
103 | group = group.group(groupName); | 105 | group = group.group(groupName); | ||
104 | } | 106 | } | ||
105 | emit configChanged(group, it.value()); | 107 | emit configChanged(group, it.value()); | ||
106 | } | 108 | } | ||
107 | } | 109 | } | ||
108 | 110 | |