ladybird/Ladybird/Qt/TaskManagerWindow.cpp
Timothy Flynn 5f8d852dae LibWebView+UI: Migrate Ladybird's command line flags to LibWebView
Currently, if we want to add a new e.g. WebContent command line option,
we have to add it to all of Qt, AppKit, and headless-browser. (Or worse,
we only add it to one of these, and we have feature disparity).

To prevent this, this moves command line flags to WebView::Application.
The flags are assigned to ChromeOptions and WebContentOptions structs.
Each chrome can still add its platform-specific options; for example,
the Qt chrome has a flag to enable Qt networking.

There should be no behavior change here, other than that AppKit will now
support command line flags that were previously only supported by Qt.
2024-08-01 11:38:42 +02:00

48 lines
1 KiB
C++

/*
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "TaskManagerWindow.h"
#include <LibWebView/Application.h>
#include <QVBoxLayout>
namespace Ladybird {
TaskManagerWindow::TaskManagerWindow(QWidget* parent)
: QWidget(parent, Qt::WindowFlags(Qt::WindowType::Window))
, m_web_view(new WebContentView(this))
{
setLayout(new QVBoxLayout);
layout()->addWidget(m_web_view);
setWindowTitle("Task Manager");
resize(600, 400);
m_update_timer.setInterval(1000);
QObject::connect(&m_update_timer, &QTimer::timeout, [this] {
this->update_statistics();
});
update_statistics();
}
void TaskManagerWindow::showEvent(QShowEvent*)
{
m_update_timer.start();
}
void TaskManagerWindow::hideEvent(QHideEvent*)
{
m_update_timer.stop();
}
void TaskManagerWindow::update_statistics()
{
WebView::Application::the().update_process_statistics();
m_web_view->load_html(WebView::Application::the().generate_process_statistics_html());
}
}