Commit 1a073f36 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Show message in result area

parent ec569b8e
......@@ -57,6 +57,8 @@ TestWebEngineScriptPage::TestWebEngineScriptPage(QObject *parent)
void TestWebEngineScriptPage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
{
qDebug() << "JAVASCRIPT MESSAGE : "<< message;
//TODO improve it.
Q_EMIT showConsoleMessage(message);
}
TestWebEngineScript::TestWebEngineScript(QWidget *parent)
......@@ -64,14 +66,15 @@ TestWebEngineScript::TestWebEngineScript(QWidget *parent)
{
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
mTestWebEngine = new TestWebEngineScriptView(this);
mTestWebEngine->setPage(new TestWebEngineScriptPage(this));
TestWebEngineScriptPage *page = new TestWebEngineScriptPage(this);
mTestWebEngine->setPage(page);
vboxLayout->addWidget(mTestWebEngine);
mTestWebEngine->load(QUrl(QStringLiteral("http://www.kde.org")));
mTestScriptWidget = new TestScriptWidget(this);
vboxLayout->addWidget(mTestScriptWidget);
connect(mTestScriptWidget, &TestScriptWidget::executeScript, this, &TestWebEngineScript::slotExecuteScript);
connect(page, &TestWebEngineScriptPage::showConsoleMessage, this, &TestWebEngineScript::slotShowConsoleMessage);
}
TestWebEngineScript::~TestWebEngineScript()
......@@ -79,6 +82,11 @@ TestWebEngineScript::~TestWebEngineScript()
}
void TestWebEngineScript::slotShowConsoleMessage(const QString &msg)
{
}
void TestWebEngineScript::handleScript(const QVariant &res)
{
qDebug() << " res" << res;
......
......@@ -40,8 +40,12 @@ class TestWebEngineScriptPage : public QWebEnginePage
Q_OBJECT
public:
explicit TestWebEngineScriptPage(QObject *parent = Q_NULLPTR);
protected:
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) Q_DECL_OVERRIDE;
Q_SIGNALS:
void showConsoleMessage(const QString &msg);
};
class TestWebEngineScriptView : public QWebEngineView
......@@ -60,8 +64,8 @@ public:
private Q_SLOTS:
void slotExecuteScript();
void handleScript(const QVariant &res);
void handleScript(const QVariant &res);
void slotShowConsoleMessage(const QString &msg);
private:
TestScriptWidget *mTestScriptWidget;
TestWebEngineScriptView *mTestWebEngine;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment