ladybird/Ladybird/Qt/InspectorWidget.cpp
Timothy Flynn 07e9a8f79b Ladybird+LibWebView: Move options used to launch WebContent to a struct
It is currently a bit messy to pass these options along from main() to
where WebContent is actually launched. If a new flag were to be added,
there are a couple dozen files that need to be updated to pass that flag
along. With this change, the flag can just be added to the struct, set
in main(), and handled in launch_web_content_process().
2023-12-01 20:07:27 -05:00

60 lines
1.3 KiB
C++

/*
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "InspectorWidget.h"
#include <LibWebView/InspectorClient.h>
#include <QCloseEvent>
#include <QVBoxLayout>
namespace Ladybird {
extern bool is_using_dark_system_theme(QWidget&);
InspectorWidget::InspectorWidget(WebContentView& content_view)
{
m_inspector_view = make<WebContentView>(WebContentOptions {}, StringView {});
if (is_using_dark_system_theme(*this))
m_inspector_view->update_palette(WebContentView::PaletteMode::Dark);
m_inspector_client = make<WebView::InspectorClient>(content_view, *m_inspector_view);
setLayout(new QVBoxLayout);
layout()->addWidget(m_inspector_view.ptr());
setWindowTitle("Inspector");
resize(875, 825);
}
InspectorWidget::~InspectorWidget() = default;
void InspectorWidget::inspect()
{
m_inspector_client->inspect();
}
void InspectorWidget::reset()
{
m_inspector_client->reset();
}
void InspectorWidget::select_hovered_node()
{
m_inspector_client->select_hovered_node();
}
void InspectorWidget::select_default_node()
{
m_inspector_client->select_default_node();
}
void InspectorWidget::closeEvent(QCloseEvent* event)
{
event->accept();
m_inspector_client->clear_selection();
}
}