mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:37:44 +00:00
CalendarSettings: Use new GML compiler
This commit is contained in:
parent
14a99bb22d
commit
63687c46ff
5 changed files with 20 additions and 16 deletions
|
@ -4,16 +4,13 @@ serenity_component(
|
||||||
TARGETS CalendarSettings
|
TARGETS CalendarSettings
|
||||||
)
|
)
|
||||||
|
|
||||||
stringify_gml(CalendarSettingsWidget.gml CalendarSettingsWidgetGML.h calendar_settings_widget_gml)
|
compile_gml(CalendarSettingsWidget.gml CalendarSettingsWidgetGML.cpp)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
|
CalendarSettingsWidgetGML.cpp
|
||||||
CalendarSettingsWidget.cpp
|
CalendarSettingsWidget.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GENERATED_SOURCES
|
|
||||||
CalendarSettingsWidgetGML.h
|
|
||||||
)
|
|
||||||
|
|
||||||
serenity_app(CalendarSettings ICON app-calendar)
|
serenity_app(CalendarSettings ICON app-calendar)
|
||||||
target_link_libraries(CalendarSettings PRIVATE LibConfig LibCore LibGfx LibGUI LibMain)
|
target_link_libraries(CalendarSettings PRIVATE LibConfig LibCore LibGfx LibGUI LibMain)
|
||||||
|
|
|
@ -7,12 +7,13 @@
|
||||||
|
|
||||||
#include "CalendarSettingsWidget.h"
|
#include "CalendarSettingsWidget.h"
|
||||||
#include <AK/DateConstants.h>
|
#include <AK/DateConstants.h>
|
||||||
#include <Applications/CalendarSettings/CalendarSettingsWidgetGML.h>
|
|
||||||
#include <LibConfig/Client.h>
|
#include <LibConfig/Client.h>
|
||||||
#include <LibGUI/ComboBox.h>
|
#include <LibGUI/ComboBox.h>
|
||||||
#include <LibGUI/ItemListModel.h>
|
#include <LibGUI/ItemListModel.h>
|
||||||
#include <LibGUI/SpinBox.h>
|
#include <LibGUI/SpinBox.h>
|
||||||
|
|
||||||
|
namespace CalendarSettings {
|
||||||
|
|
||||||
void CalendarSettingsWidget::apply_settings()
|
void CalendarSettingsWidget::apply_settings()
|
||||||
{
|
{
|
||||||
Config::write_string("Calendar"sv, "View"sv, "FirstDayOfWeek"sv, m_first_day_of_week_combobox->text());
|
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");
|
m_default_view_combobox->set_text("Month");
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<NonnullRefPtr<CalendarSettingsWidget>> CalendarSettingsWidget::try_create()
|
ErrorOr<NonnullRefPtr<CalendarSettingsWidget>> CalendarSettingsWidget::create()
|
||||||
{
|
{
|
||||||
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) CalendarSettingsWidget()));
|
auto widget = TRY(try_create());
|
||||||
TRY(widget->setup());
|
TRY(widget->setup());
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> CalendarSettingsWidget::setup()
|
ErrorOr<void> CalendarSettingsWidget::setup()
|
||||||
{
|
{
|
||||||
TRY(load_from_gml(calendar_settings_widget_gml));
|
|
||||||
|
|
||||||
m_first_day_of_week_combobox = *find_descendant_of_type_named<GUI::ComboBox>("first_day_of_week");
|
m_first_day_of_week_combobox = *find_descendant_of_type_named<GUI::ComboBox>("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_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);
|
m_first_day_of_week_combobox->set_only_allow_values_from_model(true);
|
||||||
|
@ -71,3 +70,5 @@ ErrorOr<void> CalendarSettingsWidget::setup()
|
||||||
};
|
};
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@GUI::Frame {
|
@CalendarSettings::CalendarSettingsWidget {
|
||||||
fill_with_background_color: true
|
fill_with_background_color: true
|
||||||
layout: @GUI::VerticalBoxLayout {
|
layout: @GUI::VerticalBoxLayout {
|
||||||
margins: [8]
|
margins: [8]
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
@GUI::Label {
|
@GUI::Label {
|
||||||
text: "Determines which day a week starts with in the calendar view."
|
text: "Determines which day a week starts with in the calendar view."
|
||||||
word_wrap: true
|
text_wrapping: "Wrap"
|
||||||
text_alignment: "CenterLeft"
|
text_alignment: "CenterLeft"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
@GUI::Label {
|
@GUI::Label {
|
||||||
text: "Determines the start and length of the weekend."
|
text: "Determines the start and length of the weekend."
|
||||||
word_wrap: true
|
text_wrapping: "Wrap"
|
||||||
text_alignment: "CenterLeft"
|
text_alignment: "CenterLeft"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
|
|
||||||
@GUI::Label {
|
@GUI::Label {
|
||||||
text: "Show the month or the year view when Calendar is started."
|
text: "Show the month or the year view when Calendar is started."
|
||||||
word_wrap: true
|
text_wrapping: "Wrap"
|
||||||
text_alignment: "CenterLeft"
|
text_alignment: "CenterLeft"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,17 +9,21 @@
|
||||||
|
|
||||||
#include <LibGUI/SettingsWindow.h>
|
#include <LibGUI/SettingsWindow.h>
|
||||||
|
|
||||||
|
namespace CalendarSettings {
|
||||||
|
|
||||||
class CalendarSettingsWidget final : public GUI::SettingsWindow::Tab {
|
class CalendarSettingsWidget final : public GUI::SettingsWindow::Tab {
|
||||||
C_OBJECT_ABSTRACT(CalendarSettingsWidget)
|
C_OBJECT_ABSTRACT(CalendarSettingsWidget)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ErrorOr<NonnullRefPtr<CalendarSettingsWidget>> try_create();
|
static ErrorOr<NonnullRefPtr<CalendarSettingsWidget>> create();
|
||||||
|
|
||||||
virtual void apply_settings() override;
|
virtual void apply_settings() override;
|
||||||
virtual void reset_default_values() override;
|
virtual void reset_default_values() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CalendarSettingsWidget() = default;
|
CalendarSettingsWidget() = default;
|
||||||
|
static ErrorOr<NonnullRefPtr<CalendarSettingsWidget>> try_create();
|
||||||
|
|
||||||
ErrorOr<void> setup();
|
ErrorOr<void> setup();
|
||||||
static constexpr Array<StringView, 2> const m_view_modes = { "Month"sv, "Year"sv };
|
static constexpr Array<StringView, 2> const m_view_modes = { "Month"sv, "Year"sv };
|
||||||
|
|
||||||
|
@ -28,3 +32,5 @@ private:
|
||||||
RefPtr<GUI::SpinBox> m_weekend_length_spinbox;
|
RefPtr<GUI::SpinBox> m_weekend_length_spinbox;
|
||||||
RefPtr<GUI::ComboBox> m_default_view_combobox;
|
RefPtr<GUI::ComboBox> m_default_view_combobox;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto app_icon = GUI::Icon::default_icon("app-calendar"sv);
|
auto app_icon = GUI::Icon::default_icon("app-calendar"sv);
|
||||||
|
|
||||||
auto window = TRY(GUI::SettingsWindow::create("Calendar Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
|
auto window = TRY(GUI::SettingsWindow::create("Calendar Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
|
||||||
(void)TRY(window->add_tab<CalendarSettingsWidget>("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_icon(app_icon.bitmap_for_size(16));
|
||||||
window->set_active_tab(selected_tab);
|
window->set_active_tab(selected_tab);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue