2022-12-18 00:50:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2022-12-18 21:12:14 +00:00
|
|
|
#include "InspectorWidget.h"
|
2023-11-24 01:04:54 +00:00
|
|
|
#include <LibWebView/InspectorClient.h>
|
2022-12-18 00:50:53 +00:00
|
|
|
#include <QCloseEvent>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
namespace Ladybird {
|
|
|
|
|
2023-11-24 01:04:54 +00:00
|
|
|
extern bool is_using_dark_system_theme(QWidget&);
|
|
|
|
|
|
|
|
InspectorWidget::InspectorWidget(WebContentView& content_view)
|
2022-12-18 00:50:53 +00:00
|
|
|
{
|
2023-12-04 14:39:22 +00:00
|
|
|
m_inspector_view = new WebContentView({}, {});
|
2023-02-21 19:49:00 +00:00
|
|
|
|
2023-11-24 01:04:54 +00:00
|
|
|
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);
|
2023-12-04 14:39:22 +00:00
|
|
|
layout()->addWidget(m_inspector_view);
|
2023-11-24 01:04:54 +00:00
|
|
|
|
|
|
|
setWindowTitle("Inspector");
|
|
|
|
resize(875, 825);
|
2022-12-18 21:12:14 +00:00
|
|
|
}
|
|
|
|
|
2023-11-24 01:04:54 +00:00
|
|
|
InspectorWidget::~InspectorWidget() = default;
|
|
|
|
|
|
|
|
void InspectorWidget::inspect()
|
2022-12-18 21:12:14 +00:00
|
|
|
{
|
2023-11-24 01:04:54 +00:00
|
|
|
m_inspector_client->inspect();
|
2022-12-18 00:50:53 +00:00
|
|
|
}
|
|
|
|
|
2023-11-24 01:04:54 +00:00
|
|
|
void InspectorWidget::reset()
|
2023-02-21 19:49:00 +00:00
|
|
|
{
|
2023-11-24 01:04:54 +00:00
|
|
|
m_inspector_client->reset();
|
2023-02-21 19:49:00 +00:00
|
|
|
}
|
|
|
|
|
2023-11-24 01:04:54 +00:00
|
|
|
void InspectorWidget::select_hovered_node()
|
2022-12-18 00:50:53 +00:00
|
|
|
{
|
2023-11-24 01:04:54 +00:00
|
|
|
m_inspector_client->select_hovered_node();
|
|
|
|
}
|
2023-11-04 15:55:09 +00:00
|
|
|
|
2023-11-24 01:04:54 +00:00
|
|
|
void InspectorWidget::select_default_node()
|
|
|
|
{
|
|
|
|
m_inspector_client->select_default_node();
|
2022-12-18 00:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InspectorWidget::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
|
|
|
event->accept();
|
2023-11-24 01:04:54 +00:00
|
|
|
m_inspector_client->clear_selection();
|
2022-12-18 00:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|