mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 21:40:33 +00:00
Calendar: Limit the starting day input range to the selected month
Previously we allowed entering any day value greater than one. With this patch the maximum input value is dynamic based on the selected month and year.
This commit is contained in:
parent
5b46d16b4d
commit
178164808c
Notes:
sideshowbarker
2024-07-17 07:23:06 +09:00
Author: https://github.com/networkException Commit: https://github.com/SerenityOS/serenity/commit/178164808c Pull-request: https://github.com/SerenityOS/serenity/pull/15145
1 changed files with 11 additions and 1 deletions
|
@ -63,8 +63,8 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window)
|
|||
|
||||
auto& starting_day_combo = middle_container.add<GUI::SpinBox>();
|
||||
starting_day_combo.set_fixed_size(40, 20);
|
||||
starting_day_combo.set_range(1, m_date_time.days_in_month());
|
||||
starting_day_combo.set_value(m_date_time.day());
|
||||
starting_day_combo.set_min(1);
|
||||
|
||||
auto& starting_year_combo = middle_container.add<GUI::SpinBox>();
|
||||
starting_year_combo.set_fixed_size(55, 20);
|
||||
|
@ -100,6 +100,16 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window)
|
|||
done(ExecResult::OK);
|
||||
};
|
||||
|
||||
auto update_starting_day_range = [&starting_day_combo, &starting_year_combo, &starting_month_combo]() {
|
||||
auto year = starting_year_combo.value();
|
||||
auto month = starting_month_combo.selected_index();
|
||||
|
||||
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(); };
|
||||
starting_month_combo.on_change = [&update_starting_day_range](auto, auto) { update_starting_day_range(); };
|
||||
|
||||
event_title_textbox.set_focus(true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue