| 125 | } |
| 126 | |
| 127 | void |
| 128 | TWScriptableWindow::runScript(QObject* scriptObj, Tw::Scripting::Script::ScriptType scriptType) |
| 129 | { |
| 130 | QVariant result; |
| 131 | |
| 132 | TWScriptManager * sm = TWApp::instance()->getScriptManager(); |
| 133 | if (!sm) |
| 134 | return; |
| 135 | |
| 136 | Tw::Scripting::ScriptObject * so = qobject_cast<Tw::Scripting::ScriptObject*>(scriptObj); |
| 137 | if (!so) { |
| 138 | return; |
| 139 | } |
| 140 | Tw::Scripting::Script * s = so->getScript(); |
| 141 | if (!s || s->getType() != scriptType) |
| 142 | return; |
| 143 | |
| 144 | bool success = sm->runScript(scriptObj, this, result, scriptType); |
| 145 | |
| 146 | if (success) { |
| 147 | if (!result.isNull() && !result.toString().isEmpty()) { |
| 148 | if (scriptType == Tw::Scripting::Script::ScriptHook) |
| 149 | statusBar()->showMessage(tr("Script \"%1\": %2").arg(s->getTitle(), result.toString()), kStatusMessageDuration); |
| 150 | else |
| 151 | QMessageBox::information(this, tr("Script result"), result.toString(), QMessageBox::Ok, QMessageBox::Ok); |
| 152 | } |
| 153 | } |
| 154 | else { |
| 155 | if (result.isNull()) |
| 156 | result = tr("unknown error"); |
| 157 | QMessageBox::information(this, tr("Script error"), tr("Script \"%1\": %2").arg(s->getTitle(), result.toString()), QMessageBox::Ok, QMessageBox::Ok); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | void |
| 162 | TWScriptableWindow::runHooks(const QString& hookName) |
nothing calls this directly
no test coverage detected