mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:37:45 +00:00
Calendar: Update day range when the month changes
Previously it was possible to create an event on Feb 31(!)
This commit is contained in:
parent
97cc5b2da4
commit
edee914093
1 changed files with 10 additions and 7 deletions
|
@ -67,16 +67,13 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, EventManager& event_man
|
||||||
done(ExecResult::OK);
|
done(ExecResult::OK);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto update_starting_day_range = [&starting_day_combo, &starting_year_combo, &starting_month_combo]() {
|
auto update_starting_day_range = [=]() {
|
||||||
auto year = starting_year_combo->value();
|
auto year = starting_year_combo->value();
|
||||||
auto month = starting_month_combo->selected_index();
|
auto month = starting_month_combo->selected_index();
|
||||||
|
|
||||||
starting_day_combo->set_range(1, days_in_month(year, month + 1));
|
starting_day_combo->set_range(1, days_in_month(year, month + 1));
|
||||||
};
|
};
|
||||||
starting_year_combo->on_change = [update_starting_day_range](auto) { update_starting_day_range(); };
|
auto update_combo_values = [=, this]() {
|
||||||
starting_month_combo->on_change = [update_starting_day_range](auto, auto) { update_starting_day_range(); };
|
|
||||||
|
|
||||||
auto update_combo_values = [&]() {
|
|
||||||
auto year = starting_year_combo->value();
|
auto year = starting_year_combo->value();
|
||||||
auto month = starting_month_combo->selected_index() + 1;
|
auto month = starting_month_combo->selected_index() + 1;
|
||||||
auto day = starting_day_combo->value();
|
auto day = starting_day_combo->value();
|
||||||
|
@ -85,8 +82,14 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, EventManager& event_man
|
||||||
|
|
||||||
m_date_time = Core::DateTime::create(year, month, day, hour, minute);
|
m_date_time = Core::DateTime::create(year, month, day, hour, minute);
|
||||||
};
|
};
|
||||||
starting_year_combo->on_change = [update_combo_values](auto) { update_combo_values(); };
|
starting_year_combo->on_change = [update_combo_values, update_starting_day_range](auto) {
|
||||||
starting_month_combo->on_change = [update_combo_values](auto, auto) { update_combo_values(); };
|
update_combo_values();
|
||||||
|
update_starting_day_range();
|
||||||
|
};
|
||||||
|
starting_month_combo->on_change = [update_combo_values, update_starting_day_range](auto, auto) {
|
||||||
|
update_combo_values();
|
||||||
|
update_starting_day_range();
|
||||||
|
};
|
||||||
starting_day_combo->on_change = [update_combo_values](auto) { update_combo_values(); };
|
starting_day_combo->on_change = [update_combo_values](auto) { update_combo_values(); };
|
||||||
starting_hour_combo->on_change = [update_combo_values](auto) { update_combo_values(); };
|
starting_hour_combo->on_change = [update_combo_values](auto) { update_combo_values(); };
|
||||||
starting_minute_combo->on_change = [update_combo_values](auto) { update_combo_values(); };
|
starting_minute_combo->on_change = [update_combo_values](auto) { update_combo_values(); };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue