aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/widgets')
-rw-r--r--src/webengine/widgets/pagetoolsmenu.cpp31
-rw-r--r--src/webengine/widgets/pagetoolsmenu.h4
2 files changed, 32 insertions, 3 deletions
diff --git a/src/webengine/widgets/pagetoolsmenu.cpp b/src/webengine/widgets/pagetoolsmenu.cpp
index 9a85f69..34c9d65 100644
--- a/src/webengine/widgets/pagetoolsmenu.cpp
+++ b/src/webengine/widgets/pagetoolsmenu.cpp
@@ -8,8 +8,12 @@
#include "pagetoolsmenu.h"
#include "../webview.h"
+#include <QDialog>
+#include <QVBoxLayout>
+#include <QWebEnginePage>
#include <QWebEngineProfile>
#include <QWebEngineScriptCollection>
+#include <QWebEngineView>
PageToolsMenu::PageToolsMenu(WebView *parent)
: QMenu(parent)
@@ -24,14 +28,35 @@ void PageToolsMenu::createEntries()
{
clear();
- auto *scriptsMenu = new QMenu(tr("Injected scripts"), this);
+ auto *scriptsMenu = new QMenu(tr("Injected Scripts"), this);
for(const auto &script : parentView->page()->scripts().toList()) {
scriptsMenu->addAction(script.name())->setEnabled(false);
}
addMenu(scriptsMenu);
- auto *devToolsAction = addAction(tr("Dev tools page"));
+ auto *devToolsAction = addAction(tr("Developer Tools"));
connect(devToolsAction, &QAction::triggered, this, [this]() {
- parentView->popupPage(parentView->page()->devToolsPage());
+ createDevToolsDialog(parentView->page())->show();
});
}
+
+QDialog *PageToolsMenu::createDevToolsDialog(QWebEnginePage *page)
+{
+ Q_CHECK_PTR(page);
+
+ auto *popup = new QDialog(nullptr);
+ popup->setWindowTitle(tr("Developer Tools"));
+ popup->setAttribute(Qt::WA_DeleteOnClose, true);
+
+ auto *view = new QWebEngineView(popup);
+ auto *devPage = new QWebEnginePage(view);
+
+ view->setPage(devPage);
+ page->setDevToolsPage(devPage);
+
+ auto *l = new QVBoxLayout(popup);
+ l->setContentsMargins(0, 0, 0, 0);
+ l->addWidget(view);
+
+ return popup;
+}
diff --git a/src/webengine/widgets/pagetoolsmenu.h b/src/webengine/widgets/pagetoolsmenu.h
index 010bb43..f234d0e 100644
--- a/src/webengine/widgets/pagetoolsmenu.h
+++ b/src/webengine/widgets/pagetoolsmenu.h
@@ -12,6 +12,8 @@
#include <QMenu>
class WebView;
+class QDialog;
+class QWebEnginePage;
class PageToolsMenu : public QMenu
{
Q_OBJECT
@@ -22,6 +24,8 @@ public slots:
void createEntries();
private:
+ QDialog *createDevToolsDialog(QWebEnginePage *page);
+
WebView *parentView;
};