mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-08 23:42:53 +03:00
ClockWidget: Deduplicate logic for updating calendar buttons
This commit is contained in:
parent
9a1018389c
commit
28b5438395
Notes:
sideshowbarker
2024-07-17 01:12:07 +09:00
Author: https://github.com/implicitfield Commit: https://github.com/SerenityOS/serenity/commit/28b5438395 Pull-request: https://github.com/SerenityOS/serenity/pull/19513 Reviewed-by: https://github.com/alimpfard
@ -54,10 +54,7 @@ ClockWidget::ClockWidget()
|
||||
m_prev_date->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
m_prev_date->on_click = [&](auto) {
|
||||
m_calendar->show_previous_date();
|
||||
if (m_calendar->mode() == GUI::Calendar::Year)
|
||||
m_selected_calendar_button->set_text(m_calendar->formatted_date(GUI::Calendar::YearOnly).release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
m_selected_calendar_button->set_text(m_calendar->formatted_date().release_value_but_fixme_should_propagate_errors());
|
||||
update_selected_calendar_button();
|
||||
};
|
||||
|
||||
m_selected_calendar_button = navigation_container.add<GUI::Button>();
|
||||
@ -65,10 +62,7 @@ ClockWidget::ClockWidget()
|
||||
m_selected_calendar_button->set_fixed_height(24);
|
||||
m_selected_calendar_button->on_click = [&](auto) {
|
||||
m_calendar->toggle_mode();
|
||||
if (m_calendar->mode() == GUI::Calendar::Year)
|
||||
m_selected_calendar_button->set_text(m_calendar->formatted_date(GUI::Calendar::YearOnly).release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
m_selected_calendar_button->set_text(m_calendar->formatted_date().release_value_but_fixme_should_propagate_errors());
|
||||
update_selected_calendar_button();
|
||||
};
|
||||
|
||||
m_next_date = navigation_container.add<GUI::Button>();
|
||||
@ -77,10 +71,7 @@ ClockWidget::ClockWidget()
|
||||
m_next_date->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
m_next_date->on_click = [&](auto) {
|
||||
m_calendar->show_next_date();
|
||||
if (m_calendar->mode() == GUI::Calendar::Year)
|
||||
m_selected_calendar_button->set_text(m_calendar->formatted_date(GUI::Calendar::YearOnly).release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
m_selected_calendar_button->set_text(m_calendar->formatted_date().release_value_but_fixme_should_propagate_errors());
|
||||
update_selected_calendar_button();
|
||||
};
|
||||
|
||||
auto& separator1 = root_container->add<GUI::HorizontalSeparator>();
|
||||
@ -212,4 +203,12 @@ void ClockWidget::jump_to_current_date()
|
||||
m_selected_calendar_button->set_text(m_calendar->formatted_date().release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
||||
void ClockWidget::update_selected_calendar_button()
|
||||
{
|
||||
if (m_calendar->mode() == GUI::Calendar::Year)
|
||||
m_selected_calendar_button->set_text(m_calendar->formatted_date(GUI::Calendar::YearOnly).release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
m_selected_calendar_button->set_text(m_calendar->formatted_date().release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ private:
|
||||
void position_calendar_window();
|
||||
void jump_to_current_date();
|
||||
|
||||
void update_selected_calendar_button();
|
||||
|
||||
DeprecatedString m_time_format;
|
||||
RefPtr<GUI::Window> m_calendar_window;
|
||||
RefPtr<GUI::Calendar> m_calendar;
|
||||
|
Loading…
Reference in New Issue
Block a user