mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 09:07:44 +00:00
ClockSettings: Convert ClockSettingsWidget
to a failable factory
This commit is contained in:
parent
e36e465b41
commit
ab8be9aed5
2 changed files with 19 additions and 6 deletions
|
@ -19,9 +19,16 @@ constexpr auto time_format_12h_seconds = "%r"sv;
|
|||
constexpr auto time_format_24h = "%R"sv;
|
||||
constexpr auto time_format_24h_seconds = "%T"sv;
|
||||
|
||||
ClockSettingsWidget::ClockSettingsWidget()
|
||||
ErrorOr<NonnullRefPtr<ClockSettingsWidget>> ClockSettingsWidget::try_create()
|
||||
{
|
||||
load_from_gml(clock_settings_widget_gml).release_value_but_fixme_should_propagate_errors();
|
||||
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ClockSettingsWidget()));
|
||||
TRY(widget->setup());
|
||||
return widget;
|
||||
}
|
||||
|
||||
ErrorOr<void> ClockSettingsWidget::setup()
|
||||
{
|
||||
TRY(load_from_gml(clock_settings_widget_gml));
|
||||
|
||||
m_24_hour_radio = *find_descendant_of_type_named<GUI::RadioButton>("24hour_radio");
|
||||
auto& twelve_hour_radio = *find_descendant_of_type_named<GUI::RadioButton>("12hour_radio");
|
||||
|
@ -87,11 +94,13 @@ ClockSettingsWidget::ClockSettingsWidget()
|
|||
set_modified(true);
|
||||
};
|
||||
|
||||
m_clock_preview_update_timer = Core::Timer::create_repeating(1000, [&]() {
|
||||
m_clock_preview_update_timer = TRY(Core::Timer::create_repeating(1000, [&]() {
|
||||
update_clock_preview();
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
}));
|
||||
m_clock_preview_update_timer->start();
|
||||
update_clock_preview();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void ClockSettingsWidget::apply_settings()
|
||||
|
|
|
@ -10,10 +10,14 @@
|
|||
#include <LibGUI/SettingsWindow.h>
|
||||
|
||||
class ClockSettingsWidget final : public GUI::SettingsWindow::Tab {
|
||||
C_OBJECT(ClockSettingsWidget)
|
||||
C_OBJECT_ABSTRACT(ClockSettingsWidget)
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<ClockSettingsWidget>> try_create();
|
||||
|
||||
private:
|
||||
ClockSettingsWidget();
|
||||
ClockSettingsWidget() = default;
|
||||
ErrorOr<void> setup();
|
||||
|
||||
virtual void apply_settings() override;
|
||||
virtual void reset_default_values() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue