diff --git a/Userland/Applications/Calendar/AddEventDialog.cpp b/Userland/Applications/Calendar/AddEventDialog.cpp index 487b600bd2c..aa53c9fbbf5 100644 --- a/Userland/Applications/Calendar/AddEventDialog.cpp +++ b/Userland/Applications/Calendar/AddEventDialog.cpp @@ -28,7 +28,7 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, EventManager& event_man , m_end_date_time(Core::DateTime::from_timestamp(date_time.timestamp() + (15 * 60))) , m_event_manager(event_manager) { - resize(158, 130); + resize(360, 140); set_title("Add Event"); set_resizable(false); set_icon(parent_window->icon()); @@ -64,6 +64,26 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, EventManager& event_man starting_meridiem_input->set_model(MeridiemListModel::create()); starting_meridiem_input->set_selected_index(0); + auto ending_month_input = widget->find_descendant_of_type_named("end_month"); + ending_month_input->set_model(MonthListModel::create()); + ending_month_input->set_selected_index(m_end_date_time.month() - 1); + + auto ending_day_input = widget->find_descendant_of_type_named("end_day"); + ending_day_input->set_value(m_end_date_time.day()); + + auto ending_year_input = widget->find_descendant_of_type_named("end_year"); + ending_year_input->set_value(m_end_date_time.year()); + + auto ending_hour_input = widget->find_descendant_of_type_named("end_hour"); + ending_hour_input->set_value(m_end_date_time.hour()); + + auto ending_minute_input = widget->find_descendant_of_type_named("end_minute"); + ending_minute_input->set_value(m_end_date_time.minute()); + + auto ending_meridiem_input = widget->find_descendant_of_type_named("end_meridiem"); + ending_meridiem_input->set_model(MeridiemListModel::create()); + ending_meridiem_input->set_selected_index(0); + auto ok_button = widget->find_descendant_of_type_named("ok_button"); ok_button->on_click = [&](auto) { add_event_to_calendar().release_value_but_fixme_should_propagate_errors(); @@ -77,7 +97,13 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, EventManager& event_man starting_day_input->set_range(1, days_in_month(year, month + 1)); }; - auto update_input_values = [=, this]() { + auto update_ending_day_range = [=]() { + auto year = ending_year_input->value(); + auto month = ending_month_input->selected_index(); + + ending_day_input->set_range(1, days_in_month(year, month + 1)); + }; + auto update_starting_input_values = [=, this]() { auto year = starting_year_input->value(); auto month = starting_month_input->selected_index() + 1; auto day = starting_day_input->value(); @@ -86,17 +112,38 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, EventManager& event_man m_start_date_time = Core::DateTime::create(year, month, day, hour, minute); }; - starting_year_input->on_change = [update_input_values, update_starting_day_range](auto) { - update_input_values(); + auto update_ending_input_values = [=, this]() { + auto year = ending_year_input->value(); + auto month = ending_month_input->selected_index() + 1; + auto day = ending_day_input->value(); + auto hour = ending_hour_input->value(); + auto minute = ending_minute_input->value(); + + m_end_date_time = Core::DateTime::create(year, month, day, hour, minute); + }; + starting_year_input->on_change = [update_starting_input_values, update_starting_day_range](auto) { + update_starting_input_values(); update_starting_day_range(); }; - starting_month_input->on_change = [update_input_values, update_starting_day_range](auto, auto) { - update_input_values(); + starting_month_input->on_change = [update_starting_input_values, update_starting_day_range](auto, auto) { + update_starting_input_values(); update_starting_day_range(); }; - starting_day_input->on_change = [update_input_values](auto) { update_input_values(); }; - starting_hour_input->on_change = [update_input_values](auto) { update_input_values(); }; - starting_minute_input->on_change = [update_input_values](auto) { update_input_values(); }; + starting_day_input->on_change = [update_starting_input_values](auto) { update_starting_input_values(); }; + starting_hour_input->on_change = [update_starting_input_values](auto) { update_starting_input_values(); }; + starting_minute_input->on_change = [update_starting_input_values](auto) { update_starting_input_values(); }; + + ending_year_input->on_change = [update_ending_input_values, update_ending_day_range](auto) { + update_ending_input_values(); + update_ending_day_range(); + }; + ending_month_input->on_change = [update_ending_input_values, update_ending_day_range](auto, auto) { + update_ending_input_values(); + update_ending_day_range(); + }; + ending_day_input->on_change = [update_ending_input_values](auto) { update_ending_input_values(); }; + ending_hour_input->on_change = [update_ending_input_values](auto) { update_ending_input_values(); }; + ending_minute_input->on_change = [update_ending_input_values](auto) { update_ending_input_values(); }; } ErrorOr AddEventDialog::add_event_to_calendar() diff --git a/Userland/Applications/Calendar/AddEventDialog.gml b/Userland/Applications/Calendar/AddEventDialog.gml index 49a6195e059..939acbb6e52 100644 --- a/Userland/Applications/Calendar/AddEventDialog.gml +++ b/Userland/Applications/Calendar/AddEventDialog.gml @@ -6,13 +6,11 @@ @GUI::Widget { fill_with_background_color: true - fixed_height: 45 - layout: @GUI::VerticalBoxLayout { - spacing: 4 - } + fixed_height: 20 + layout: @GUI::HorizontalBoxLayout {} @GUI::Label { - text: "Add title & date:" + text: "Title:" text_alignment: "CenterLeft" fixed_height: 14 font_weight: "Bold" @@ -20,7 +18,7 @@ @GUI::TextBox { name: "event_title_textbox" - fixed_height: 20 + fixed_size: [310, 20] } } @@ -31,6 +29,13 @@ spacing: 4 } + @GUI::Label { + text: "Start:" + text_alignment: "CenterLeft" + fixed_height: 14 + font_weight: "Bold" + } + @GUI::ComboBox { name: "start_month" model_only: true @@ -49,14 +54,6 @@ min: 0 max: 9999 } - } - - @GUI::Widget { - fill_with_background_color: true - fixed_height: 25 - layout: @GUI::HorizontalBoxLayout { - spacing: 4 - } @GUI::SpinBox { name: "start_hour" @@ -79,6 +76,60 @@ } } + @GUI::Widget { + fill_with_background_color: true + fixed_height: 25 + layout: @GUI::HorizontalBoxLayout { + spacing: 4 + } + + @GUI::Label { + text: "End:" + text_alignment: "CenterLeft" + fixed_height: 14 + font_weight: "Bold" + } + + @GUI::ComboBox { + name: "end_month" + model_only: true + fixed_size: [50, 20] + } + + @GUI::SpinBox { + name: "end_day" + fixed_size: [40, 20] + min: 1 + } + + @GUI::SpinBox { + name: "end_year" + fixed_size: [55, 20] + min: 0 + max: 9999 + } + + @GUI::SpinBox { + name: "end_hour" + fixed_size: [50, 20] + min: 1 + max: 12 + } + + @GUI::SpinBox { + name: "end_minute" + fixed_size: [40, 20] + min: 1 + max: 59 + } + + @GUI::ComboBox { + name: "end_meridiem" + model_only: true + fixed_size: [55, 20] + } + } + @GUI::Layout::Spacer {} @GUI::Widget {