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

LibGUI: Add GUI::TabWidget::try_add_tab<T>(...)

This is a fallible variant of add_tab<T>(...) that returns ErrorOr.
This commit is contained in:
Andreas Kling 2021-11-24 13:13:30 +01:00
parent dc47fce2d9
commit 47b6339025
2 changed files with 17 additions and 1 deletions

View file

@ -44,13 +44,19 @@ TabWidget::~TabWidget()
{
}
void TabWidget::add_widget(StringView title, Widget& widget)
ErrorOr<void> TabWidget::try_add_widget(StringView title, Widget& widget)
{
m_tabs.append({ title, nullptr, &widget });
add_child(widget);
update_focus_policy();
if (on_tab_count_change)
on_tab_count_change(m_tabs.size());
return {};
}
void TabWidget::add_widget(StringView title, Widget& widget)
{
MUST(try_add_widget(title, widget));
}
void TabWidget::remove_widget(Widget& widget)