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

MouseSettings: Convert setting widgets to a failable factory

This commit is contained in:
Karol Kosek 2023-05-09 22:44:43 +02:00 committed by Andreas Kling
parent ab8be9aed5
commit 90819e2d71
6 changed files with 43 additions and 13 deletions

View file

@ -9,9 +9,16 @@
#include <Applications/MouseSettings/HighlightWidgetGML.h>
#include <LibGUI/ConnectionToWindowServer.h>
HighlightWidget::HighlightWidget()
ErrorOr<NonnullRefPtr<HighlightWidget>> HighlightWidget::try_create()
{
load_from_gml(highlight_widget_gml).release_value_but_fixme_should_propagate_errors();
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) HighlightWidget()));
TRY(widget->setup());
return widget;
}
ErrorOr<void> HighlightWidget::setup()
{
TRY(load_from_gml(highlight_widget_gml));
m_highlight_preview = find_descendant_of_type_named<GUI::Frame>("preview_frame")->add<MouseSettings::HighlightPreviewWidget>(palette());
@ -41,6 +48,7 @@ HighlightWidget::HighlightWidget()
m_highlight_preview->set_color(highlight_color());
m_highlight_preview->set_radius(highlight_radius());
return {};
}
Gfx::Color HighlightWidget::highlight_color()