1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:07:36 +00:00

Calendar/AddEventDialog: Prevent inputting invalid date ranges

The calendar now verifies that the user can't input invalid date ranges,
i.e. date ranges where the end is before the start. The UI elements do
this implicitly, by adjusting the values when changing the dates in an
illegal way (e.g. when picking an end date that is before the start
date, the end date will change to the start date).
This commit is contained in:
david072 2023-11-17 21:51:13 +01:00 committed by Andrew Kaster
parent df3e6174b6
commit a84778f6ee
2 changed files with 78 additions and 30 deletions

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2019-2020, Ryan Grieb <ryan.m.grieb@gmail.com>
* Copyright (c) 2022-2023, the SerenityOS developers.
* Copyright (c) 2023, David Ganz <david.g.ganz@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -29,11 +30,21 @@ public:
private:
AddEventDialog(Core::DateTime date_time, EventManager& event_manager, Window* parent_window = nullptr);
ErrorOr<void> add_event_to_calendar();
ErrorOr<bool> add_event_to_calendar();
void update_start_date();
void update_end_date();
Core::DateTime m_start_date_time;
Core::DateTime m_end_date_time;
EventManager& m_event_manager;
RefPtr<GUI::TextBox> m_start_date_box;
RefPtr<GUI::TextBox> m_end_date_box;
RefPtr<GUI::SpinBox> m_start_hour_box;
RefPtr<GUI::SpinBox> m_start_minute_box;
RefPtr<GUI::SpinBox> m_end_hour_box;
RefPtr<GUI::SpinBox> m_end_minute_box;
};
}