summaryrefslogtreecommitdiff
path: root/www-client/falkon/files/falkon-3.0.1-webinspector.patch
blob: 9cfea7e42dc985a5c58c92acf63ff859b7c2b934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From 48ca42d645b155069a57eaede3e560874ed07bc7 Mon Sep 17 00:00:00 2001
From: David Rosca <nowrep@gmail.com>
Date: Thu, 1 Mar 2018 15:14:15 +0100
Subject: WebInspector: Don't require remote debugging with QtWebEngine 5.11

---
 src/lib/webengine/webinspector.cpp | 11 ++++++++++-
 src/lib/webengine/webinspector.h   | 11 ++++-------
 2 files changed, 14 insertions(+), 8 deletions(-)

* asturm@gentoo.org: Make #ifdef obsolete by requiring Qt 5.11.0.

 diff -u b/src/lib/webengine/webinspector.cpp b/src/lib/webengine/webinspector.cpp
--- b/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 <QJsonArray>
 #include <QJsonObject>
@@ -60,27 +62,13 @@
     }
 }
 
-void WebInspector::setView(QWebEngineView *view)
+void WebInspector::setView(WebView *view)
 {
     m_view = view;
     Q_ASSERT(isEnabled());
 
-    int port = qEnvironmentVariableIntValue("QTWEBENGINE_REMOTE_DEBUGGING");
-    QUrl inspectorUrl = QUrl(QSL("http://localhost:%1").arg(port));
-    int index = s_views.indexOf(m_view);
-
-    QNetworkReply *reply = mApp->networkManager()->get(QNetworkRequest(inspectorUrl.resolved(QUrl("json/list"))));
-    connect(reply, &QNetworkReply::finished, this, [=]() {
-        QJsonArray clients = QJsonDocument::fromJson(reply->readAll()).array();
-        QUrl pageUrl;
-        if (clients.size() > index) {
-            QJsonObject object = clients.at(index).toObject();
-            pageUrl = inspectorUrl.resolved(QUrl(object.value(QSL("devtoolsFrontendUrl")).toString()));
-        }
-        load(pageUrl);
-        pushView(this);
-        show();
-    });
+    page()->setInspectedPage(m_view->page());
+    connect(m_view, &WebView::pageChanged, this, &WebInspector::deleteLater);
 }
 
 void WebInspector::inspectElement()
@@ -90,9 +78,6 @@
 
 bool WebInspector::isEnabled()
 {
-    if (!qEnvironmentVariableIsSet("QTWEBENGINE_REMOTE_DEBUGGING")) {
-        return false;
-    }
     if (!mApp->webSettings()->testAttribute(QWebEngineSettings::JavascriptEnabled)) {
         return false;
     }
--- 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 <http://www.gnu.org/licenses/>.
 * ============================================================ */
-#ifndef WEBINSPECTORDOCKWIDGET_H
-#define WEBINSPECTORDOCKWIDGET_H
+#pragma once
 
 #include <QWebEngineView>
 
 #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