mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
UI/Qt: Replace the Task Manager window with about:processes
This commit is contained in:
parent
67a1dd72db
commit
45d8cd5c9f
Notes:
github-actions[bot]
2025-03-19 14:04:21 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/45d8cd5c9fe Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3967 Reviewed-by: https://github.com/shannonbooth
7 changed files with 3 additions and 114 deletions
|
@ -9,7 +9,6 @@
|
|||
#include <UI/Qt/Application.h>
|
||||
#include <UI/Qt/Settings.h>
|
||||
#include <UI/Qt/StringUtils.h>
|
||||
#include <UI/Qt/TaskManagerWindow.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFileOpenEvent>
|
||||
|
@ -26,10 +25,7 @@ void Application::create_platform_options(WebView::BrowserOptions&, WebView::Web
|
|||
web_content_options.config_path = Settings::the()->directory();
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
close_task_manager_window();
|
||||
}
|
||||
Application::~Application() = default;
|
||||
|
||||
bool Application::event(QEvent* event)
|
||||
{
|
||||
|
@ -52,25 +48,6 @@ bool Application::event(QEvent* event)
|
|||
return QApplication::event(event);
|
||||
}
|
||||
|
||||
void Application::show_task_manager_window()
|
||||
{
|
||||
if (!m_task_manager_window) {
|
||||
m_task_manager_window = new TaskManagerWindow(nullptr);
|
||||
}
|
||||
m_task_manager_window->show();
|
||||
m_task_manager_window->activateWindow();
|
||||
m_task_manager_window->raise();
|
||||
}
|
||||
|
||||
void Application::close_task_manager_window()
|
||||
{
|
||||
if (m_task_manager_window) {
|
||||
m_task_manager_window->close();
|
||||
delete m_task_manager_window;
|
||||
m_task_manager_window = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, BrowserWindow::IsPopupWindow is_popup_window, Tab* parent_tab, Optional<u64> page_index)
|
||||
{
|
||||
auto* window = new BrowserWindow(initial_urls, is_popup_window, parent_tab, move(page_index));
|
||||
|
|
|
@ -30,9 +30,6 @@ public:
|
|||
|
||||
BrowserWindow& new_window(Vector<URL::URL> const& initial_urls, BrowserWindow::IsPopupWindow is_popup_window = BrowserWindow::IsPopupWindow::No, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
|
||||
|
||||
void show_task_manager_window();
|
||||
void close_task_manager_window();
|
||||
|
||||
BrowserWindow& active_window() { return *m_active_window; }
|
||||
void set_active_window(BrowserWindow& w) { m_active_window = &w; }
|
||||
|
||||
|
@ -41,7 +38,6 @@ private:
|
|||
|
||||
virtual Optional<ByteString> ask_user_for_download_folder() const override;
|
||||
|
||||
TaskManagerWindow* m_task_manager_window { nullptr };
|
||||
BrowserWindow* m_active_window { nullptr };
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <UI/Qt/SettingsDialog.h>
|
||||
#include <UI/Qt/StringUtils.h>
|
||||
#include <UI/Qt/TabBar.h>
|
||||
#include <UI/Qt/TaskManagerWindow.h>
|
||||
#include <UI/Qt/WebContentView.h>
|
||||
|
||||
#include <QAction>
|
||||
|
@ -383,8 +382,8 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, IsPopupWindow
|
|||
task_manager_action->setIcon(load_icon_from_uri("resource://icons/16x16/app-system-monitor.png"sv));
|
||||
task_manager_action->setShortcuts({ QKeySequence("Ctrl+Shift+M") });
|
||||
inspect_menu->addAction(task_manager_action);
|
||||
QObject::connect(task_manager_action, &QAction::triggered, this, [&] {
|
||||
static_cast<Ladybird::Application*>(QApplication::instance())->show_task_manager_window();
|
||||
QObject::connect(task_manager_action, &QAction::triggered, this, [this]() {
|
||||
new_tab_from_url(URL::URL::about("processes"_string), Web::HTML::ActivateTab::Yes);
|
||||
});
|
||||
|
||||
auto* debug_menu = m_hamburger_menu->addMenu("&Debug");
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace Ladybird {
|
|||
|
||||
class SettingsDialog;
|
||||
class WebContentView;
|
||||
class TaskManagerWindow;
|
||||
|
||||
class BrowserWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -10,7 +10,6 @@ target_sources(ladybird PRIVATE
|
|||
SettingsDialog.cpp
|
||||
Tab.cpp
|
||||
TabBar.cpp
|
||||
TaskManagerWindow.cpp
|
||||
TVGIconEngine.cpp
|
||||
StringUtils.cpp
|
||||
WebContentView.cpp
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWebView/Application.h>
|
||||
#include <UI/Qt/TaskManagerWindow.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());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <UI/Qt/WebContentView.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ladybird {
|
||||
|
||||
class TaskManagerWindow : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TaskManagerWindow(QWidget* parent);
|
||||
|
||||
private:
|
||||
virtual void showEvent(QShowEvent*) override;
|
||||
virtual void hideEvent(QHideEvent*) override;
|
||||
|
||||
void update_statistics();
|
||||
|
||||
WebContentView* m_web_view { nullptr };
|
||||
QTimer m_update_timer;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue