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

This patch adds a new add_tab() function in GUI::SettingsWindow that
takes an already created NonnullRefPtr<Tab> 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 SettingsWindow.
This commit is contained in:
Baitinq 2022-12-15 01:54:39 +01:00 committed by Sam Atkins
parent 2693745336
commit 27a1798dd9
Notes: sideshowbarker 2024-07-17 04:01:41 +09:00

View file

@ -55,6 +55,15 @@ public:
return tab;
}
ErrorOr<void> add_tab(NonnullRefPtr<Tab> const& tab, DeprecatedString title, StringView id)
{
tab->set_title(move(title));
TRY(m_tab_widget->try_add_widget(*tab));
TRY(m_tabs.try_set(id, tab));
tab->set_settings_window(*this);
return {};
}
Optional<NonnullRefPtr<Tab>> get_tab(StringView id) const;
void set_active_tab(StringView id);