intial commit #21369 Working on clear method of console

This commit is contained in:
NeetBhagat 2017-06-06 19:00:21 +05:30
parent e79fd9c5cb
commit 904e25c9e3
14 changed files with 154 additions and 121 deletions

View file

@ -74,6 +74,12 @@ Windows.Window {
root.dynamicContent.fromScript(message);
}
}
function fromConsole() {
if (root.dynamicContent && root.dynamicContent.fromConsole) {
root.dynamicContent.fromConsole();
}
}
// Handle message traffic from our loaded QML to the script that launched us
signal sendToScript(var message);

View file

@ -5514,6 +5514,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
connect(scriptEngine, &ScriptEngine::errorMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onErrorMessage);
connect(scriptEngine, &ScriptEngine::warningMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onWarningMessage);
connect(scriptEngine, &ScriptEngine::infoMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onInfoMessage);
connect(scriptEngine, &ScriptEngine::clearDebugWindow, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::OnClearConsole);
}
bool Application::canAcceptURL(const QString& urlString) const {

View file

@ -21,7 +21,6 @@
#include "Application.h"
#include "JSConsole.h"
#include "ScriptHighlighting.h"
//#include "D:\Dhruvesh\Project\Hifi\github\hifi\libraries\script-engine\src\ScriptEngineLogging.h"
const int NO_CURRENT_HISTORY_COMMAND = -1;
const int MAX_HISTORY_SIZE = 64;
@ -36,15 +35,15 @@ const QString RESULT_ERROR_STYLE = "color: #d13b22;";
const QString GUTTER_PREVIOUS_COMMAND = "<span style=\"color: #57b8bb;\">&lt;</span>";
const QString GUTTER_ERROR = "<span style=\"color: #d13b22;\">X</span>";
const QString JSConsole::_consoleFileName { "about:console" };
const QString JSConsole::_consoleFileName{ "about:console" };
JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) :
QWidget(parent),
_ui(new Ui::Console),
_currentCommandInHistory(NO_CURRENT_HISTORY_COMMAND),
_commandHistory(),
_ownScriptEngine(scriptEngine == NULL),
_scriptEngine(NULL) {
QWidget(parent),
_ui(new Ui::Console),
_currentCommandInHistory(NO_CURRENT_HISTORY_COMMAND),
_commandHistory(),
_ownScriptEngine(scriptEngine == NULL),
_scriptEngine(NULL) {
_ui->setupUi(this);
_ui->promptTextEdit->setLineWrapMode(QTextEdit::NoWrap);
@ -85,7 +84,6 @@ void JSConsole::setScriptEngine(ScriptEngine* scriptEngine) {
disconnect(_scriptEngine, &ScriptEngine::infoMessage, this, &JSConsole::handleInfo);
disconnect(_scriptEngine, &ScriptEngine::warningMessage, this, &JSConsole::handleWarning);
disconnect(_scriptEngine, &ScriptEngine::errorMessage, this, &JSConsole::handleError);
disconnect(_scriptEngine, &ScriptEngine::clearDebugWindow, this, &JSConsole::clear);
if (_ownScriptEngine) {
_scriptEngine->deleteLater();
}
@ -99,7 +97,6 @@ void JSConsole::setScriptEngine(ScriptEngine* scriptEngine) {
connect(_scriptEngine, &ScriptEngine::infoMessage, this, &JSConsole::handleInfo);
connect(_scriptEngine, &ScriptEngine::warningMessage, this, &JSConsole::handleWarning);
connect(_scriptEngine, &ScriptEngine::errorMessage, this, &JSConsole::handleError);
connect(_scriptEngine, &ScriptEngine::clearDebugWindow, this, &JSConsole::clear);
}
void JSConsole::executeCommand(const QString& command) {
@ -119,9 +116,9 @@ void JSConsole::executeCommand(const QString& command) {
QScriptValue JSConsole::executeCommandInWatcher(const QString& command) {
QScriptValue result;
QMetaObject::invokeMethod(_scriptEngine, "evaluate", Qt::ConnectionType::BlockingQueuedConnection,
Q_RETURN_ARG(QScriptValue, result),
Q_ARG(const QString&, command),
Q_ARG(const QString&, _consoleFileName));
Q_RETURN_ARG(QScriptValue, result),
Q_ARG(const QString&, command),
Q_ARG(const QString&, _consoleFileName));
return result;
}
@ -147,7 +144,6 @@ void JSConsole::commandFinished() {
void JSConsole::handleError(const QString& message, const QString& scriptName) {
Q_UNUSED(scriptName);
appendMessage(GUTTER_ERROR, "<span style='" + RESULT_ERROR_STYLE + "'>" + message.toHtmlEscaped() + "</span>");
}
void JSConsole::handlePrint(const QString& message, const QString& scriptName) {
@ -184,7 +180,8 @@ bool JSConsole::eventFilter(QObject* sender, QEvent* event) {
// If the shift key is being used then treat it as a regular return/enter. If this isn't done,
// a new QTextBlock isn't created.
keyEvent->setModifiers(keyEvent->modifiers() & ~Qt::ShiftModifier);
} else {
}
else {
QString command = _ui->promptTextEdit->toPlainText().trimmed();
if (!command.isEmpty()) {
@ -196,7 +193,8 @@ bool JSConsole::eventFilter(QObject* sender, QEvent* event) {
return true;
}
} else if (key == Qt::Key_Down) {
}
else if (key == Qt::Key_Down) {
// Go to the next command in history if the cursor is at the last line of the current command.
int blockNumber = _ui->promptTextEdit->textCursor().blockNumber();
int blockCount = _ui->promptTextEdit->document()->blockCount();
@ -204,7 +202,8 @@ bool JSConsole::eventFilter(QObject* sender, QEvent* event) {
setToNextCommandInHistory();
return true;
}
} else if (key == Qt::Key_Up) {
}
else if (key == Qt::Key_Up) {
// Go to the previous command in history if the cursor is at the first line of the current command.
int blockNumber = _ui->promptTextEdit->textCursor().blockNumber();
if (blockNumber == 0) {
@ -222,7 +221,8 @@ void JSConsole::setToNextCommandInHistory() {
_currentCommandInHistory--;
if (_currentCommandInHistory == NO_CURRENT_HISTORY_COMMAND) {
setAndSelectCommand(_rootCommand);
} else {
}
else {
setAndSelectCommand(_commandHistory[_currentCommandInHistory]);
}
}
@ -295,14 +295,11 @@ void JSConsole::appendMessage(const QString& gutter, const QString& message) {
}
void JSConsole::clear() {
/* qCDebug(scriptengine) << "=============================";
qCDebug(scriptengine) << "Clear fUNCTION";*/
QLayoutItem* item;
while ((item = _ui->logArea->layout()->takeAt(0)) != NULL) {
// qCDebug(scriptengine) << "While loop called";
delete item->widget();
delete item;
}
// _ui->logArea->updateGeometry();
// scrollToBottom();
_ui->logArea->updateGeometry();
scrollToBottom();
}

View file

@ -32,9 +32,10 @@ public:
JSConsole(QWidget* parent, ScriptEngine* scriptEngine = NULL);
~JSConsole();
void setScriptEngine(ScriptEngine* scriptEngine = NULL);
void setScriptEngine(ScriptEngine* scriptEngine = NULL);
void clear();
public slots:
public slots:
void executeCommand(const QString& command);
protected:
@ -43,15 +44,14 @@ protected:
virtual void mouseReleaseEvent(QMouseEvent* event) override;
virtual void showEvent(QShowEvent* event) override;
protected slots:
protected slots:
void scrollToBottom();
void resizeTextInput();
void handlePrint(const QString& message, const QString& scriptName);
void handleInfo(const QString& message, const QString& scriptName);
void handleWarning(const QString& message, const QString& scriptName);
void handleError(const QString& message, const QString& scriptName);
void commandFinished();
void clear();
void commandFinished();
private:
void appendMessage(const QString& gutter, const QString& message);

View file

@ -15,8 +15,8 @@
#include "Application.h"
TestingDialog::TestingDialog(QWidget* parent) :
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint),
_console(new JSConsole(this))
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint),
_console(new JSConsole(this))
{
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(windowLabel);
@ -26,11 +26,10 @@ TestingDialog::TestingDialog(QWidget* parent) :
auto _engines = DependencyManager::get<ScriptEngines>();
_engine = _engines->loadScript(qApp->applicationDirPath() + testRunnerRelativePath);
_console->setScriptEngine(_engine);
connect(_engine, &ScriptEngine::finished, this, &TestingDialog::onTestingFinished);
connect(_engine, &ScriptEngine::finished, this, &TestingDialog::onTestingFinished);
}
void TestingDialog::onTestingFinished(const QString& scriptPath) {
_engine = nullptr;
_console->setScriptEngine(nullptr);
}

View file

@ -44,7 +44,7 @@ Q_LOGGING_CATEGORY(trace_render_qml_gl, "trace.render.qml.gl")
struct TextureSet {
// The number of surfaces with this size
size_t count { 0 };
size_t count{ 0 };
std::list<OffscreenQmlSurface::TextureAndFence> returnedTextures;
};
@ -193,7 +193,7 @@ private:
std::unordered_map<GLuint, uvec2> _textureSizes;
Mutex _mutex;
std::list<OffscreenQmlSurface::TextureAndFence> _returnedTextures;
size_t _totalTextureUsage { 0 };
size_t _totalTextureUsage{ 0 };
} offscreenTextures;
class UrlHandler : public QObject {
@ -286,7 +286,7 @@ void OffscreenQmlSurface::render() {
}
PROFILE_RANGE(render_qml_gl, __FUNCTION__)
_canvas->makeCurrent();
_canvas->makeCurrent();
_renderControl->sync();
_quickWindow->setRenderTarget(_fbo, QSize(_size.x, _size.y));
@ -532,8 +532,8 @@ QObject* OffscreenQmlSurface::load(const QUrl& qmlSource, std::function<void(QQm
if (_qmlComponent->isLoading()) {
connect(_qmlComponent, &QQmlComponent::statusChanged, this,
[this, f](QQmlComponent::Status){
finishQmlLoad(f);
});
finishQmlLoad(f);
});
return nullptr;
}
@ -563,7 +563,8 @@ QObject* OffscreenQmlSurface::finishQmlLoad(std::function<void(QQmlContext*, QOb
QString webChannelStr = QTextStream(&webChannelFile).readAll();
QString createGlobalEventBridgeStr = QTextStream(&createGlobalEventBridgeFile).readAll();
javaScriptToInject = webChannelStr + createGlobalEventBridgeStr;
} else {
}
else {
qCWarning(glLogging) << "Unable to find qwebchannel.js or createGlobalEventBridge.js";
}
@ -634,7 +635,7 @@ void OffscreenQmlSurface::updateQuick() {
if (_polish) {
PROFILE_RANGE(render_qml, "OffscreenQML polish")
_renderControl->polishItems();
_renderControl->polishItems();
_polish = false;
}
@ -648,7 +649,8 @@ QPointF OffscreenQmlSurface::mapWindowToUi(const QPointF& sourcePosition, QObjec
vec2 sourceSize;
if (dynamic_cast<QWidget*>(sourceObject)) {
sourceSize = toGlm(((QWidget*)sourceObject)->size());
} else if (dynamic_cast<QWindow*>(sourceObject)) {
}
else if (dynamic_cast<QWindow*>(sourceObject)) {
sourceSize = toGlm(((QWindow*)sourceObject)->size());
}
vec2 offscreenPosition = toGlm(sourcePosition);
@ -691,61 +693,61 @@ bool OffscreenQmlSurface::eventFilter(QObject* originalDestination, QEvent* even
#endif
switch (event->type()) {
case QEvent::Resize: {
QResizeEvent* resizeEvent = static_cast<QResizeEvent*>(event);
QWidget* widget = dynamic_cast<QWidget*>(originalDestination);
if (widget) {
this->resize(resizeEvent->size());
}
break;
case QEvent::Resize: {
QResizeEvent* resizeEvent = static_cast<QResizeEvent*>(event);
QWidget* widget = dynamic_cast<QWidget*>(originalDestination);
if (widget) {
this->resize(resizeEvent->size());
}
break;
}
case QEvent::KeyPress:
case QEvent::KeyRelease: {
event->ignore();
if (QCoreApplication::sendEvent(_quickWindow, event)) {
return event->isAccepted();
}
break;
case QEvent::KeyPress:
case QEvent::KeyRelease: {
event->ignore();
if (QCoreApplication::sendEvent(_quickWindow, event)) {
return event->isAccepted();
}
break;
}
case QEvent::Wheel: {
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos(), originalDestination);
QWheelEvent mappedEvent(
transformedPos,
wheelEvent->delta(), wheelEvent->buttons(),
wheelEvent->modifiers(), wheelEvent->orientation());
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_quickWindow, &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
case QEvent::Wheel: {
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos(), originalDestination);
QWheelEvent mappedEvent(
transformedPos,
wheelEvent->delta(), wheelEvent->buttons(),
wheelEvent->modifiers(), wheelEvent->orientation());
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_quickWindow, &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
}
// Fall through
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove: {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos(), originalDestination);
QMouseEvent mappedEvent(mouseEvent->type(),
transformedPos,
mouseEvent->screenPos(), mouseEvent->button(),
mouseEvent->buttons(), mouseEvent->modifiers());
if (event->type() == QEvent::MouseMove) {
_qmlEngine->rootContext()->setContextProperty("lastMousePosition", transformedPos);
}
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_quickWindow, &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
// Fall through
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove: {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos(), originalDestination);
QMouseEvent mappedEvent(mouseEvent->type(),
transformedPos,
mouseEvent->screenPos(), mouseEvent->button(),
mouseEvent->buttons(), mouseEvent->modifiers());
if (event->type() == QEvent::MouseMove) {
_qmlEngine->rootContext()->setContextProperty("lastMousePosition", transformedPos);
}
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_quickWindow, &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
}
default:
break;
default:
break;
}
return false;
@ -800,7 +802,7 @@ Q_DECLARE_METATYPE(std::function<QVariant()>);
auto VariantLambdaType = qRegisterMetaType<std::function<QVariant()>>();
void OffscreenQmlSurface::executeOnUiThread(std::function<void()> function, bool blocking ) {
void OffscreenQmlSurface::executeOnUiThread(std::function<void()> function, bool blocking) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "executeOnUiThread", blocking ? Qt::BlockingQueuedConnection : Qt::QueuedConnection,
Q_ARG(std::function<void()>, function));
@ -892,16 +894,20 @@ void OffscreenQmlSurface::synthesizeKeyPress(QString key) {
if (equals(utf8Key, SHIFT_ARROW) || equals(utf8Key, NUMERIC_SHIFT_ARROW) ||
equals(utf8Key, (uint8_t*)PUNCTUATION_STRING) || equals(utf8Key, (uint8_t*)ALPHABET_STRING)) {
return; // ignore
} else if (equals(utf8Key, BACKSPACE_SYMBOL)) {
}
else if (equals(utf8Key, BACKSPACE_SYMBOL)) {
scanCode = Qt::Key_Backspace;
keyString = "\x08";
} else if (equals(utf8Key, RETURN_SYMBOL)) {
}
else if (equals(utf8Key, RETURN_SYMBOL)) {
scanCode = Qt::Key_Return;
keyString = "\x0d";
} else if (equals(utf8Key, LEFT_ARROW)) {
}
else if (equals(utf8Key, LEFT_ARROW)) {
scanCode = Qt::Key_Left;
keyString = "";
} else if (equals(utf8Key, RIGHT_ARROW)) {
}
else if (equals(utf8Key, RIGHT_ARROW)) {
scanCode = Qt::Key_Right;
keyString = "";
}
@ -941,7 +947,8 @@ void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool n
void OffscreenQmlSurface::emitScriptEvent(const QVariant& message) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "emitScriptEvent", Qt::QueuedConnection, Q_ARG(QVariant, message));
} else {
}
else {
emit scriptEventReceived(message);
}
}
@ -949,7 +956,8 @@ void OffscreenQmlSurface::emitScriptEvent(const QVariant& message) {
void OffscreenQmlSurface::emitWebEvent(const QVariant& message) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "emitWebEvent", Qt::QueuedConnection, Q_ARG(QVariant, message));
} else {
}
else {
// Special case to handle raising and lowering the virtual keyboard.
const QString RAISE_KEYBOARD = "_RAISE_KEYBOARD";
const QString RAISE_KEYBOARD_NUMERIC = "_RAISE_KEYBOARD_NUMERIC";
@ -957,9 +965,11 @@ void OffscreenQmlSurface::emitWebEvent(const QVariant& message) {
QString messageString = message.type() == QVariant::String ? message.toString() : "";
if (messageString.left(RAISE_KEYBOARD.length()) == RAISE_KEYBOARD) {
setKeyboardRaised(_currentFocusItem, true, messageString == RAISE_KEYBOARD_NUMERIC);
} else if (messageString == LOWER_KEYBOARD) {
}
else if (messageString == LOWER_KEYBOARD) {
setKeyboardRaised(_currentFocusItem, false);
} else {
}
else {
emit webEventReceived(message);
}
}
@ -968,7 +978,8 @@ void OffscreenQmlSurface::emitWebEvent(const QVariant& message) {
void OffscreenQmlSurface::sendToQml(const QVariant& message) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "emitQmlEvent", Qt::QueuedConnection, Q_ARG(QVariant, message));
} else if (_rootItem) {
}
else if (_rootItem) {
// call fromScript method on qml root
QMetaObject::invokeMethod(_rootItem, "fromScript", Qt::QueuedConnection, Q_ARG(QVariant, message));
}

View file

@ -37,7 +37,7 @@ class QQuickItem;
class OffscreenQmlSurface : public QObject {
Q_OBJECT
Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged)
Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged)
public:
OffscreenQmlSurface();
virtual ~OffscreenQmlSurface();
@ -95,12 +95,12 @@ signals:
void focusObjectChanged(QObject* newFocus);
void focusTextChanged(bool focusText);
public slots:
public slots:
void onAboutToQuit();
void focusDestroyed(QObject *obj);
// event bridge
public slots:
public slots:
void emitScriptEvent(const QVariant& scriptMessage);
void emitWebEvent(const QVariant& webMessage);
signals:
@ -108,7 +108,7 @@ signals:
void webEventReceived(const QVariant& message);
// qml event bridge
public slots:
public slots:
void sendToQml(const QVariant& message);
signals:
void fromQml(QVariant message);
@ -126,37 +126,37 @@ private:
void cleanup();
QJsonObject getGLContextData();
private slots:
private slots:
void updateQuick();
void onFocusObjectChanged(QObject* newFocus);
private:
QQuickWindow* _quickWindow { nullptr };
QQuickWindow* _quickWindow{ nullptr };
QMyQuickRenderControl* _renderControl{ nullptr };
QQmlEngine* _qmlEngine { nullptr };
QQmlComponent* _qmlComponent { nullptr };
QQuickItem* _rootItem { nullptr };
OffscreenGLCanvas* _canvas { nullptr };
QQmlEngine* _qmlEngine{ nullptr };
QQmlComponent* _qmlComponent{ nullptr };
QQuickItem* _rootItem{ nullptr };
OffscreenGLCanvas* _canvas{ nullptr };
QJsonObject _glData;
QTimer _updateTimer;
uint32_t _fbo { 0 };
uint32_t _depthStencil { 0 };
uint64_t _lastRenderTime { 0 };
uint32_t _fbo{ 0 };
uint32_t _depthStencil{ 0 };
uint64_t _lastRenderTime{ 0 };
uvec2 _size;
// Texture management
TextureAndFence _latestTextureAndFence { 0, 0 };
TextureAndFence _latestTextureAndFence{ 0, 0 };
bool _render { false };
bool _polish { true };
bool _paused { true };
bool _focusText { false };
uint8_t _maxFps { 60 };
MouseTranslator _mouseTranslator { [](const QPointF& p) { return p.toPoint(); } };
QWindow* _proxyWindow { nullptr };
bool _render{ false };
bool _polish{ true };
bool _paused{ true };
bool _focusText{ false };
uint8_t _maxFps{ 60 };
MouseTranslator _mouseTranslator{ [](const QPointF& p) { return p.toPoint(); } };
QWindow* _proxyWindow{ nullptr };
QQuickItem* _currentFocusItem { nullptr };
QQuickItem* _currentFocusItem{ nullptr };
};
#endif

View file

@ -485,10 +485,11 @@ void ScriptEngine::scriptPrintedMessage(const QString& message) {
qCDebug(scriptengine) << message;
emit printedMessage(message, getFilename());
}
void ScriptEngine::clearConsole() {
qCDebug(scriptengine) << "Clearing debug window";
emit clearDebugWindow();
}
// Even though we never pass AnimVariantMap directly to and from javascript, the queued invokeMethod of
// callAnimationStateHandler requires that the type be registered.
// These two are meaningful, if we ever do want to use them...

View file

@ -54,6 +54,10 @@ void ScriptEngines::onInfoMessage(const QString& message, const QString& scriptN
emit infoMessage(message, scriptName);
}
void ScriptEngines::OnClearConsole() {
emit clearDebugWindow();
}
void ScriptEngines::onErrorLoadingScript(const QString& url) {
emit errorLoadingScript(url);
}

View file

@ -79,6 +79,7 @@ signals:
void warningMessage(const QString& message, const QString& engineName);
void infoMessage(const QString& message, const QString& engineName);
void errorLoadingScript(const QString& url);
void clearDebugWindow();
public slots:
void onPrintedMessage(const QString& message, const QString& scriptName);
@ -86,6 +87,7 @@ public slots:
void onWarningMessage(const QString& message, const QString& scriptName);
void onInfoMessage(const QString& message, const QString& scriptName);
void onErrorLoadingScript(const QString& url);
void OnClearConsole();
protected slots:
void onScriptFinished(const QString& fileNameString, ScriptEngine* engine);

View file

@ -153,6 +153,9 @@ void QmlWindowClass::sendToQml(const QVariant& message) {
QMetaObject::invokeMethod(asQuickItem(), "fromScript", Qt::QueuedConnection, Q_ARG(QVariant, message));
}
void QmlWindowClass::clearConsole() {
QMetaObject::invokeMethod(asQuickItem(), "fromConsole", Qt::QueuedConnection);
}
void QmlWindowClass::emitScriptEvent(const QVariant& scriptMessage) {
if (QThread::currentThread() != thread()) {

View file

@ -53,6 +53,7 @@ public slots:
// Scripts can use this to send a message to the QML object
void sendToQml(const QVariant& message);
void clearConsole();
// QmlWindow content may include WebView requiring EventBridge.
void emitScriptEvent(const QVariant& scriptMessage);

View file

@ -49,4 +49,8 @@ ScriptDiscoveryService.infoMessage.connect(function(message, scriptFileName) {
sendToLogWindow("INFO", message, scriptFileName);
});
ScriptDiscoveryService.clearDebugWindow.connect(function () {
window.clearConsole();
});
}()); // END LOCAL_SCOPE

View file

@ -29,7 +29,7 @@ Rectangle {
height: parent.height
text:""
}
function fromScript(message) {
var MAX_LINE_COUNT = 2000;
var TRIM_LINES = 500;
@ -40,6 +40,10 @@ Rectangle {
}
textArea.append(message);
}
function fromConsole(){
textArea.remove(0,textArea.length);
}
}