mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
SystemMonitor: Add a status bar to the main window
To get us started, this shows the number of processes and threads in the last captured state.
This commit is contained in:
parent
1e912fb5a1
commit
0f7443f010
Notes:
sideshowbarker
2024-07-18 20:47:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0f7443f0109
3 changed files with 15 additions and 3 deletions
|
@ -429,6 +429,9 @@ void ProcessModel::update()
|
||||||
if (on_cpu_info_change)
|
if (on_cpu_info_change)
|
||||||
on_cpu_info_change(m_cpus);
|
on_cpu_info_change(m_cpus);
|
||||||
|
|
||||||
|
if (on_state_update)
|
||||||
|
on_state_update(all_processes->size(), m_threads.size());
|
||||||
|
|
||||||
// FIXME: This is a rather hackish way of invalidating indexes.
|
// FIXME: This is a rather hackish way of invalidating indexes.
|
||||||
// It would be good if GUI::Model had a way to orchestrate removal/insertion while preserving indexes.
|
// It would be good if GUI::Model had a way to orchestrate removal/insertion while preserving indexes.
|
||||||
did_update(previous_tid_count == m_tids.size() ? GUI::Model::UpdateFlag::DontInvalidateIndexes : GUI::Model::UpdateFlag::InvalidateAllIndexes);
|
did_update(previous_tid_count == m_tids.size() ? GUI::Model::UpdateFlag::DontInvalidateIndexes : GUI::Model::UpdateFlag::InvalidateAllIndexes);
|
||||||
|
|
|
@ -94,6 +94,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Function<void(const NonnullOwnPtrVector<CpuInfo>&)> on_cpu_info_change;
|
Function<void(const NonnullOwnPtrVector<CpuInfo>&)> on_cpu_info_change;
|
||||||
|
Function<void(int process_count, int thread_count)> on_state_update;
|
||||||
|
|
||||||
const NonnullOwnPtrVector<CpuInfo>& cpus() const { return m_cpus; }
|
const NonnullOwnPtrVector<CpuInfo>& cpus() const { return m_cpus; }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -51,6 +51,7 @@
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
#include <LibGUI/SortingProxyModel.h>
|
#include <LibGUI/SortingProxyModel.h>
|
||||||
#include <LibGUI/Splitter.h>
|
#include <LibGUI/Splitter.h>
|
||||||
|
#include <LibGUI/StatusBar.h>
|
||||||
#include <LibGUI/TabWidget.h>
|
#include <LibGUI/TabWidget.h>
|
||||||
#include <LibGUI/TableView.h>
|
#include <LibGUI/TableView.h>
|
||||||
#include <LibGUI/ToolBar.h>
|
#include <LibGUI/ToolBar.h>
|
||||||
|
@ -174,10 +175,17 @@ int main(int argc, char** argv)
|
||||||
auto& keeper = window->set_main_widget<GUI::Widget>();
|
auto& keeper = window->set_main_widget<GUI::Widget>();
|
||||||
keeper.set_layout<GUI::VerticalBoxLayout>();
|
keeper.set_layout<GUI::VerticalBoxLayout>();
|
||||||
keeper.set_fill_with_background_color(true);
|
keeper.set_fill_with_background_color(true);
|
||||||
keeper.layout()->set_margins({ 2, 2, 2, 2 });
|
keeper.layout()->set_margins({ 2, 2, 2, 0 });
|
||||||
|
|
||||||
auto& tabwidget = keeper.add<GUI::TabWidget>();
|
auto& tabwidget = keeper.add<GUI::TabWidget>();
|
||||||
|
|
||||||
|
auto& statusbar = keeper.add<GUI::StatusBar>(2);
|
||||||
|
auto process_model = ProcessModel::create();
|
||||||
|
process_model->on_state_update = [&](int process_count, int thread_count) {
|
||||||
|
statusbar.set_text(0, String::formatted("Processes: {}", process_count));
|
||||||
|
statusbar.set_text(1, String::formatted("Threads: {}", thread_count));
|
||||||
|
};
|
||||||
|
|
||||||
auto process_container_splitter = GUI::VerticalSplitter::construct();
|
auto process_container_splitter = GUI::VerticalSplitter::construct();
|
||||||
tabwidget.add_widget("Processes", process_container_splitter);
|
tabwidget.add_widget("Processes", process_container_splitter);
|
||||||
process_container_splitter->layout()->set_margins({ 4, 4, 4, 4 });
|
process_container_splitter->layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
@ -210,7 +218,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto& process_table_view = process_table_container.add<GUI::TableView>();
|
auto& process_table_view = process_table_container.add<GUI::TableView>();
|
||||||
process_table_view.set_column_headers_visible(true);
|
process_table_view.set_column_headers_visible(true);
|
||||||
process_table_view.set_model(GUI::SortingProxyModel::create(ProcessModel::create()));
|
process_table_view.set_model(GUI::SortingProxyModel::create(process_model));
|
||||||
process_table_view.set_key_column_and_sort_order(ProcessModel::Column::CPU, GUI::SortOrder::Descending);
|
process_table_view.set_key_column_and_sort_order(ProcessModel::Column::CPU, GUI::SortOrder::Descending);
|
||||||
process_table_view.model()->update();
|
process_table_view.model()->update();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue