diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-27 17:30:46 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-28 08:10:53 +0100 |
commit | 8359975ff373c2af36de69cabf2b1501b4bb180b (patch) | |
tree | 08850600a137fd46119df3a8dc503e613fa40663 | |
parent | 8a11e986e5709299fe4711d81dc4a0f13dd1c6d9 (diff) | |
download | serenity-8359975ff373c2af36de69cabf2b1501b4bb180b.zip |
LibGUI: Make GUI::TabWidget tab creation APIs take String
Ultimately we'd like the caller to provide a String if possible (instead
of a StringView) as we're going to end up storing it.
-rw-r--r-- | Userland/Libraries/LibGUI/TabWidget.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/TabWidget.h | 12 |
2 files changed, 10 insertions, 10 deletions
diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp index d2c4136183..e9499542ad 100644 --- a/Userland/Libraries/LibGUI/TabWidget.cpp +++ b/Userland/Libraries/LibGUI/TabWidget.cpp @@ -44,9 +44,9 @@ TabWidget::~TabWidget() { } -ErrorOr<void> TabWidget::try_add_widget(StringView title, Widget& widget) +ErrorOr<void> TabWidget::try_add_widget(String title, Widget& widget) { - m_tabs.append({ title, nullptr, &widget }); + m_tabs.append({ move(title), nullptr, &widget }); add_child(widget); update_focus_policy(); if (on_tab_count_change) @@ -54,9 +54,9 @@ ErrorOr<void> TabWidget::try_add_widget(StringView title, Widget& widget) return {}; } -void TabWidget::add_widget(StringView title, Widget& widget) +void TabWidget::add_widget(String title, Widget& widget) { - MUST(try_add_widget(title, widget)); + MUST(try_add_widget(move(title), widget)); } void TabWidget::remove_widget(Widget& widget) diff --git a/Userland/Libraries/LibGUI/TabWidget.h b/Userland/Libraries/LibGUI/TabWidget.h index ac0d5402d0..2addcc729b 100644 --- a/Userland/Libraries/LibGUI/TabWidget.h +++ b/Userland/Libraries/LibGUI/TabWidget.h @@ -36,24 +36,24 @@ public: GUI::Margins const& container_margins() const { return m_container_margins; } void set_container_margins(GUI::Margins const&); - ErrorOr<void> try_add_widget(StringView, Widget&); + ErrorOr<void> try_add_widget(String, Widget&); - void add_widget(StringView, Widget&); + void add_widget(String, Widget&); void remove_widget(Widget&); template<class T, class... Args> - ErrorOr<NonnullRefPtr<T>> try_add_tab(StringView title, Args&&... args) + ErrorOr<NonnullRefPtr<T>> try_add_tab(String title, Args&&... args) { auto t = TRY(T::try_create(forward<Args>(args)...)); - TRY(try_add_widget(title, *t)); + TRY(try_add_widget(move(title), *t)); return *t; } template<class T, class... Args> - T& add_tab(StringView title, Args&&... args) + T& add_tab(String title, Args&&... args) { auto t = T::construct(forward<Args>(args)...); - add_widget(title, *t); + add_widget(move(title), *t); return *t; } |