diff --git a/Userland/Applications/CalendarSettings/CMakeLists.txt b/Userland/Applications/CalendarSettings/CMakeLists.txt index 19145c166e..4fe3c6cf05 100644 --- a/Userland/Applications/CalendarSettings/CMakeLists.txt +++ b/Userland/Applications/CalendarSettings/CMakeLists.txt @@ -4,16 +4,13 @@ serenity_component( TARGETS CalendarSettings ) -stringify_gml(CalendarSettingsWidget.gml CalendarSettingsWidgetGML.h calendar_settings_widget_gml) +compile_gml(CalendarSettingsWidget.gml CalendarSettingsWidgetGML.cpp) set(SOURCES main.cpp + CalendarSettingsWidgetGML.cpp CalendarSettingsWidget.cpp ) -set(GENERATED_SOURCES - CalendarSettingsWidgetGML.h -) - serenity_app(CalendarSettings ICON app-calendar) target_link_libraries(CalendarSettings PRIVATE LibConfig LibCore LibGfx LibGUI LibMain) diff --git a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp index 872daacdf8..a76beebb9b 100644 --- a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp +++ b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp @@ -7,12 +7,13 @@ #include "CalendarSettingsWidget.h" #include -#include #include #include #include #include +namespace CalendarSettings { + void CalendarSettingsWidget::apply_settings() { Config::write_string("Calendar"sv, "View"sv, "FirstDayOfWeek"sv, m_first_day_of_week_combobox->text()); @@ -29,17 +30,15 @@ void CalendarSettingsWidget::reset_default_values() m_default_view_combobox->set_text("Month"); } -ErrorOr> CalendarSettingsWidget::try_create() +ErrorOr> CalendarSettingsWidget::create() { - auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) CalendarSettingsWidget())); + auto widget = TRY(try_create()); TRY(widget->setup()); return widget; } ErrorOr CalendarSettingsWidget::setup() { - TRY(load_from_gml(calendar_settings_widget_gml)); - m_first_day_of_week_combobox = *find_descendant_of_type_named("first_day_of_week"); m_first_day_of_week_combobox->set_text(Config::read_string("Calendar"sv, "View"sv, "FirstDayOfWeek"sv, "Sunday"sv)); m_first_day_of_week_combobox->set_only_allow_values_from_model(true); @@ -71,3 +70,5 @@ ErrorOr CalendarSettingsWidget::setup() }; return {}; } + +} diff --git a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.gml b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.gml index 99718ced5a..d63346f88b 100644 --- a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.gml +++ b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.gml @@ -1,4 +1,4 @@ -@GUI::Frame { +@CalendarSettings::CalendarSettingsWidget { fill_with_background_color: true layout: @GUI::VerticalBoxLayout { margins: [8] @@ -15,7 +15,7 @@ @GUI::Label { text: "Determines which day a week starts with in the calendar view." - word_wrap: true + text_wrapping: "Wrap" text_alignment: "CenterLeft" } @@ -46,7 +46,7 @@ @GUI::Label { text: "Determines the start and length of the weekend." - word_wrap: true + text_wrapping: "Wrap" text_alignment: "CenterLeft" } @@ -103,7 +103,7 @@ @GUI::Label { text: "Show the month or the year view when Calendar is started." - word_wrap: true + text_wrapping: "Wrap" text_alignment: "CenterLeft" } diff --git a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h index 7c0f66574a..9a8d90e10f 100644 --- a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h +++ b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h @@ -9,17 +9,21 @@ #include +namespace CalendarSettings { + class CalendarSettingsWidget final : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(CalendarSettingsWidget) public: - static ErrorOr> try_create(); + static ErrorOr> create(); virtual void apply_settings() override; virtual void reset_default_values() override; private: CalendarSettingsWidget() = default; + static ErrorOr> try_create(); + ErrorOr setup(); static constexpr Array const m_view_modes = { "Month"sv, "Year"sv }; @@ -28,3 +32,5 @@ private: RefPtr m_weekend_length_spinbox; RefPtr m_default_view_combobox; }; + +} diff --git a/Userland/Applications/CalendarSettings/main.cpp b/Userland/Applications/CalendarSettings/main.cpp index 25f912d097..31f735b6a7 100644 --- a/Userland/Applications/CalendarSettings/main.cpp +++ b/Userland/Applications/CalendarSettings/main.cpp @@ -33,7 +33,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app_icon = GUI::Icon::default_icon("app-calendar"sv); auto window = TRY(GUI::SettingsWindow::create("Calendar Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes)); - (void)TRY(window->add_tab("Calendar"_string, "Calendar"sv)); + (void)TRY(window->add_tab(TRY(CalendarSettings::CalendarSettingsWidget::create()), "Calendar"_string, "Calendar"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->set_active_tab(selected_tab);