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

Calendar: Add a Calendar settings dialog for the first day of the week

This commit adds a new settings dialog for the Calendar application and
applet. It allows the user to specify their preferred first day of the
week.
This commit is contained in:
Olivier De Cannière 2022-07-16 01:33:39 +02:00 committed by Tim Flynn
parent 9414525d75
commit 0eceed4fd7
12 changed files with 178 additions and 2 deletions

View file

@ -6,6 +6,7 @@
*/
#include <AK/DateConstants.h>
#include <LibConfig/Client.h>
#include <LibCore/DateTime.h>
#include <LibGUI/Calendar.h>
#include <LibGUI/Painter.h>
@ -26,6 +27,9 @@ Calendar::Calendar(Core::DateTime date_time, Mode mode)
: m_selected_date(date_time)
, m_mode(mode)
{
auto first_day_of_week = Config::read_string("Calendar"sv, "View"sv, "FirstDayOfWeek"sv, "Sunday"sv);
m_first_day_of_week = static_cast<DayOfWeek>(day_of_week_index(first_day_of_week));
set_fill_with_background_color(true);
for (int i = 0; i < 7; i++) {
@ -736,4 +740,10 @@ void Calendar::doubleclick_event(GUI::MouseEvent& event)
}
}
}
size_t Calendar::day_of_week_index(String const& day_name)
{
auto const& day_names = AK::long_day_names;
return AK::find_index(day_names.begin(), day_names.end(), day_name);
}
}