|
24 | 24 | #include <libinputactions/InputActionsMain.h> |
25 | 25 | #include <libinputactions/PointF.h> |
26 | 26 | #include <libinputactions/config/ConfigIssue.h> |
| 27 | +#include <libinputactions/globals.h> |
27 | 28 | #include <libinputactions/helpers/QString.h> |
28 | 29 | #include <libinputactions/helpers/QThread.h> |
29 | 30 | #include <libinputactions/interfaces/NotificationManager.h> |
@@ -71,8 +72,13 @@ void ScriptingEngine::initialize() |
71 | 72 | m_coreModule = std::make_unique<CoreModule>(); |
72 | 73 | QJSEngine::setObjectOwnership(m_coreModule.get(), QJSEngine::CppOwnership); |
73 | 74 | auto coreModule = m_engine->newQObject(m_coreModule.get()); |
| 75 | + coreModule.setProperty("KeyboardModifier", newEnum<KeyboardModifier>()); |
74 | 76 | registerBuiltinModule("inputactions/core", coreModule); |
75 | 77 |
|
| 78 | + auto desktopModule = m_engine->newObject(); |
| 79 | + desktopModule.setProperty("CursorShape", newEnum<CursorShape>()); |
| 80 | + registerBuiltinModule("inputactions/desktop", desktopModule); |
| 81 | + |
76 | 82 | auto fsModule = m_engine->newObject(); |
77 | 83 | fsModule.setProperty("File", m_engine->newQMetaObject(&File::staticMetaObject)); |
78 | 84 | auto file = fsModule.property("File"); |
@@ -166,6 +172,15 @@ void ScriptingEngine::registerBuiltinModule(const QString &name, QJSValue value) |
166 | 172 | m_builtinModules[name] = std::move(value); |
167 | 173 | } |
168 | 174 |
|
| 175 | +QJSValue ScriptingEngine::newEnum(const QMetaEnum &metaEnum) |
| 176 | +{ |
| 177 | + auto object = ensureEngine().newObject(); |
| 178 | + for (int i = 0; i < metaEnum.keyCount(); i++) { |
| 179 | + object.setProperty(metaEnum.key(i), metaEnum.value(i)); |
| 180 | + } |
| 181 | + return object; |
| 182 | +} |
| 183 | + |
169 | 184 | QJSValue ScriptingEngine::evaluate(const QString &script) |
170 | 185 | { |
171 | 186 | const auto result = ensureEngine().evaluate(script); |
|
0 commit comments