@@ -154,31 +156,24 @@ Main::Main(QWidget *parent) :
m_server->setIdentities(keysAsVector(owned()));
m_server->StartListening();
- connect(ui->webView, &QWebView::loadStarted, [this]()
+ connect(ui->webView, &QWebEngineView::loadFinished, [this]()
{
- QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
- QWebFrame* f = ui->webView->page()->mainFrame();
- f->disconnect(SIGNAL(javaScriptWindowObjectCleared()));
-
- connect(f, &QWebFrame::javaScriptWindowObjectCleared, [f, this]()
- {
- f->disconnect();
- f->addToJavaScriptWindowObject("env", this, QWebFrame::QtOwnership);
- f->evaluateJavaScript(contentsOfQResource(":/js/bignumber.min.js"));
- f->evaluateJavaScript(contentsOfQResource(":/js/webthree.js"));
- f->evaluateJavaScript(contentsOfQResource(":/js/setup.js"));
- });
+// f->disconnect();
+// f->addToJavaScriptWindowObject("env", this, QWebFrame::QtOwnership);
+ auto f = ui->webView->page();
+ f->runJavaScript(contentsOfQResource(":/js/bignumber.min.js"));
+ f->runJavaScript(contentsOfQResource(":/js/webthree.js"));
+ f->runJavaScript(contentsOfQResource(":/js/setup.js"));
});
- connect(ui->webView, &QWebView::loadFinished, [=]()
- {
- });
-
- connect(ui->webView, &QWebView::titleChanged, [=]()
+ connect(ui->webView, &QWebEngineView::titleChanged, [=]()
{
ui->tabWidget->setTabText(0, ui->webView->title());
});
+ ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true);
+// QWebEngineInspector* inspector = new QWebEngineInspector();
+// inspector->setPage(page);
readSettings();
installWatches();
startTimer(100);
@@ -361,7 +356,7 @@ QString Main::contents(QString _s)
void Main::load(QString _s)
{
QString contents = QString::fromStdString(dev::asString(dev::contents(_s.toStdString())));
- ui->webView->page()->currentFrame()->evaluateJavaScript(contents);
+ ui->webView->page()->runJavaScript(contents);
/*
QFile fin(_s);
if (!fin.open(QFile::ReadOnly))
@@ -420,35 +415,35 @@ void Main::on_jsInput_returnPressed()
ui->jsInput->setText("");
}
-QVariant Main::evalRaw(QString const& _js)
-{
- return ui->webView->page()->currentFrame()->evaluateJavaScript(_js);
-}
-
void Main::eval(QString const& _js)
{
if (_js.trimmed().isEmpty())
return;
- QVariant ev = ui->webView->page()->currentFrame()->evaluateJavaScript((_js.startsWith("{") || _js.startsWith("if ") || _js.startsWith("if(")) ? _js : ("___RET=(" + _js + ")"));
- QVariant jsonEv = ui->webView->page()->currentFrame()->evaluateJavaScript("JSON.stringify(___RET)");
- QString s;
- if (ev.isNull())
- s = "null";
- else if (ev.type() == QVariant::String)
- s = "\"" + ev.toString().toHtmlEscaped() + "\"";
- else if (ev.type() == QVariant::Int || ev.type() == QVariant::Double)
- s = "" + ev.toString().toHtmlEscaped() + "";
- else if (jsonEv.type() == QVariant::String)
- s = "" + jsonEv.toString().toHtmlEscaped() + "";
- else
- s = "unknown type";
- m_consoleHistory.push_back(qMakePair(_js, s));
- s = "" Div(Mono "position: absolute; bottom: 0; border: 0px; margin: 0px; width: 100%");
- for (auto const& i: m_consoleHistory)
- s += ">" + i.first.toHtmlEscaped() + "
"
- " " + i.second + "
";
- s += "";
- ui->jsConsole->setHtml(s);
+ auto f = [=](QVariant ev) {
+ auto f2 = [=](QVariant jsonEv) {
+ QString s;
+ if (ev.isNull())
+ s = "null";
+ else if (ev.type() == QVariant::String)
+ s = "\"" + ev.toString().toHtmlEscaped() + "\"";
+ else if (ev.type() == QVariant::Int || ev.type() == QVariant::Double)
+ s = "" + ev.toString().toHtmlEscaped() + "";
+ else if (jsonEv.type() == QVariant::String)
+ s = "" + jsonEv.toString().toHtmlEscaped() + "";
+ else
+ s = "unknown type";
+ m_consoleHistory.push_back(qMakePair(_js, s));
+ s = "" Div(Mono "position: absolute; bottom: 0; border: 0px; margin: 0px; width: 100%");
+ for (auto const& i: m_consoleHistory)
+ s += ">" + i.first.toHtmlEscaped() + "
"
+ " " + i.second + "
";
+ s += "";
+ ui->jsConsole->setHtml(s);
+ };
+ ui->webView->page()->runJavaScript("JSON.stringify(___RET)", f2);
+ };
+ auto c = (_js.startsWith("{") || _js.startsWith("if ") || _js.startsWith("if(")) ? _js : ("___RET=(" + _js + ")");
+ ui->webView->page()->runJavaScript(c, f);
}
static Public stringToPublic(QString const& _a)
diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h
index 6c4a97301..5cb7aa964 100644
--- a/alethzero/MainWin.h
+++ b/alethzero/MainWin.h
@@ -74,8 +74,6 @@ public:
NatSpecFace* natSpec() { return &m_natSpecDB; }
- QVariant evalRaw(QString const& _js);
-
QString pretty(dev::Address _a) const override;
QString prettyU256(dev::u256 _n) const override;
QString render(dev::Address _a) const override;