1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:47:34 +00:00

AK: Make "foo"_string infallible

Stop worrying about tiny OOMs.

Work towards #20405.
This commit is contained in:
Andreas Kling 2023-08-07 11:12:38 +02:00
parent db2a8725c6
commit 34344120f2
181 changed files with 626 additions and 630 deletions

View file

@ -167,7 +167,7 @@ ErrorOr<GUI::Widget*> BrushTool::get_properties_widget()
hardness_container->set_fixed_height(20);
(void)TRY(hardness_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto hardness_label = TRY(hardness_container->try_add<GUI::Label>(TRY("Hardness:"_string)));
auto hardness_label = TRY(hardness_container->try_add<GUI::Label>("Hardness:"_string));
hardness_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
hardness_label->set_fixed_size(80, 20);

View file

@ -71,7 +71,7 @@ ErrorOr<GUI::Widget*> BucketTool::get_properties_widget()
threshold_container->set_fixed_height(20);
(void)TRY(threshold_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto threshold_label = TRY(threshold_container->try_add<GUI::Label>(TRY("Threshold:"_string)));
auto threshold_label = TRY(threshold_container->try_add<GUI::Label>("Threshold:"_string));
threshold_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
threshold_label->set_fixed_size(80, 20);

View file

@ -154,7 +154,7 @@ ErrorOr<GUI::Widget*> CloneTool::get_properties_widget()
hardness_container->set_fixed_height(20);
(void)TRY(hardness_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto hardness_label = TRY(hardness_container->try_add<GUI::Label>(TRY("Hardness:"_string)));
auto hardness_label = TRY(hardness_container->try_add<GUI::Label>("Hardness:"_string));
hardness_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
hardness_label->set_fixed_size(80, 20);

View file

@ -136,7 +136,7 @@ ErrorOr<GUI::Widget*> EllipseTool::get_properties_widget()
thickness_container->set_fixed_height(20);
(void)TRY(thickness_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto thickness_label = TRY(thickness_container->try_add<GUI::Label>(TRY("Thickness:"_string)));
auto thickness_label = TRY(thickness_container->try_add<GUI::Label>("Thickness:"_string));
thickness_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
thickness_label->set_fixed_size(80, 20);
@ -159,7 +159,7 @@ ErrorOr<GUI::Widget*> EllipseTool::get_properties_widget()
(void)TRY(mode_radio_container->try_set_layout<GUI::VerticalBoxLayout>());
auto outline_mode_radio = TRY(mode_radio_container->try_add<GUI::RadioButton>("Outline"_short_string));
auto fill_mode_radio = TRY(mode_radio_container->try_add<GUI::RadioButton>("Fill"_short_string));
auto aa_enable_checkbox = TRY(mode_radio_container->try_add<GUI::CheckBox>(TRY("Anti-alias"_string)));
auto aa_enable_checkbox = TRY(mode_radio_container->try_add<GUI::CheckBox>("Anti-alias"_string));
aa_enable_checkbox->on_checked = [this](bool checked) {
m_antialias_enabled = checked;
@ -180,7 +180,7 @@ ErrorOr<GUI::Widget*> EllipseTool::get_properties_widget()
aspect_container->set_fixed_height(20);
(void)TRY(aspect_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto aspect_label = TRY(aspect_container->try_add<GUI::Label>(TRY("Aspect Ratio:"_string)));
auto aspect_label = TRY(aspect_container->try_add<GUI::Label>("Aspect Ratio:"_string));
aspect_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
aspect_label->set_fixed_size(80, 20);

View file

@ -82,7 +82,7 @@ ErrorOr<GUI::Widget*> EraseTool::get_properties_widget()
hardness_container->set_fixed_height(20);
(void)TRY(hardness_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto hardness_label = TRY(hardness_container->try_add<GUI::Label>(TRY("Hardness:"_string)));
auto hardness_label = TRY(hardness_container->try_add<GUI::Label>("Hardness:"_string));
hardness_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
hardness_label->set_fixed_size(80, 20);
@ -101,7 +101,7 @@ ErrorOr<GUI::Widget*> EraseTool::get_properties_widget()
auto use_secondary_color_checkbox = TRY(secondary_color_container->try_add<GUI::CheckBox>());
use_secondary_color_checkbox->set_checked(m_use_secondary_color);
use_secondary_color_checkbox->set_text(TRY("Use secondary color"_string));
use_secondary_color_checkbox->set_text("Use secondary color"_string);
use_secondary_color_checkbox->on_checked = [this](bool checked) {
m_use_secondary_color = checked;
};
@ -109,7 +109,7 @@ ErrorOr<GUI::Widget*> EraseTool::get_properties_widget()
auto mode_container = TRY(properties_widget->try_add<GUI::Widget>());
mode_container->set_fixed_height(46);
(void)TRY(mode_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto mode_label = TRY(mode_container->try_add<GUI::Label>(TRY("Draw Mode:"_string)));
auto mode_label = TRY(mode_container->try_add<GUI::Label>("Draw Mode:"_string));
mode_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
mode_label->set_fixed_size(80, 20);

View file

@ -207,7 +207,7 @@ ErrorOr<GUI::Widget*> GradientTool::get_properties_widget()
auto mode_container = TRY(properties_widget->try_add<GUI::Widget>());
mode_container->set_fixed_height(20);
(void)TRY(mode_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto mode_label = TRY(mode_container->try_add<GUI::Label>(TRY("Gradient Type:"_string)));
auto mode_label = TRY(mode_container->try_add<GUI::Label>("Gradient Type:"_string));
mode_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
mode_label->set_fixed_size(80, 20);
@ -237,7 +237,7 @@ ErrorOr<GUI::Widget*> GradientTool::get_properties_widget()
opacity_container->set_fixed_height(20);
(void)TRY(opacity_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto opacity_label = TRY(opacity_container->try_add<GUI::Label>(TRY("Opacity:"_string)));
auto opacity_label = TRY(opacity_container->try_add<GUI::Label>("Opacity:"_string));
opacity_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
opacity_label->set_fixed_size(80, 20);
@ -271,7 +271,7 @@ ErrorOr<GUI::Widget*> GradientTool::get_properties_widget()
hardness_container->set_visible(m_mode == GradientMode::Radial);
};
auto hardness_label = TRY(hardness_container->try_add<GUI::Label>(TRY("Hardness:"_string)));
auto hardness_label = TRY(hardness_container->try_add<GUI::Label>("Hardness:"_string));
hardness_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
hardness_label->set_fixed_size(80, 20);
@ -286,7 +286,7 @@ ErrorOr<GUI::Widget*> GradientTool::get_properties_widget()
};
set_secondary_slider(hardness_slider);
auto use_secondary_color_checkbox = TRY(properties_widget->try_add<GUI::CheckBox>(TRY("Use secondary color"_string)));
auto use_secondary_color_checkbox = TRY(properties_widget->try_add<GUI::CheckBox>("Use secondary color"_string));
use_secondary_color_checkbox->on_checked = [this](bool checked) {
m_use_secondary_color = checked;
m_editor->update();

View file

@ -186,7 +186,7 @@ ErrorOr<GUI::Widget*> GuideTool::get_properties_widget()
snapping_container->set_fixed_height(20);
(void)TRY(snapping_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto snapping_label = TRY(snapping_container->try_add<GUI::Label>(TRY("Snap offset:"_string)));
auto snapping_label = TRY(snapping_container->try_add<GUI::Label>("Snap offset:"_string));
snapping_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
snapping_label->set_fixed_size(80, 20);
snapping_label->set_tooltip("Press Shift to snap");

View file

@ -129,7 +129,7 @@ ErrorOr<GUI::Widget*> LineTool::get_properties_widget()
thickness_container->set_fixed_height(20);
(void)TRY(thickness_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto thickness_label = TRY(thickness_container->try_add<GUI::Label>(TRY("Thickness:"_string)));
auto thickness_label = TRY(thickness_container->try_add<GUI::Label>("Thickness:"_string));
thickness_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
thickness_label->set_fixed_size(80, 20);
@ -150,7 +150,7 @@ ErrorOr<GUI::Widget*> LineTool::get_properties_widget()
mode_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
mode_label->set_fixed_size(80, 20);
auto aa_enable_checkbox = TRY(mode_container->try_add<GUI::CheckBox>(TRY("Anti-alias"_string)));
auto aa_enable_checkbox = TRY(mode_container->try_add<GUI::CheckBox>("Anti-alias"_string));
aa_enable_checkbox->on_checked = [this](bool checked) {
m_antialias_enabled = checked;
};

View file

@ -298,15 +298,15 @@ ErrorOr<GUI::Widget*> MoveTool::get_properties_widget()
auto selection_mode_container = TRY(properties_widget->try_add<GUI::Widget>());
(void)TRY(selection_mode_container->try_set_layout<GUI::HorizontalBoxLayout>());
selection_mode_container->set_fixed_height(46);
auto selection_mode_label = TRY(selection_mode_container->try_add<GUI::Label>(TRY("Selection Mode:"_string)));
auto selection_mode_label = TRY(selection_mode_container->try_add<GUI::Label>("Selection Mode:"_string));
selection_mode_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
selection_mode_label->set_fixed_size(80, 40);
auto mode_radio_container = TRY(selection_mode_container->try_add<GUI::Widget>());
(void)TRY(mode_radio_container->try_set_layout<GUI::VerticalBoxLayout>());
m_selection_mode_foreground = TRY(mode_radio_container->try_add<GUI::RadioButton>(TRY("Foreground"_string)));
m_selection_mode_foreground = TRY(mode_radio_container->try_add<GUI::RadioButton>("Foreground"_string));
m_selection_mode_active = TRY(mode_radio_container->try_add<GUI::RadioButton>(TRY("Active Layer"_string)));
m_selection_mode_active = TRY(mode_radio_container->try_add<GUI::RadioButton>("Active Layer"_string));
m_selection_mode_foreground->on_checked = [this](bool) {
m_layer_selection_mode = LayerSelectionMode::ForegroundLayer;

View file

@ -45,7 +45,7 @@ ErrorOr<GUI::Widget*> PenTool::get_properties_widget()
size_container->set_fixed_height(20);
(void)TRY(size_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto size_label = TRY(size_container->try_add<GUI::Label>(TRY("Thickness:"_string)));
auto size_label = TRY(size_container->try_add<GUI::Label>("Thickness:"_string));
size_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
size_label->set_fixed_size(80, 20);

View file

@ -47,7 +47,7 @@ ErrorOr<GUI::Widget*> PickerTool::get_properties_widget()
auto properties_widget = TRY(GUI::Widget::try_create());
(void)TRY(properties_widget->try_set_layout<GUI::VerticalBoxLayout>());
auto sample_checkbox = TRY(properties_widget->try_add<GUI::CheckBox>(TRY("Sample all layers"_string)));
auto sample_checkbox = TRY(properties_widget->try_add<GUI::CheckBox>("Sample all layers"_string));
sample_checkbox->set_checked(m_sample_all_layers);
sample_checkbox->on_checked = [this](bool value) {
m_sample_all_layers = value;

View file

@ -165,7 +165,7 @@ ErrorOr<GUI::Widget*> RectangleSelectTool::get_properties_widget()
(void)TRY(feather_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto feather_label = TRY(feather_container->try_add<GUI::Label>());
feather_label->set_text(TRY("Feather:"_string));
feather_label->set_text("Feather:"_string);
feather_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
feather_label->set_fixed_size(80, 20);

View file

@ -189,7 +189,7 @@ ErrorOr<GUI::Widget*> RectangleTool::get_properties_widget()
(void)TRY(mode_radio_container->try_set_layout<GUI::VerticalBoxLayout>());
auto outline_mode_radio = TRY(mode_radio_container->try_add<GUI::RadioButton>("Outline"_short_string));
auto fill_mode_radio = TRY(mode_radio_container->try_add<GUI::RadioButton>("Fill"_short_string));
auto gradient_mode_radio = TRY(mode_radio_container->try_add<GUI::RadioButton>(TRY("Gradient"_string)));
auto gradient_mode_radio = TRY(mode_radio_container->try_add<GUI::RadioButton>("Gradient"_string));
mode_radio_container->set_fixed_width(70);
auto rounded_corners_mode_radio = TRY(mode_radio_container->try_add<GUI::RadioButton>("Rounded"_short_string));
@ -215,7 +215,7 @@ ErrorOr<GUI::Widget*> RectangleTool::get_properties_widget()
auto mode_extras_container = TRY(mode_container->try_add<GUI::Widget>());
(void)TRY(mode_extras_container->try_set_layout<GUI::VerticalBoxLayout>());
auto aa_enable_checkbox = TRY(mode_extras_container->try_add<GUI::CheckBox>(TRY("Anti-alias"_string)));
auto aa_enable_checkbox = TRY(mode_extras_container->try_add<GUI::CheckBox>("Anti-alias"_string));
aa_enable_checkbox->on_checked = [this](bool checked) {
m_antialias_enabled = checked;
};
@ -225,7 +225,7 @@ ErrorOr<GUI::Widget*> RectangleTool::get_properties_widget()
(void)TRY(aspect_container->try_set_layout<GUI::VerticalBoxLayout>());
aspect_container->set_fixed_width(75);
auto aspect_label = TRY(aspect_container->try_add<GUI::Label>(TRY("Aspect Ratio:"_string)));
auto aspect_label = TRY(aspect_container->try_add<GUI::Label>("Aspect Ratio:"_string));
aspect_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
aspect_label->set_fixed_size(75, 20);

View file

@ -117,7 +117,7 @@ ErrorOr<GUI::Widget*> SprayTool::get_properties_widget()
density_container->set_fixed_height(20);
(void)TRY(density_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto density_label = TRY(density_container->try_add<GUI::Label>(TRY("Density:"_string)));
auto density_label = TRY(density_container->try_add<GUI::Label>("Density:"_string));
density_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
density_label->set_fixed_size(80, 20);

View file

@ -111,12 +111,12 @@ ErrorOr<GUI::Widget*> TextTool::get_properties_widget()
auto properties_widget = TRY(GUI::Widget::try_create());
(void)TRY(properties_widget->try_set_layout<GUI::VerticalBoxLayout>());
auto font_header = TRY(properties_widget->try_add<GUI::Label>(TRY("Current Font:"_string)));
auto font_header = TRY(properties_widget->try_add<GUI::Label>("Current Font:"_string));
font_header->set_text_alignment(Gfx::TextAlignment::CenterLeft);
m_font_label = TRY(properties_widget->try_add<GUI::Label>(TRY(String::from_deprecated_string(m_selected_font->human_readable_name()))));
auto change_font_button = TRY(properties_widget->try_add<GUI::Button>(TRY("Change Font..."_string)));
auto change_font_button = TRY(properties_widget->try_add<GUI::Button>("Change Font..."_string));
change_font_button->on_click = [this](auto) {
auto picker = GUI::FontPicker::construct(nullptr, m_selected_font, false);
if (picker->exec() == GUI::Dialog::ExecResult::OK) {

View file

@ -79,7 +79,7 @@ ErrorOr<GUI::Widget*> WandSelectTool::get_properties_widget()
threshold_container->set_fixed_height(20);
(void)TRY(threshold_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto threshold_label = TRY(threshold_container->try_add<GUI::Label>(TRY("Threshold:"_string)));
auto threshold_label = TRY(threshold_container->try_add<GUI::Label>("Threshold:"_string));
threshold_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
threshold_label->set_fixed_size(80, 20);

View file

@ -33,7 +33,7 @@ ErrorOr<GUI::Widget*> ZoomTool::get_properties_widget()
sensitivity_container->set_fixed_height(20);
(void)TRY(sensitivity_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto sensitivity_label = TRY(sensitivity_container->try_add<GUI::Label>(TRY("Sensitivity:"_string)));
auto sensitivity_label = TRY(sensitivity_container->try_add<GUI::Label>("Sensitivity:"_string));
sensitivity_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
sensitivity_label->set_fixed_size(80, 20);