diff --git a/autotests/test_scripted_effectloader.cpp b/autotests/test_scripted_effectloader.cpp index 9af6248694..f0e2049a03 100644 --- a/autotests/test_scripted_effectloader.cpp +++ b/autotests/test_scripted_effectloader.cpp @@ -33,6 +33,7 @@ along with this program. If not, see . Q_DECLARE_METATYPE(KWin::LoadEffectFlag) Q_DECLARE_METATYPE(KWin::LoadEffectFlags) Q_DECLARE_METATYPE(KWin::Effect*) +Q_DECLARE_METATYPE(KSharedConfigPtr) Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core") @@ -64,6 +65,7 @@ class TestScriptedEffectLoader : public QObject { Q_OBJECT private Q_SLOTS: + void initTestCase(); void testHasEffect_data(); void testHasEffect(); void testKnownEffects(); @@ -75,6 +77,12 @@ private Q_SLOTS: void testCancelLoadAllEffects(); }; +void TestScriptedEffectLoader::initTestCase() +{ + auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); + QCoreApplication::instance()->setProperty("config", QVariant::fromValue(config)); +} + void TestScriptedEffectLoader::testHasEffect_data() { QTest::addColumn("name"); diff --git a/main.cpp b/main.cpp index e5fc0c2297..65fc150388 100644 --- a/main.cpp +++ b/main.cpp @@ -65,6 +65,8 @@ along with this program. If not, see . #define XCB_GE_GENERIC 35 #endif +Q_DECLARE_METATYPE(KSharedConfigPtr) + namespace KWin { @@ -107,6 +109,7 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv qRegisterMetaType("Options::WindowOperation"); qRegisterMetaType(); qRegisterMetaType("KWayland::Server::SurfaceInterface *"); + qRegisterMetaType(); } void Application::setConfigLock(bool lock) diff --git a/main.h b/main.h index a7dd47dd60..0758da8405 100644 --- a/main.h +++ b/main.h @@ -54,6 +54,7 @@ class KWIN_EXPORT Application : public QApplication Q_PROPERTY(quint32 x11RootWindow READ x11RootWindow CONSTANT) Q_PROPERTY(void *x11Connection READ x11Connection NOTIFY x11ConnectionChanged) Q_PROPERTY(int x11ScreenNumber READ x11ScreenNumber CONSTANT) + Q_PROPERTY(KSharedConfigPtr config READ config WRITE setConfig) public: /** * @brief This enum provides the various operation modes of KWin depending on the available diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp index 0d59b89307..ab99d8b326 100644 --- a/scripting/scriptedeffect.cpp +++ b/scripting/scriptedeffect.cpp @@ -23,7 +23,6 @@ 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 @@ -37,6 +36,8 @@ along with this program. If not, see . typedef KWin::EffectWindow* KEffectWindowRef; +Q_DECLARE_METATYPE(KSharedConfigPtr) + namespace KWin { @@ -483,7 +484,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 = kwinApp()->config()->group(QStringLiteral("Effect-%1").arg(m_effectName)); + KConfigGroup cg = QCoreApplication::instance()->property("config").value()->group(QStringLiteral("Effect-%1").arg(m_effectName)); QFile xmlFile(kconfigXTFile); m_config = new KConfigLoader(cg, &xmlFile, this); m_config->load();