summaryrefslogtreecommitdiff
path: root/Userland/Applications/CalendarSettings
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere96@gmail.com>2022-09-19 22:50:01 +0200
committerTim Flynn <trflynn89@pm.me>2022-09-20 13:12:00 -0400
commita1d98b825d0255d4d35f435d8381d541fc56f48b (patch)
tree8faa615da650c3e629d9c3fe82ab8d958b585fc9 /Userland/Applications/CalendarSettings
parent0eceed4fd72697a4e9bebf23c06b300637296361 (diff)
downloadserenity-a1d98b825d0255d4d35f435d8381d541fc56f48b.zip
Calendar: Add setting to choose default view
This commit adds an entry to the Calendar Settings to allow the user to select between the month and year views as the startup default.
Diffstat (limited to 'Userland/Applications/CalendarSettings')
-rw-r--r--Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp11
-rw-r--r--Userland/Applications/CalendarSettings/CalendarSettingsWidget.gml37
-rw-r--r--Userland/Applications/CalendarSettings/CalendarSettingsWidget.h2
3 files changed, 47 insertions, 3 deletions
diff --git a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp
index 72d4976f86..d354a9ba7f 100644
--- a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp
+++ b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp
@@ -13,16 +13,19 @@
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, "DefaultView"sv, m_default_view_combobox->text());
}
void CalendarSettingsWidget::reset_default_values()
{
m_first_day_of_week_combobox->set_text("Sunday");
+ m_default_view_combobox->set_text("Month");
}
CalendarSettingsWidget::CalendarSettingsWidget()
{
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->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);
@@ -30,4 +33,12 @@ CalendarSettingsWidget::CalendarSettingsWidget()
m_first_day_of_week_combobox->on_change = [&](auto, auto) {
set_modified(true);
};
+
+ m_default_view_combobox = *find_descendant_of_type_named<GUI::ComboBox>("default_view");
+ m_default_view_combobox->set_text(Config::read_string("Calendar"sv, "View"sv, "DefaultView"sv, "Month"sv));
+ m_default_view_combobox->set_only_allow_values_from_model(true);
+ m_default_view_combobox->set_model(*GUI::ItemListModel<StringView, Array<StringView, 2>>::create(m_view_modes));
+ m_default_view_combobox->on_change = [&](auto, auto) {
+ set_modified(true);
+ };
}
diff --git a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.gml b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.gml
index 8403a640e5..f619bec9c5 100644
--- a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.gml
+++ b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.gml
@@ -30,9 +30,40 @@
fixed_width: 70
}
- @GUI::ComboBox {
- name: "first_day_of_week"
- }
+ @GUI::ComboBox {
+ name: "first_day_of_week"
+ }
+ }
+ }
+
+ @GUI::GroupBox {
+ title: "Default view"
+ fixed_height: 72
+ layout: @GUI::VerticalBoxLayout {
+ margins: [6]
+ spacing: 2
+ }
+
+ @GUI::Label {
+ text: "Show the month or the year view when Calendar is started."
+ word_wrap: true
+ text_alignment: "CenterLeft"
+ }
+
+ @GUI::Widget {
+ layout: @GUI::HorizontalBoxLayout {
+ spacing: 16
+ }
+
+ @GUI::Label {
+ text: "Default view:"
+ text_alignment: "CenterLeft"
+ fixed_width: 70
+ }
+
+ @GUI::ComboBox {
+ name: "default_view"
+ }
}
}
}
diff --git a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h
index b033537472..494597100a 100644
--- a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h
+++ b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h
@@ -18,6 +18,8 @@ public:
private:
CalendarSettingsWidget();
+ static constexpr Array<StringView, 2> const m_view_modes = { "Month"sv, "Year"sv };
RefPtr<GUI::ComboBox> m_first_day_of_week_combobox;
+ RefPtr<GUI::ComboBox> m_default_view_combobox;
};