SystemMonitor: Grow CPU and memory charts to window size

This commit is contained in:
Bastiaan van der Plaat 2024-12-29 21:41:47 +01:00 committed by Nico Weber
parent 90a67e24a6
commit 3899092ea3
2 changed files with 7 additions and 5 deletions

View file

@ -43,12 +43,14 @@
@GUI::GroupBox { @GUI::GroupBox {
title: "CPU usage" title: "CPU usage"
name: "cpu_graph" name: "cpu_graph"
preferred_height: "opportunistic_grow"
layout: @GUI::VerticalBoxLayout {} layout: @GUI::VerticalBoxLayout {}
} }
@GUI::GroupBox { @GUI::GroupBox {
title: "Memory usage" title: "Memory usage"
fixed_height: 120 preferred_height: "opportunistic_grow"
min_height: 120
layout: @GUI::VerticalBoxLayout { layout: @GUI::VerticalBoxLayout {
margins: [6] margins: [6]
} }

View file

@ -597,15 +597,15 @@ ErrorOr<void> build_performance_tab(GUI::Widget& graphs_container)
{ {
auto& cpu_graph_group_box = *graphs_container.find_descendant_of_type_named<GUI::GroupBox>("cpu_graph"); auto& cpu_graph_group_box = *graphs_container.find_descendant_of_type_named<GUI::GroupBox>("cpu_graph");
size_t cpu_graphs_per_row = min(4, ProcessModel::the().cpus().size()); size_t cpus_count = ProcessModel::the().cpus().size();
auto cpu_graph_rows = ceil_div(ProcessModel::the().cpus().size(), cpu_graphs_per_row); size_t cpu_graphs_per_row = min(cpus_count, 4);
cpu_graph_group_box.set_fixed_height(120u * cpu_graph_rows); auto cpu_graph_rows = ceil_div(cpus_count, cpu_graphs_per_row);
Vector<SystemMonitor::GraphWidget&> cpu_graphs; Vector<SystemMonitor::GraphWidget&> cpu_graphs;
for (auto row = 0u; row < cpu_graph_rows; ++row) { for (auto row = 0u; row < cpu_graph_rows; ++row) {
auto& cpu_graph_row = cpu_graph_group_box.add<GUI::Widget>(); auto& cpu_graph_row = cpu_graph_group_box.add<GUI::Widget>();
cpu_graph_row.set_layout<GUI::HorizontalBoxLayout>(6); cpu_graph_row.set_layout<GUI::HorizontalBoxLayout>(6);
cpu_graph_row.set_fixed_height(108); cpu_graph_row.set_min_height(108);
for (auto i = 0u; i < cpu_graphs_per_row; ++i) { for (auto i = 0u; i < cpu_graphs_per_row; ++i) {
auto& cpu_graph = cpu_graph_row.add<SystemMonitor::GraphWidget>(); auto& cpu_graph = cpu_graph_row.add<SystemMonitor::GraphWidget>();
cpu_graph.set_max(100); cpu_graph.set_max(100);