diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-07-11 14:39:08 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-07-11 14:39:08 +0200 |
commit | 8aa707cfe56604f95c6d5c75e146b70a5272cc5d (patch) | |
tree | cada71476496ee0bc5f5b76103f4e5d55d3363cb /src/mainwindow | |
parent | Add custom WebView context menu (diff) | |
download | smolbote-8aa707cfe56604f95c6d5c75e146b70a5272cc5d.tar.xz |
Remove PageToolsMenu
Diffstat (limited to 'src/mainwindow')
-rw-r--r-- | src/mainwindow/mainwindow.cpp | 37 | ||||
-rw-r--r-- | src/mainwindow/mainwindow.ui | 6 |
2 files changed, 38 insertions, 5 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index ff8c911..6cf3f84 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -36,11 +36,37 @@ #include <QPrinterInfo> #include <QPrintDialog> #include "profilemanager.h" - +#include <QVBoxLayout> #ifdef PLASMA_BLUR #include <KWindowEffects> #endif +inline QDialog *createDevToolsDialog(QWebEnginePage *page) +{ + Q_CHECK_PTR(page); + + auto *popup = new QDialog(nullptr); + popup->setWindowTitle(QObject::tr("Developer Tools")); + popup->setAttribute(Qt::WA_DeleteOnClose, true); + popup->resize(800, 600); + + auto *view = new QWebEngineView(popup); + auto *devPage = new QWebEnginePage(view); + + view->setPage(devPage); + page->setDevToolsPage(devPage); + + QObject::connect(popup, &QDialog::destroyed, [page]() { + page->setDevToolsPage(nullptr); + }); + + auto *l = new QVBoxLayout(popup); + l->setContentsMargins(0, 0, 0, 0); + l->addWidget(view); + + return popup; +} + MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) @@ -148,6 +174,11 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa } }); + connect(ui->actionDeveloperTools, &QAction::triggered, this, [this]() { + if(currentView != nullptr) + createDevToolsDialog(currentView->page())->show(); + }); + pageLoadProfileMenu = ui->menuPage->addMenu(tr("Load Profile")); connect(pageLoadProfileMenu, &QMenu::aboutToShow, this, &MainWindow::updatePageLoadProfileMenu); } @@ -326,8 +357,6 @@ void MainWindow::setView(WebView *view) currentView = view; if(view) { - addressBar->setToolsMenu(view->toolsMenu()); - connect(view, &WebView::urlChanged, addressBar, &AddressBar::setUrl); addressBar->setUrl(view->url()); @@ -335,8 +364,6 @@ void MainWindow::setView(WebView *view) addressBar->setProgress(100); } else { - addressBar->setToolsMenu(nullptr); - addressBar->setUrl(QUrl()); addressBar->setProgress(100); } diff --git a/src/mainwindow/mainwindow.ui b/src/mainwindow/mainwindow.ui index 698e1c4..d670b66 100644 --- a/src/mainwindow/mainwindow.ui +++ b/src/mainwindow/mainwindow.ui @@ -65,6 +65,7 @@ <addaction name="actionPrintPage"/> <addaction name="actionPrintPageToPdf"/> <addaction name="separator"/> + <addaction name="actionDeveloperTools"/> </widget> <addaction name="menusmolbote"/> <addaction name="menuSession"/> @@ -143,6 +144,11 @@ <string>P&rint to PDF</string> </property> </action> + <action name="actionDeveloperTools"> + <property name="text"> + <string>Developer Tools</string> + </property> + </action> </widget> <resources/> <connections/> |