From 27a1798dd9ebb87235d8d7cc5aa708020ddfc422 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Thu, 15 Dec 2022 01:54:39 +0100 Subject: [PATCH] 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 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. --- Userland/Libraries/LibGUI/SettingsWindow.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Userland/Libraries/LibGUI/SettingsWindow.h b/Userland/Libraries/LibGUI/SettingsWindow.h index c8e8f016ef..8bff81d12e 100644 --- a/Userland/Libraries/LibGUI/SettingsWindow.h +++ b/Userland/Libraries/LibGUI/SettingsWindow.h @@ -55,6 +55,15 @@ public: return tab; } + ErrorOr add_tab(NonnullRefPtr 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> get_tab(StringView id) const; void set_active_tab(StringView id);