mirror of
https://github.com/RGBCube/serenity
synced 2025-06-15 18:42:09 +00:00
SystemMonitor: Split multi-core CPU usage graphs into multiple rows
This looks much nicer than the current cramped single-row solution.
This commit is contained in:
parent
7974fee800
commit
d55c130df5
1 changed files with 28 additions and 19 deletions
|
@ -668,26 +668,35 @@ NonnullRefPtr<GUI::Widget> build_performance_tab()
|
||||||
graphs_container->layout()->set_margins(4);
|
graphs_container->layout()->set_margins(4);
|
||||||
|
|
||||||
auto& cpu_graph_group_box = graphs_container->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.set_layout<GUI::VerticalBoxLayout>();
|
||||||
cpu_graph_group_box.layout()->set_margins(6);
|
|
||||||
cpu_graph_group_box.set_fixed_height(120);
|
static constexpr size_t cpu_graphs_per_row = 4;
|
||||||
|
auto cpu_graph_rows = ceil_div(ProcessModel::the().cpus().size(), cpu_graphs_per_row);
|
||||||
|
cpu_graph_group_box.set_fixed_height(120u * cpu_graph_rows);
|
||||||
|
|
||||||
Vector<GraphWidget&> cpu_graphs;
|
Vector<GraphWidget&> cpu_graphs;
|
||||||
for (size_t i = 0; i < ProcessModel::the().cpus().size(); i++) {
|
for (auto row = 0u; row < cpu_graph_rows; ++row) {
|
||||||
auto& cpu_graph = cpu_graph_group_box.add<GraphWidget>();
|
auto& cpu_graph_row = cpu_graph_group_box.add<GUI::Widget>();
|
||||||
cpu_graph.set_max(100);
|
cpu_graph_row.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
cpu_graph.set_value_format(0, {
|
cpu_graph_row.layout()->set_margins(6);
|
||||||
.graph_color_role = ColorRole::SyntaxPreprocessorStatement,
|
cpu_graph_row.set_fixed_height(108);
|
||||||
.text_formatter = [](int value) {
|
for (auto i = 0u; i < cpu_graphs_per_row; ++i) {
|
||||||
return String::formatted("Total: {}%", value);
|
auto& cpu_graph = cpu_graph_row.add<GraphWidget>();
|
||||||
},
|
cpu_graph.set_max(100);
|
||||||
});
|
cpu_graph.set_value_format(0, {
|
||||||
cpu_graph.set_value_format(1, {
|
.graph_color_role = ColorRole::SyntaxPreprocessorStatement,
|
||||||
.graph_color_role = ColorRole::SyntaxPreprocessorValue,
|
.text_formatter = [](int value) {
|
||||||
.text_formatter = [](int value) {
|
return String::formatted("Total: {}%", value);
|
||||||
return String::formatted("Kernel: {}%", value);
|
},
|
||||||
},
|
});
|
||||||
});
|
cpu_graph.set_value_format(1, {
|
||||||
cpu_graphs.append(cpu_graph);
|
.graph_color_role = ColorRole::SyntaxPreprocessorValue,
|
||||||
|
.text_formatter = [](int value) {
|
||||||
|
return String::formatted("Kernel: {}%", value);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
cpu_graphs.append(cpu_graph);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ProcessModel::the().on_cpu_info_change = [cpu_graphs](const NonnullOwnPtrVector<ProcessModel::CpuInfo>& cpus) {
|
ProcessModel::the().on_cpu_info_change = [cpu_graphs](const NonnullOwnPtrVector<ProcessModel::CpuInfo>& cpus) {
|
||||||
float sum_cpu = 0;
|
float sum_cpu = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue