1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Ladybird: Use a web view for the Qt chrome's View Source action

Unlike the existing popup window, this will provide syntax highlighting.
This commit is contained in:
Timothy Flynn 2023-08-28 16:36:51 -04:00 committed by Tim Flynn
parent a718a1f3a6
commit a6bdf8c2a9

View file

@ -14,6 +14,7 @@
#include <Browser/History.h> #include <Browser/History.h>
#include <LibGfx/ImageFormats/BMPWriter.h> #include <LibGfx/ImageFormats/BMPWriter.h>
#include <LibGfx/Painter.h> #include <LibGfx/Painter.h>
#include <LibWebView/SourceHighlighter.h>
#include <QClipboard> #include <QClipboard>
#include <QCoreApplication> #include <QCoreApplication>
#include <QCursor> #include <QCursor>
@ -26,7 +27,6 @@
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QPainter> #include <QPainter>
#include <QPlainTextEdit>
#include <QPoint> #include <QPoint>
#include <QResizeEvent> #include <QResizeEvent>
@ -217,13 +217,8 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
QObject::connect(focus_location_editor_action, &QAction::triggered, this, &Tab::focus_location_editor); QObject::connect(focus_location_editor_action, &QAction::triggered, this, &Tab::focus_location_editor);
view().on_received_source = [this](auto const& url, auto const& source) { view().on_received_source = [this](auto const& url, auto const& source) {
auto* text_edit = new QPlainTextEdit(this); auto html = WebView::highlight_source(url, source);
text_edit->setWindowFlags(Qt::Window); m_window->new_tab(html, url, Web::HTML::ActivateTab::Yes);
text_edit->setFont(QFontDatabase::systemFont(QFontDatabase::SystemFont::FixedFont));
text_edit->resize(800, 600);
text_edit->setWindowTitle(qstring_from_ak_deprecated_string(url.to_deprecated_string()));
text_edit->setPlainText(qstring_from_ak_deprecated_string(source));
text_edit->show();
}; };
view().on_navigate_back = [this]() { view().on_navigate_back = [this]() {