File tree Expand file tree Collapse file tree
src/libinputactions/scripting Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ void ScriptingEngine::initialize()
6767 }
6868 )" );
6969
70- m_coreModule = std::make_unique<CoreModule>();
70+ m_coreModule = std::make_unique<CoreModule>(m_engine-> globalObject () );
7171 QJSEngine::setObjectOwnership (m_coreModule.get (), QJSEngine::CppOwnership);
7272 auto coreModule = m_engine->newQObject (m_coreModule.get ());
7373 coreModule.setProperty (" Point" , m_engine->newQMetaObject (&PointF::staticMetaObject));
Original file line number Diff line number Diff line change 2525namespace InputActions
2626{
2727
28- CoreModule::CoreModule ()
28+ CoreModule::CoreModule (QJSValue globalObject )
2929 : m_config(std::make_unique<Config>())
30+ , m_globalObject(std::move(globalObject))
3031{
3132 QJSEngine::setObjectOwnership (m_config.get (), QJSEngine::CppOwnership);
3233}
Original file line number Diff line number Diff line change 1818
1919#pragma once
2020
21+ #include < QJSValue>
2122#include < QObject>
2223
2324namespace InputActions
@@ -33,18 +34,21 @@ class CoreModule : public QObject
3334
3435 Q_PROPERTY (Config *config READ config)
3536 Q_PROPERTY (InputBackend *input READ input)
37+ Q_PROPERTY (QJSValue globalThis READ globalThis)
3638 Q_PROPERTY (VariableRegistry *variableRegistry READ variableRegistry)
3739
3840public:
39- CoreModule ();
41+ CoreModule (QJSValue globalObject );
4042 ~CoreModule () override ;
4143
4244 Config *config () const ;
45+ QJSValue globalThis () const { return m_globalObject; }
4346 InputBackend *input () const ;
4447 VariableRegistry *variableRegistry () const ;
4548
4649private:
4750 std::unique_ptr<Config> m_config;
51+ QJSValue m_globalObject;
4852};
4953
5054}
You can’t perform that action at this time.
0 commit comments