aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow')
-rw-r--r--src/mainwindow/mainwindow.cpp27
-rw-r--r--src/mainwindow/menubar.cpp52
2 files changed, 47 insertions, 32 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index 5358fb6..a5f1c90 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -35,37 +35,10 @@
#include <QStatusBar>
#include <QToolBar>
#include <QUrl>
-#include <QVBoxLayout>
#ifdef CONFIG_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)
, configuration(config.get())
diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp
index e74069e..ed0eb8f 100644
--- a/src/mainwindow/menubar.cpp
+++ b/src/mainwindow/menubar.cpp
@@ -28,6 +28,7 @@
#include <QPrinterInfo>
#include <QWidgetAction>
#include <functional>
+#include <QVBoxLayout>
inline void run_if(SubWindow *_subwindow, std::function<void(SubWindow*, int)> f)
{
@@ -35,6 +36,31 @@ inline void run_if(SubWindow *_subwindow, std::function<void(SubWindow*, int)> f
f(_subwindow, _subwindow->currentTabIndex());
}
+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);
+
+ auto *l = new QVBoxLayout(popup);
+ l->setContentsMargins(0, 0, 0, 0);
+ l->addWidget(view);
+
+ page->setDevToolsPage(devPage);
+ QObject::connect(popup, &QDialog::destroyed, [page]() {
+ page->setDevToolsPage(nullptr);
+ });
+
+ return popup;
+}
+
MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
: QMenuBar(parent)
{
@@ -112,9 +138,8 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
auto *actionAbout = smolbote->addAction(tr("About"), browser, &Browser::about);
config->setShortcut(actionAbout, "mainwindow.shortcuts.about");
- smolbote->addAction(tr("Help"));
-
- //smolbote->addAction(tr("Check for updates"));
+// smolbote->addAction(tr("Help"));
+// smolbote->addAction(tr("Check for updates"));
smolbote->addSeparator();
@@ -367,8 +392,25 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
});
page->addSeparator();
- page->addAction(tr("Developer Tools"));
- page->addAction(tr("View Source"));
+ page->addAction(tr("Developer Tools"), parent, [parent]() {
+ if(parent->currentView != nullptr) {
+ auto *dlg = createDevToolsDialog(parent->currentView->page());
+ dlg->show();
+ }
+ });
+ page->addAction(tr("View Source"), parent, [parent]() {
+ if(parent->currentView != nullptr) {
+ parent->currentView->triggerPageAction(QWebEnginePage::ViewSource);
+ }
+ });
+#ifdef QT_DEBUG
+ // doesn't seem to do anything?
+ page->addAction(tr("Inspect Element"), parent, [parent]() {
+ if(parent->currentView != nullptr) {
+ parent->currentView->triggerPageAction(QWebEnginePage::InspectElement);
+ }
+ });
+#endif
}
}