diff options
author | Andreas Kling <kling@serenityos.org> | 2022-07-09 17:46:11 +0200 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-25 07:58:58 -0700 |
commit | 74c71804c7aa4619bc84be3d90ac661dc9a3ede8 (patch) | |
tree | 8b987b1a463bee6a82a93bea7a6eff858fae7f59 /Ladybird/BrowserWindow.cpp | |
parent | 1400a160bcf7195b3fd53dfbfd6dbe6b60737b84 (diff) | |
download | serenity-74c71804c7aa4619bc84be3d90ac661dc9a3ede8.zip |
Ladybird: Add "View Source" menu action (Ctrl+U)
Diffstat (limited to 'Ladybird/BrowserWindow.cpp')
-rw-r--r-- | Ladybird/BrowserWindow.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Ladybird/BrowserWindow.cpp b/Ladybird/BrowserWindow.cpp index a14624f282..b1f0d68782 100644 --- a/Ladybird/BrowserWindow.cpp +++ b/Ladybird/BrowserWindow.cpp @@ -9,6 +9,7 @@ #include "WebView.h" #include <LibCore/EventLoop.h> #include <QAction> +#include <QPlainTextEdit> #include <QStatusBar> extern String s_serenity_resource_root; @@ -31,6 +32,24 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop) quit_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); menu->addAction(quit_action); + auto* inspect_menu = menuBar()->addMenu("&Inspect"); + + auto* view_source_action = new QAction("View &Source"); + view_source_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-html.png").arg(s_serenity_resource_root.characters()))); + view_source_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U)); + inspect_menu->addAction(view_source_action); + QObject::connect(view_source_action, &QAction::triggered, this, [this] { + if (m_current_tab) { + auto source = m_current_tab->view().source(); + + auto* text_edit = new QPlainTextEdit; + text_edit->setFont(QFontDatabase::systemFont(QFontDatabase::SystemFont::FixedFont)); + text_edit->resize(800, 600); + text_edit->setPlainText(source.characters()); + text_edit->show(); + } + }); + auto* debug_menu = menuBar()->addMenu("&Debug"); auto* dump_dom_tree_action = new QAction("Dump DOM Tree"); |