Use KWin's KSharedConfigPtr in ScriptedEffect

Summary:
So far ScriptedEffect used EffectsHandler::effectConfig to get the
KConfigGroup for the ScriptedEffect. This has the disadvantage that the
config file name is hardcoded to kwinrc in EffectsHandler::effectConfig.

Inside KWin a KSharedConfigPtr is used which can point to somwhere else
than kwinrc. If that was the case the ScriptedEffects were not able to
pick up this customized config and instead continued to read values from
kwinrc.

With this change the ScriptedEffects use the KSharedConfigPtr provided
by KWin. Thus in e.g. autotests we can use the general way to configure
the effects and don't need to write to the config.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3383
remotes/origin/bshah/hwcomposer_testing
Martin Gräßlin 9 years ago
parent 9a582f6dbe
commit af83401b83
  1. 3
      autotests/integration/effects/translucency_test.cpp
  2. 3
      scripting/scriptedeffect.cpp

@ -71,11 +71,10 @@ void TranslucencyTest::initTestCase()
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->group("Outline").writeEntry(QStringLiteral("QmlPath"), QString("/does/not/exist.qml"));
config->group("Effect-kwin4_effect_translucency").writeEntry(QStringLiteral("Dialogs"), 90);
config->sync();
kwinApp()->setConfig(config);
// TODO: make effects use KWin's config directly
KSharedConfig::openConfig(QStringLiteral(KWIN_CONFIG), KConfig::NoGlobals)->group("Effect-kwin4_effect_translucency").writeEntry(QStringLiteral("Dialogs"), 90);
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", "1");
kwinApp()->start();

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "scriptingutils.h"
#include "workspace_wrapper.h"
#include "../screenedge.h"
#include "../main.h"
#include "scripting_logging.h"
// KDE
#include <KConfigGroup>
@ -482,7 +483,7 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript
// does the effect contain an KConfigXT file?
const QString kconfigXTFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(KWIN_NAME "/effects/") + m_effectName + QLatin1String("/contents/config/main.xml"));
if (!kconfigXTFile.isNull()) {
KConfigGroup cg = effects->effectConfig(m_effectName);
KConfigGroup cg = kwinApp()->config()->group(QStringLiteral("Effect-%1").arg(m_effectName));
QFile xmlFile(kconfigXTFile);
m_config = new KConfigLoader(cg, &xmlFile, this);
m_config->load();

Loading…
Cancel
Save