mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Calendar: Add inputs to change event end date/time
This commit is contained in:
parent
a7c3d39bab
commit
e5c9d7ce26
Notes:
sideshowbarker
2024-07-17 08:38:37 +09:00
Author: https://github.com/lanmonster Commit: https://github.com/SerenityOS/serenity/commit/e5c9d7ce26 Pull-request: https://github.com/SerenityOS/serenity/pull/21468
2 changed files with 121 additions and 23 deletions
|
@ -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_end_date_time(Core::DateTime::from_timestamp(date_time.timestamp() + (15 * 60)))
|
||||||
, m_event_manager(event_manager)
|
, m_event_manager(event_manager)
|
||||||
{
|
{
|
||||||
resize(158, 130);
|
resize(360, 140);
|
||||||
set_title("Add Event");
|
set_title("Add Event");
|
||||||
set_resizable(false);
|
set_resizable(false);
|
||||||
set_icon(parent_window->icon());
|
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_model(MeridiemListModel::create());
|
||||||
starting_meridiem_input->set_selected_index(0);
|
starting_meridiem_input->set_selected_index(0);
|
||||||
|
|
||||||
|
auto ending_month_input = widget->find_descendant_of_type_named<GUI::ComboBox>("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<GUI::SpinBox>("end_day");
|
||||||
|
ending_day_input->set_value(m_end_date_time.day());
|
||||||
|
|
||||||
|
auto ending_year_input = widget->find_descendant_of_type_named<GUI::SpinBox>("end_year");
|
||||||
|
ending_year_input->set_value(m_end_date_time.year());
|
||||||
|
|
||||||
|
auto ending_hour_input = widget->find_descendant_of_type_named<GUI::SpinBox>("end_hour");
|
||||||
|
ending_hour_input->set_value(m_end_date_time.hour());
|
||||||
|
|
||||||
|
auto ending_minute_input = widget->find_descendant_of_type_named<GUI::SpinBox>("end_minute");
|
||||||
|
ending_minute_input->set_value(m_end_date_time.minute());
|
||||||
|
|
||||||
|
auto ending_meridiem_input = widget->find_descendant_of_type_named<GUI::ComboBox>("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<GUI::Button>("ok_button");
|
auto ok_button = widget->find_descendant_of_type_named<GUI::Button>("ok_button");
|
||||||
ok_button->on_click = [&](auto) {
|
ok_button->on_click = [&](auto) {
|
||||||
add_event_to_calendar().release_value_but_fixme_should_propagate_errors();
|
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));
|
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 year = starting_year_input->value();
|
||||||
auto month = starting_month_input->selected_index() + 1;
|
auto month = starting_month_input->selected_index() + 1;
|
||||||
auto day = starting_day_input->value();
|
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);
|
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) {
|
auto update_ending_input_values = [=, this]() {
|
||||||
update_input_values();
|
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();
|
update_starting_day_range();
|
||||||
};
|
};
|
||||||
starting_month_input->on_change = [update_input_values, update_starting_day_range](auto, auto) {
|
starting_month_input->on_change = [update_starting_input_values, update_starting_day_range](auto, auto) {
|
||||||
update_input_values();
|
update_starting_input_values();
|
||||||
update_starting_day_range();
|
update_starting_day_range();
|
||||||
};
|
};
|
||||||
starting_day_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_input_values](auto) { update_input_values(); };
|
starting_hour_input->on_change = [update_starting_input_values](auto) { update_starting_input_values(); };
|
||||||
starting_minute_input->on_change = [update_input_values](auto) { update_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<void> AddEventDialog::add_event_to_calendar()
|
ErrorOr<void> AddEventDialog::add_event_to_calendar()
|
||||||
|
|
|
@ -6,13 +6,11 @@
|
||||||
|
|
||||||
@GUI::Widget {
|
@GUI::Widget {
|
||||||
fill_with_background_color: true
|
fill_with_background_color: true
|
||||||
fixed_height: 45
|
fixed_height: 20
|
||||||
layout: @GUI::VerticalBoxLayout {
|
layout: @GUI::HorizontalBoxLayout {}
|
||||||
spacing: 4
|
|
||||||
}
|
|
||||||
|
|
||||||
@GUI::Label {
|
@GUI::Label {
|
||||||
text: "Add title & date:"
|
text: "Title:"
|
||||||
text_alignment: "CenterLeft"
|
text_alignment: "CenterLeft"
|
||||||
fixed_height: 14
|
fixed_height: 14
|
||||||
font_weight: "Bold"
|
font_weight: "Bold"
|
||||||
|
@ -20,7 +18,7 @@
|
||||||
|
|
||||||
@GUI::TextBox {
|
@GUI::TextBox {
|
||||||
name: "event_title_textbox"
|
name: "event_title_textbox"
|
||||||
fixed_height: 20
|
fixed_size: [310, 20]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +29,13 @@
|
||||||
spacing: 4
|
spacing: 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GUI::Label {
|
||||||
|
text: "Start:"
|
||||||
|
text_alignment: "CenterLeft"
|
||||||
|
fixed_height: 14
|
||||||
|
font_weight: "Bold"
|
||||||
|
}
|
||||||
|
|
||||||
@GUI::ComboBox {
|
@GUI::ComboBox {
|
||||||
name: "start_month"
|
name: "start_month"
|
||||||
model_only: true
|
model_only: true
|
||||||
|
@ -49,14 +54,6 @@
|
||||||
min: 0
|
min: 0
|
||||||
max: 9999
|
max: 9999
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@GUI::Widget {
|
|
||||||
fill_with_background_color: true
|
|
||||||
fixed_height: 25
|
|
||||||
layout: @GUI::HorizontalBoxLayout {
|
|
||||||
spacing: 4
|
|
||||||
}
|
|
||||||
|
|
||||||
@GUI::SpinBox {
|
@GUI::SpinBox {
|
||||||
name: "start_hour"
|
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::Layout::Spacer {}
|
||||||
|
|
||||||
@GUI::Widget {
|
@GUI::Widget {
|
||||||
|
|
Loading…
Reference in a new issue