mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-17 11:37:10 +03:00
chore(plasmaapi): replace root js object with qml context
The script is actually loaded via QML and therefore it uses context properties instead of the global object. If the script were loaded as a javascript - it would use the global object.
This commit is contained in:
parent
b43ca58b33
commit
d58cfd240c
@ -3,6 +3,8 @@
|
||||
|
||||
#include "workspace.hpp"
|
||||
|
||||
#include <QQmlContext>
|
||||
|
||||
#include "logger.hpp"
|
||||
#include "plasma-api/client.hpp"
|
||||
#include "plasma-api/plasma-api.hpp"
|
||||
@ -13,7 +15,7 @@ namespace PlasmaApi
|
||||
Workspace::Workspace(QQmlEngine *engine)
|
||||
: QObject()
|
||||
, m_engine(engine)
|
||||
, m_kwinImpl(engine->globalObject().property("workspace").toQObject())
|
||||
, m_kwinImpl(m_engine->rootContext()->contextProperty(QStringLiteral("workspace")).value<QObject *>())
|
||||
{
|
||||
wrapSignals();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlContext>
|
||||
#include <QQmlEngine>
|
||||
#include <QSignalSpy>
|
||||
|
||||
@ -49,7 +50,7 @@ TEST_CASE("Workspace Properties Read")
|
||||
auto mockWorkspace = MockWorkspaceJS();
|
||||
mockWorkspace.setCurrentDesktop(42);
|
||||
|
||||
engine.globalObject().setProperty(QStringLiteral("workspace"), engine.newQObject(&mockWorkspace));
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("workspace"), &mockWorkspace);
|
||||
|
||||
auto plasmaApi = ::PlasmaApi::PlasmaApi(&engine);
|
||||
auto workspace = plasmaApi.workspace();
|
||||
@ -66,7 +67,7 @@ TEST_CASE("Workspace Properties Write")
|
||||
auto engine = QQmlEngine();
|
||||
auto mockWorkspace = MockWorkspaceJS();
|
||||
|
||||
engine.globalObject().setProperty(QStringLiteral("workspace"), engine.newQObject(&mockWorkspace));
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("workspace"), &mockWorkspace);
|
||||
|
||||
auto plasmaApi = ::PlasmaApi::PlasmaApi(&engine);
|
||||
auto workspace = plasmaApi.workspace();
|
||||
@ -85,7 +86,7 @@ TEST_CASE("Workspace Properties Signals")
|
||||
auto engine = QQmlEngine();
|
||||
auto mockWorkspace = MockWorkspaceJS();
|
||||
|
||||
engine.globalObject().setProperty(QStringLiteral("workspace"), engine.newQObject(&mockWorkspace));
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("workspace"), &mockWorkspace);
|
||||
|
||||
auto plasmaApi = ::PlasmaApi::PlasmaApi(&engine);
|
||||
auto workspace = plasmaApi.workspace();
|
||||
|
Loading…
Reference in New Issue
Block a user