1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

SystemMonitor: Start capturing CPU/memory graphs on startup

It felt really weird that the graphs didn't start filling in before
you opened the graph tab for the first time.
This commit is contained in:
Andreas Kling 2021-04-04 20:49:37 +02:00
parent 0f7443f010
commit 5fcce5c7e2

View file

@ -577,15 +577,14 @@ NonnullRefPtr<GUI::Widget> build_devices_tab()
NonnullRefPtr<GUI::Widget> build_graphs_tab()
{
auto graphs_container = GUI::LazyWidget::construct();
auto graphs_container = GUI::Widget::construct();
graphs_container->on_first_show = [](GUI::LazyWidget& self) {
self.set_fill_with_background_color(true);
self.set_background_role(ColorRole::Button);
self.set_layout<GUI::VerticalBoxLayout>();
self.layout()->set_margins({ 4, 4, 4, 4 });
graphs_container->set_fill_with_background_color(true);
graphs_container->set_background_role(ColorRole::Button);
graphs_container->set_layout<GUI::VerticalBoxLayout>();
graphs_container->layout()->set_margins({ 4, 4, 4, 4 });
auto& cpu_graph_group_box = self.add<GUI::GroupBox>("CPU usage");
auto& cpu_graph_group_box = graphs_container->add<GUI::GroupBox>("CPU usage");
cpu_graph_group_box.set_layout<GUI::HorizontalBoxLayout>();
cpu_graph_group_box.layout()->set_margins({ 6, 16, 6, 6 });
cpu_graph_group_box.set_fixed_height(120);
@ -612,7 +611,7 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
cpu_graphs[i]->add_value({ (int)cpus[i].total_cpu_percent, (int)cpus[i].total_cpu_percent_kernel });
};
auto& memory_graph_group_box = self.add<GUI::GroupBox>("Memory usage");
auto& memory_graph_group_box = graphs_container->add<GUI::GroupBox>("Memory usage");
memory_graph_group_box.set_layout<GUI::VerticalBoxLayout>();
memory_graph_group_box.layout()->set_margins({ 6, 16, 6, 6 });
memory_graph_group_box.set_fixed_height(120);
@ -637,8 +636,7 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
},
});
self.add<MemoryStatsWidget>(memory_graph);
};
graphs_container->add<MemoryStatsWidget>(memory_graph);
return graphs_container;
}