| 384 | } |
| 385 | |
| 386 | bool |
| 387 | TWScriptManager::runScript(QObject* script, QObject * context, QVariant & result, Tw::Scripting::Script::ScriptType scriptType) |
| 388 | { |
| 389 | Tw::Settings settings; |
| 390 | |
| 391 | Tw::Scripting::ScriptObject * so = qobject_cast<Tw::Scripting::ScriptObject*>(script); |
| 392 | if (!so || so->getType() != scriptType) |
| 393 | return false; |
| 394 | |
| 395 | const bool needsPlugin = ( |
| 396 | #if WITH_QTSCRIPT |
| 397 | qobject_cast<const Tw::Scripting::JSScriptInterface*>(so->getScriptLanguagePlugin()) == nullptr && |
| 398 | #endif |
| 399 | qobject_cast<const Tw::Scripting::ECMAScriptInterface*>(so->getScriptLanguagePlugin()) == nullptr |
| 400 | ); |
| 401 | if (needsPlugin && !settings.value(QString::fromLatin1("enableScriptingPlugins"), false).toBool()) |
| 402 | return false; |
| 403 | |
| 404 | if (!so->isEnabled()) |
| 405 | return false; |
| 406 | |
| 407 | Tw::Scripting::ScriptAPI api(so, qApp, context, result); |
| 408 | return so->run(api); |
| 409 | } |
| 410 | |
| 411 | void |
| 412 | TWScriptManager::runHooks(const QString& hookName, QObject * context /* = nullptr */) |
nothing calls this directly
no test coverage detected