LibGUI: Add GUI::TabWidget::add_tab() that takes a constructed tab

This patch adds a new add_tab() function in GUI::TabWidget that takes
an already created NonnullRefPtr<Widget> object. This allows us to
handle errors while creating the Tab object and then pass it to this
function to actually add the object to the TabWidget.
This commit is contained in:
Baitinq 2022-12-16 01:49:54 +01:00 committed by Andreas Kling
parent c355e9692d
commit 61789de11d
Notes: sideshowbarker 2024-07-17 08:36:27 +09:00

View File

@ -73,6 +73,13 @@ public:
return *t;
}
ErrorOr<void> add_tab(NonnullRefPtr<Widget> const& tab, DeprecatedString title)
{
tab->set_title(move(title));
TRY(try_add_widget(*tab));
return {};
}
void remove_tab(Widget& tab) { remove_widget(tab); }
void remove_all_tabs_except(Widget& tab);