mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:47:45 +00:00
LibGUI: Teach Calendar about the new Config Items
Now the Calendar living in LibGUI knows about FirstDayOfWeekend and WeekendLength.
This commit is contained in:
parent
eca559d65d
commit
170b8cad04
2 changed files with 22 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2020, Ryan Grieb <ryan.m.grieb@gmail.com>
|
* Copyright (c) 2019-2020, Ryan Grieb <ryan.m.grieb@gmail.com>
|
||||||
* Copyright (c) 2020-2022, the SerenityOS developers.
|
* Copyright (c) 2020-2022, the SerenityOS developers.
|
||||||
|
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -30,6 +31,12 @@ Calendar::Calendar(Core::DateTime date_time, Mode mode)
|
||||||
auto first_day_of_week = Config::read_string("Calendar"sv, "View"sv, "FirstDayOfWeek"sv, "Sunday"sv);
|
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));
|
m_first_day_of_week = static_cast<DayOfWeek>(day_of_week_index(first_day_of_week));
|
||||||
|
|
||||||
|
auto first_day_of_weekend = Config::read_string("Calendar"sv, "View"sv, "FirstDayOfWeekend"sv, "Saturday"sv);
|
||||||
|
m_first_day_of_weekend = static_cast<DayOfWeek>(day_of_week_index(first_day_of_weekend));
|
||||||
|
|
||||||
|
auto weekend_length = Config::read_i32("Calendar"sv, "View"sv, "WeekendLength"sv, 2);
|
||||||
|
m_weekend_length = weekend_length;
|
||||||
|
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
|
@ -760,6 +767,17 @@ void Calendar::config_string_did_change(String const& domain, String const& grou
|
||||||
if (domain == "Calendar" && group == "View" && key == "FirstDayOfWeek") {
|
if (domain == "Calendar" && group == "View" && key == "FirstDayOfWeek") {
|
||||||
m_first_day_of_week = static_cast<DayOfWeek>(day_of_week_index(value));
|
m_first_day_of_week = static_cast<DayOfWeek>(day_of_week_index(value));
|
||||||
update_tiles(m_view_year, m_view_month);
|
update_tiles(m_view_year, m_view_month);
|
||||||
|
} else if (domain == "Calendar" && group == "View" && key == "FirstDayOfWeekend") {
|
||||||
|
m_first_day_of_weekend = static_cast<DayOfWeek>(day_of_week_index(value));
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Calendar::config_i32_did_change(String const& domain, String const& group, String const& key, i32 value)
|
||||||
|
{
|
||||||
|
if (domain == "Calendar" && group == "View" && key == "WeekendLength") {
|
||||||
|
m_weekend_length = value;
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2020, Ryan Grieb <ryan.m.grieb@gmail.com>
|
* Copyright (c) 2019-2020, Ryan Grieb <ryan.m.grieb@gmail.com>
|
||||||
* Copyright (c) 2020-2022, the SerenityOS developers.
|
* Copyright (c) 2020-2022, the SerenityOS developers.
|
||||||
|
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -71,6 +72,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void config_string_did_change(String const&, String const&, String const&, String const&) override;
|
virtual void config_string_did_change(String const&, String const&, String const&, String const&) override;
|
||||||
|
virtual void config_i32_did_change(String const&, String const&, String const&, i32 value) override;
|
||||||
|
|
||||||
Function<void()> on_tile_click;
|
Function<void()> on_tile_click;
|
||||||
Function<void()> on_tile_doubleclick;
|
Function<void()> on_tile_doubleclick;
|
||||||
|
@ -146,6 +148,8 @@ private:
|
||||||
Saturday
|
Saturday
|
||||||
};
|
};
|
||||||
DayOfWeek m_first_day_of_week { DayOfWeek::Sunday };
|
DayOfWeek m_first_day_of_week { DayOfWeek::Sunday };
|
||||||
|
DayOfWeek m_first_day_of_weekend { DayOfWeek::Saturday };
|
||||||
|
int m_weekend_length { 2 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue