1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:17:44 +00:00

Userland: Use non-fallible EventReceiver::add() where possible

This commit is contained in:
Tim Ledbetter 2023-09-22 22:28:59 +01:00 committed by Andreas Kling
parent 707ca984bd
commit b4e134cb52
54 changed files with 934 additions and 934 deletions

View file

@ -19,7 +19,7 @@ ErrorOr<NonnullRefPtr<ProcessFileDescriptorMapWidget>> ProcessFileDescriptorMapW
{
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ProcessFileDescriptorMapWidget()));
widget->set_layout<GUI::VerticalBoxLayout>(4);
widget->m_table_view = TRY(widget->try_add<GUI::TableView>());
widget->m_table_view = widget->add<GUI::TableView>();
Vector<GUI::JsonArrayModel::FieldSpec> pid_fds_fields;
TRY(pid_fds_fields.try_empend("fd", "FD"_string, Gfx::TextAlignment::CenterRight));

View file

@ -53,7 +53,7 @@ ErrorOr<NonnullRefPtr<ProcessMemoryMapWidget>> ProcessMemoryMapWidget::try_creat
{
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ProcessMemoryMapWidget()));
widget->set_layout<GUI::VerticalBoxLayout>(4);
widget->m_table_view = TRY(widget->try_add<GUI::TableView>());
widget->m_table_view = widget->add<GUI::TableView>();
Vector<GUI::JsonArrayModel::FieldSpec> pid_vm_fields;
TRY(pid_vm_fields.try_empend(
@ -110,7 +110,7 @@ ErrorOr<NonnullRefPtr<ProcessMemoryMapWidget>> ProcessMemoryMapWidget::try_creat
widget->m_table_view->set_column_painting_delegate(7, TRY(try_make<PagemapPaintingDelegate>()));
widget->m_table_view->set_key_column_and_sort_order(0, GUI::SortOrder::Ascending);
widget->m_timer = TRY(widget->try_add<Core::Timer>(1000, [widget] { widget->refresh(); }));
widget->m_timer = widget->add<Core::Timer>(1000, [widget] { widget->refresh(); });
widget->m_timer->start();
return widget;

View file

@ -97,7 +97,7 @@ ErrorOr<NonnullRefPtr<ProcessStateWidget>> ProcessStateWidget::try_create()
{
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ProcessStateWidget()));
widget->set_layout<GUI::VerticalBoxLayout>(4);
widget->m_table_view = TRY(widget->try_add<GUI::TableView>());
widget->m_table_view = widget->add<GUI::TableView>();
widget->m_table_view->set_model(TRY(try_make_ref_counted<ProcessStateModel>(ProcessModel::the(), 0)));
widget->m_table_view->column_header().set_visible(false);
widget->m_table_view->column_header().set_section_size(0, 90);

View file

@ -20,7 +20,7 @@ ErrorOr<NonnullRefPtr<ProcessUnveiledPathsWidget>> ProcessUnveiledPathsWidget::t
{
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ProcessUnveiledPathsWidget()));
widget->set_layout<GUI::VerticalBoxLayout>(4);
widget->m_table_view = TRY(widget->try_add<GUI::TableView>());
widget->m_table_view = widget->add<GUI::TableView>();
Vector<GUI::JsonArrayModel::FieldSpec> pid_unveil_fields;
TRY(pid_unveil_fields.try_empend("path", "Path"_string, Gfx::TextAlignment::CenterLeft));

View file

@ -75,7 +75,7 @@ ErrorOr<NonnullRefPtr<ThreadStackWidget>> ThreadStackWidget::try_create()
{
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ThreadStackWidget()));
widget->set_layout<GUI::VerticalBoxLayout>(4);
widget->m_stack_table = TRY(widget->try_add<GUI::TableView>());
widget->m_stack_table = widget->add<GUI::TableView>();
widget->m_stack_table->set_model(TRY(try_make_ref_counted<ThreadStackModel>()));
return widget;
}

View file

@ -332,8 +332,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
memory_stats_widget->refresh();
};
update_stats();
auto refresh_timer = TRY(window->try_add<Core::Timer>(frequency * 1000, move(update_stats)));
refresh_timer->start();
auto& refresh_timer = window->add<Core::Timer>(frequency * 1000, move(update_stats));
refresh_timer.start();
auto selected_id = [&](ProcessModel::Column column) -> pid_t {
if (process_table_view.selection().is_empty())
@ -454,7 +454,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto make_frequency_action = [&](int seconds) -> ErrorOr<void> {
auto action = GUI::Action::create_checkable(DeprecatedString::formatted("&{} Sec", seconds), [&refresh_timer, seconds](auto&) {
Config::write_i32("SystemMonitor"sv, "Monitor"sv, "Frequency"sv, seconds);
refresh_timer->restart(seconds * 1000);
refresh_timer.restart(seconds * 1000);
});
action->set_status_tip(TRY(String::formatted("Refresh every {} seconds", seconds)));
action->set_checked(frequency == seconds);
@ -578,24 +578,24 @@ ErrorOr<void> build_performance_tab(GUI::Widget& graphs_container)
Vector<SystemMonitor::GraphWidget&> cpu_graphs;
for (auto row = 0u; row < cpu_graph_rows; ++row) {
auto cpu_graph_row = TRY(cpu_graph_group_box.try_add<GUI::Widget>());
cpu_graph_row->set_layout<GUI::HorizontalBoxLayout>(6);
cpu_graph_row->set_fixed_height(108);
auto& cpu_graph_row = cpu_graph_group_box.add<GUI::Widget>();
cpu_graph_row.set_layout<GUI::HorizontalBoxLayout>(6);
cpu_graph_row.set_fixed_height(108);
for (auto i = 0u; i < cpu_graphs_per_row; ++i) {
auto cpu_graph = TRY(cpu_graph_row->try_add<SystemMonitor::GraphWidget>());
cpu_graph->set_max(100);
cpu_graph->set_value_format(0, {
.graph_color_role = ColorRole::SyntaxPreprocessorStatement,
.text_formatter = [](u64 value) {
return DeprecatedString::formatted("Total: {}%", value);
},
});
cpu_graph->set_value_format(1, {
.graph_color_role = ColorRole::SyntaxPreprocessorValue,
.text_formatter = [](u64 value) {
return DeprecatedString::formatted("Kernel: {}%", value);
},
});
auto& cpu_graph = cpu_graph_row.add<SystemMonitor::GraphWidget>();
cpu_graph.set_max(100);
cpu_graph.set_value_format(0, {
.graph_color_role = ColorRole::SyntaxPreprocessorStatement,
.text_formatter = [](u64 value) {
return DeprecatedString::formatted("Total: {}%", value);
},
});
cpu_graph.set_value_format(1, {
.graph_color_role = ColorRole::SyntaxPreprocessorValue,
.text_formatter = [](u64 value) {
return DeprecatedString::formatted("Kernel: {}%", value);
},
});
cpu_graphs.append(cpu_graph);
}
}