| 179 | } |
| 180 | |
| 181 | void ScriptingTool::evaluateCode(QString code) |
| 182 | { |
| 183 | QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss"); |
| 184 | QString output; |
| 185 | |
| 186 | QJSValue val = ScopyJS::GetInstance()->engine()->evaluate(code, ""); |
| 187 | int ret = EXIT_SUCCESS; |
| 188 | if(val.isError()) { |
| 189 | qWarning(CAT_SCRIPTINGTOOL) << "Exception:" << val.toString(); |
| 190 | ret = EXIT_FAILURE; |
| 191 | output += timestamp + ": Exception:" + val.toString(); |
| 192 | } else if(!val.isUndefined()) { |
| 193 | qWarning(CAT_SCRIPTINGTOOL) << val.toString(); |
| 194 | output += timestamp + ": " + val.toString(); |
| 195 | } |
| 196 | |
| 197 | if(m_runBtn->isChecked()) |
| 198 | output += "\n" + timestamp + ": Script finished with status " + QString::number(ret); |
| 199 | |
| 200 | m_console->appendPlainText(output); |
| 201 | |
| 202 | if(m_runBtn->isEnabled()) { |
| 203 | m_runBtn->setChecked(false); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | #include "moc_scriptingtool.cpp" |
nothing calls this directly
no test coverage detected