Use existing KSharedConfig in RuleBook::save
Summary: Recently a KSharedConfig was introduced in RuleBook. It makes sense to also use it in save and not just in load. Reviewers: #kwin, #plasma Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D12747icc-effect-5.14.5
parent
32a715b0c9
commit
a02797ca06
13
rules.cpp
13
rules.cpp
|
@ -1080,20 +1080,23 @@ void RuleBook::load()
|
||||||
void RuleBook::save()
|
void RuleBook::save()
|
||||||
{
|
{
|
||||||
m_updateTimer->stop();
|
m_updateTimer->stop();
|
||||||
KConfig cfg(QStringLiteral(KWIN_NAME "rulesrc"), KConfig::NoGlobals);
|
if (!m_config) {
|
||||||
QStringList groups = cfg.groupList();
|
qCWarning(KWIN_CORE) << "RuleBook::save invoked without prior invokation of RuleBook::load";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QStringList groups = m_config->groupList();
|
||||||
for (QStringList::ConstIterator it = groups.constBegin();
|
for (QStringList::ConstIterator it = groups.constBegin();
|
||||||
it != groups.constEnd();
|
it != groups.constEnd();
|
||||||
++it)
|
++it)
|
||||||
cfg.deleteGroup(*it);
|
m_config->deleteGroup(*it);
|
||||||
cfg.group("General").writeEntry("count", m_rules.count());
|
m_config->group("General").writeEntry("count", m_rules.count());
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (QList< Rules* >::ConstIterator it = m_rules.constBegin();
|
for (QList< Rules* >::ConstIterator it = m_rules.constBegin();
|
||||||
it != m_rules.constEnd();
|
it != m_rules.constEnd();
|
||||||
++it) {
|
++it) {
|
||||||
if ((*it)->isTemporary())
|
if ((*it)->isTemporary())
|
||||||
continue;
|
continue;
|
||||||
KConfigGroup cg(&cfg, QString::number(i));
|
KConfigGroup cg(m_config, QString::number(i));
|
||||||
(*it)->write(cg);
|
(*it)->write(cg);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue