From af83401b838ff0bc17ef8117f685c11f24a33ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 16 Nov 2016 13:42:45 +0100 Subject: [PATCH] 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 --- autotests/integration/effects/translucency_test.cpp | 3 +-- scripting/scriptedeffect.cpp | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autotests/integration/effects/translucency_test.cpp b/autotests/integration/effects/translucency_test.cpp index 428026d48c..d2073891b2 100644 --- a/autotests/integration/effects/translucency_test.cpp +++ b/autotests/integration/effects/translucency_test.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(); diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp index 193ed958dc..0d59b89307 100644 --- a/scripting/scriptedeffect.cpp +++ b/scripting/scriptedeffect.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #include "scriptingutils.h" #include "workspace_wrapper.h" #include "../screenedge.h" +#include "../main.h" #include "scripting_logging.h" // KDE #include @@ -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();