| 59 | void ScopyJS::exit() { QApplication::closeAllWindows(); } |
| 60 | |
| 61 | void ScopyJS::init() |
| 62 | { |
| 63 | QJSValue js_obj = m_engine.newQObject(this); |
| 64 | auto meta = metaObject(); |
| 65 | input = ""; |
| 66 | |
| 67 | for(int i = meta->methodOffset(); i < meta->methodCount(); i++) { |
| 68 | QString name(meta->method(i).name()); |
| 69 | |
| 70 | m_engine.globalObject().setProperty(name, js_obj.property(name)); |
| 71 | } |
| 72 | |
| 73 | m_engine.globalObject().setProperty("inspect()", |
| 74 | m_engine.evaluate("(function(o) { for (each in o) { print(each); } })")); |
| 75 | m_engine.installExtensions(QJSEngine::ConsoleExtension); |
| 76 | m_engine.globalObject().setProperty("fileIO", m_engine.newQObject(new JsFileIo(this))); |
| 77 | |
| 78 | if(isatty(STDIN_FILENO)) { |
| 79 | // verify if stdin is a true TTY - prevents QtCreator Application output from flooding the application |
| 80 | // notifier->setEnabled(false); |
| 81 | notifier = new QSocketNotifier(STDIN_FILENO, QSocketNotifier::Read); |
| 82 | connect(notifier, SIGNAL(activated(int)), this, SLOT(hasText())); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | void ScopyJS::returnToApplication() |
| 87 | { |