TaskManagerWindow.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "TaskManagerWindow.h"
  7. #include <LibWebView/Application.h>
  8. #include <QVBoxLayout>
  9. namespace Ladybird {
  10. TaskManagerWindow::TaskManagerWindow(QWidget* parent)
  11. : QWidget(parent, Qt::WindowFlags(Qt::WindowType::Window))
  12. , m_web_view(new WebContentView(this))
  13. {
  14. setLayout(new QVBoxLayout);
  15. layout()->addWidget(m_web_view);
  16. setWindowTitle("Task Manager");
  17. resize(600, 400);
  18. m_update_timer.setInterval(1000);
  19. QObject::connect(&m_update_timer, &QTimer::timeout, [this] {
  20. this->update_statistics();
  21. });
  22. update_statistics();
  23. }
  24. void TaskManagerWindow::showEvent(QShowEvent*)
  25. {
  26. m_update_timer.start();
  27. }
  28. void TaskManagerWindow::hideEvent(QHideEvent*)
  29. {
  30. m_update_timer.stop();
  31. }
  32. void TaskManagerWindow::update_statistics()
  33. {
  34. WebView::Application::the().update_process_statistics();
  35. m_web_view->load_html(WebView::Application::the().generate_process_statistics_html());
  36. }
  37. }