diff --git a/src/lib/webengine/webinspector.cpp b/src/lib/webengine/webinspector.cpp index bfaaef08d..1ef70e4d3 100644 --- a/src/lib/webengine/webinspector.cpp +++ b/src/lib/webengine/webinspector.cpp @@ -19,6 +19,8 @@ #include "mainapplication.h" #include "networkmanager.h" #include "settings.h" +#include "webview.h" +#include "webpage.h" #include #include @@ -60,11 +62,15 @@ WebInspector::~WebInspector() } } -void WebInspector::setView(QWebEngineView *view) +void WebInspector::setView(WebView *view) { m_view = view; Q_ASSERT(isEnabled()); +#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + page()->setInspectedPage(m_view->page()); + connect(m_view, &WebView::pageChanged, this, &WebInspector::deleteLater); +#else int port = qEnvironmentVariableIntValue("QTWEBENGINE_REMOTE_DEBUGGING"); QUrl inspectorUrl = QUrl(QSL("http://localhost:%1").arg(port)); int index = s_views.indexOf(m_view); @@ -81,6 +87,7 @@ void WebInspector::setView(QWebEngineView *view) pushView(this); show(); }); +#endif } void WebInspector::inspectElement() @@ -90,9 +97,11 @@ void WebInspector::inspectElement() bool WebInspector::isEnabled() { +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) if (!qEnvironmentVariableIsSet("QTWEBENGINE_REMOTE_DEBUGGING")) { return false; } +#endif if (!mApp->webSettings()->testAttribute(QWebEngineSettings::JavascriptEnabled)) { return false; } diff --git a/src/lib/webengine/webinspector.h b/src/lib/webengine/webinspector.h index fdc5836c0..40c5ec477 100644 --- a/src/lib/webengine/webinspector.h +++ b/src/lib/webengine/webinspector.h @@ -15,14 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ -#ifndef WEBINSPECTORDOCKWIDGET_H -#define WEBINSPECTORDOCKWIDGET_H +#pragma once #include #include "qzcommon.h" -class ToolButton; +class WebView; class FALKON_EXPORT WebInspector : public QWebEngineView { @@ -32,7 +31,7 @@ public: explicit WebInspector(QWidget *parent = Q_NULLPTR); ~WebInspector(); - void setView(QWebEngineView *view); + void setView(WebView *view); void inspectElement(); static bool isEnabled(); @@ -53,7 +52,5 @@ private: int m_height; QSize m_windowSize; bool m_inspectElement = false; - QWebEngineView *m_view; + WebView *m_view; }; - -#endif // WEBINSPECTORDOCKWIDGET_H