mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:57:44 +00:00
Userland: Prefer non-fallible construction for LibGUI objects
This commit is contained in:
parent
a4a94de942
commit
a6f6a1afd2
54 changed files with 69 additions and 70 deletions
|
@ -36,7 +36,7 @@ FilterGallery::FilterGallery(GUI::Window* parent_window, ImageEditor* editor)
|
|||
VERIFY(m_config_widget);
|
||||
VERIFY(m_preview_widget);
|
||||
|
||||
m_error_label = GUI::Label::try_create().release_value_but_fixme_should_propagate_errors();
|
||||
m_error_label = GUI::Label::construct();
|
||||
m_error_label->set_enabled(false);
|
||||
|
||||
auto filter_tree_model = MUST(create_filter_tree_model(editor));
|
||||
|
|
|
@ -37,7 +37,7 @@ void Bloom::apply(Gfx::Bitmap& target_bitmap) const
|
|||
ErrorOr<RefPtr<GUI::Widget>> Bloom::get_settings_widget()
|
||||
{
|
||||
if (!m_settings_widget) {
|
||||
auto settings_widget = TRY(GUI::Widget::try_create());
|
||||
auto settings_widget = GUI::Widget::construct();
|
||||
settings_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto name_label = TRY(settings_widget->try_add<GUI::Label>("Bloom Filter"_string));
|
||||
|
|
|
@ -39,7 +39,7 @@ void FastBoxBlur::apply(Gfx::Bitmap& target_bitmap) const
|
|||
ErrorOr<RefPtr<GUI::Widget>> FastBoxBlur::get_settings_widget()
|
||||
{
|
||||
if (!m_settings_widget) {
|
||||
auto settings_widget = TRY(GUI::Widget::try_create());
|
||||
auto settings_widget = GUI::Widget::construct();
|
||||
settings_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto name_label = TRY(settings_widget->try_add<GUI::Label>("Fast Box Blur Filter"_string));
|
||||
|
|
|
@ -25,7 +25,7 @@ Filter::Filter(ImageEditor* editor)
|
|||
ErrorOr<RefPtr<GUI::Widget>> Filter::get_settings_widget()
|
||||
{
|
||||
if (!m_settings_widget) {
|
||||
auto settings_widget = TRY(GUI::Widget::try_create());
|
||||
auto settings_widget = GUI::Widget::construct();
|
||||
settings_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto name_label = TRY(settings_widget->try_add<GUI::Label>(TRY(String::from_utf8(filter_name()))));
|
||||
|
|
|
@ -30,7 +30,7 @@ void HueAndSaturation::apply(Gfx::Bitmap& target_bitmap) const
|
|||
ErrorOr<RefPtr<GUI::Widget>> HueAndSaturation::get_settings_widget()
|
||||
{
|
||||
if (!m_settings_widget) {
|
||||
auto settings_widget = TRY(GUI::Widget::try_create());
|
||||
auto settings_widget = GUI::Widget::construct();
|
||||
settings_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto add_slider = [&](auto name, int min, int max, auto member) -> ErrorOr<void> {
|
||||
|
|
|
@ -45,7 +45,7 @@ void Median::apply(Gfx::Bitmap& target_bitmap, Gfx::Bitmap const& source_bitmap)
|
|||
ErrorOr<RefPtr<GUI::Widget>> Median::get_settings_widget()
|
||||
{
|
||||
if (!m_settings_widget) {
|
||||
auto settings_widget = TRY(GUI::Widget::try_create());
|
||||
auto settings_widget = GUI::Widget::construct();
|
||||
TRY(settings_widget->load_from_gml(median_settings_gml));
|
||||
settings_widget->find_descendant_of_type_named<GUI::SpinBox>("filter_radius")->on_change = [this](auto value) {
|
||||
m_filter_radius = value;
|
||||
|
|
|
@ -20,7 +20,7 @@ void Sepia::apply(Gfx::Bitmap& target_bitmap, Gfx::Bitmap const& source_bitmap)
|
|||
ErrorOr<RefPtr<GUI::Widget>> Sepia::get_settings_widget()
|
||||
{
|
||||
if (!m_settings_widget) {
|
||||
auto settings_widget = TRY(GUI::Widget::try_create());
|
||||
auto settings_widget = GUI::Widget::construct();
|
||||
settings_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto name_label = TRY(settings_widget->try_add<GUI::Label>("Sepia Filter"_string));
|
||||
|
|
|
@ -564,13 +564,13 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
show_pixel_grid_action->set_checked(Config::read_bool("PixelPaint"sv, "PixelGrid"sv, "Show"sv, true));
|
||||
m_view_menu->add_action(*show_pixel_grid_action);
|
||||
|
||||
m_show_rulers_action = TRY(GUI::Action::try_create_checkable(
|
||||
m_show_rulers_action = GUI::Action::create_checkable(
|
||||
"Show R&ulers", { Mod_Ctrl, Key_R }, [&](auto& action) {
|
||||
Config::write_bool("PixelPaint"sv, "Rulers"sv, "Show"sv, action.is_checked());
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
editor->set_ruler_visibility(action.is_checked());
|
||||
}));
|
||||
});
|
||||
m_show_rulers_action->set_checked(Config::read_bool("PixelPaint"sv, "Rulers"sv, "Show"sv, true));
|
||||
m_view_menu->add_action(*m_show_rulers_action);
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ void BrushTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint s
|
|||
ErrorOr<GUI::Widget*> BrushTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto mode_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -64,7 +64,7 @@ void BucketTool::on_mousedown(Layer* layer, MouseEvent& event)
|
|||
ErrorOr<GUI::Widget*> BucketTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto threshold_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -128,7 +128,7 @@ void CloneTool::on_keyup(GUI::KeyEvent& event)
|
|||
ErrorOr<GUI::Widget*> CloneTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto size_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -129,7 +129,7 @@ bool EllipseTool::on_keydown(GUI::KeyEvent& event)
|
|||
ErrorOr<GUI::Widget*> EllipseTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto thickness_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -57,7 +57,7 @@ void EraseTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint
|
|||
ErrorOr<GUI::Widget*> EraseTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto size_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -201,7 +201,7 @@ void GradientTool::on_tool_activation()
|
|||
ErrorOr<GUI::Widget*> GradientTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto mode_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -179,7 +179,7 @@ void GuideTool::on_tool_activation()
|
|||
ErrorOr<GUI::Widget*> GuideTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto snapping_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -160,7 +160,7 @@ ErrorOr<GUI::Widget*> LassoSelectTool::get_properties_widget()
|
|||
return m_properties_widget.ptr();
|
||||
}
|
||||
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto mode_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -122,7 +122,7 @@ bool LineTool::on_keydown(GUI::KeyEvent& event)
|
|||
ErrorOr<GUI::Widget*> LineTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto thickness_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -292,7 +292,7 @@ Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> MoveTool::cursor(
|
|||
ErrorOr<GUI::Widget*> MoveTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto selection_mode_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -38,7 +38,7 @@ void PenTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint sta
|
|||
ErrorOr<GUI::Widget*> PenTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto size_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -44,7 +44,7 @@ void PickerTool::on_mousemove(Layer* layer, MouseEvent& event)
|
|||
ErrorOr<GUI::Widget*> PickerTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto sample_checkbox = TRY(properties_widget->try_add<GUI::CheckBox>("Sample all layers"_string));
|
||||
|
|
|
@ -189,7 +189,7 @@ ErrorOr<GUI::Widget*> PolygonalSelectTool::get_properties_widget()
|
|||
if (m_properties_widget)
|
||||
return m_properties_widget.ptr();
|
||||
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto mode_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -157,7 +157,7 @@ ErrorOr<GUI::Widget*> RectangleSelectTool::get_properties_widget()
|
|||
return m_properties_widget.ptr();
|
||||
}
|
||||
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto feather_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -143,7 +143,7 @@ bool RectangleTool::on_keydown(GUI::KeyEvent& event)
|
|||
ErrorOr<GUI::Widget*> RectangleTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto thickness_or_radius_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -93,7 +93,7 @@ void SprayTool::on_mouseup(Layer*, MouseEvent&)
|
|||
ErrorOr<GUI::Widget*> SprayTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto size_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -108,7 +108,7 @@ ErrorOr<GUI::Widget*> TextTool::get_properties_widget()
|
|||
if (m_properties_widget)
|
||||
return m_properties_widget.ptr();
|
||||
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto font_header = TRY(properties_widget->try_add<GUI::Label>("Current Font:"_string));
|
||||
|
|
|
@ -72,7 +72,7 @@ ErrorOr<GUI::Widget*> WandSelectTool::get_properties_widget()
|
|||
return m_properties_widget.ptr();
|
||||
}
|
||||
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto threshold_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
|
@ -26,7 +26,7 @@ void ZoomTool::on_mousedown(Layer*, MouseEvent& event)
|
|||
ErrorOr<GUI::Widget*> ZoomTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
auto properties_widget = TRY(GUI::Widget::try_create());
|
||||
auto properties_widget = GUI::Widget::construct();
|
||||
properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto sensitivity_container = TRY(properties_widget->try_add<GUI::Widget>());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue