summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorKarol Kosek <krkk@serenityos.org>2023-03-10 18:40:34 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-16 09:58:42 +0100
commit3805e4e3a9c102779420ed91342701487fee9979 (patch)
tree23ca2658d870ad1a2ae1587b77d4c86b8d7768f1 /Userland/Libraries/LibGUI
parent858e55b6531d6c44020271e5c93c88e22c7c3399 (diff)
downloadserenity-3805e4e3a9c102779420ed91342701487fee9979.zip
LibGUI+HackStudio+PixelPaint: Port Widget title to the new String
I had to add a set_title(String) helper function for ImageEditor because TabWidget requires it. This is a temporary fix and will be handled in subsequent commit.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/SettingsWindow.h2
-rw-r--r--Userland/Libraries/LibGUI/TabWidget.cpp2
-rw-r--r--Userland/Libraries/LibGUI/TabWidget.h6
-rw-r--r--Userland/Libraries/LibGUI/Widget.cpp6
-rw-r--r--Userland/Libraries/LibGUI/Widget.h7
5 files changed, 12 insertions, 11 deletions
diff --git a/Userland/Libraries/LibGUI/SettingsWindow.h b/Userland/Libraries/LibGUI/SettingsWindow.h
index 8bff81d12e..fa6c65732a 100644
--- a/Userland/Libraries/LibGUI/SettingsWindow.h
+++ b/Userland/Libraries/LibGUI/SettingsWindow.h
@@ -57,7 +57,7 @@ public:
ErrorOr<void> add_tab(NonnullRefPtr<Tab> const& tab, DeprecatedString title, StringView id)
{
- tab->set_title(move(title));
+ tab->set_title(TRY(String::from_deprecated_string(title)));
TRY(m_tab_widget->try_add_widget(*tab));
TRY(m_tabs.try_set(id, tab));
tab->set_settings_window(*this);
diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp
index e4a54b330d..d01f9abac9 100644
--- a/Userland/Libraries/LibGUI/TabWidget.cpp
+++ b/Userland/Libraries/LibGUI/TabWidget.cpp
@@ -53,7 +53,7 @@ TabWidget::TabWidget()
ErrorOr<void> TabWidget::try_add_widget(Widget& widget)
{
- TRY(m_tabs.try_append({ widget.title(), nullptr, &widget, false }));
+ TRY(m_tabs.try_append({ widget.title().to_deprecated_string(), nullptr, &widget, false }));
TRY(try_add_child(widget));
update_focus_policy();
if (on_tab_count_change)
diff --git a/Userland/Libraries/LibGUI/TabWidget.h b/Userland/Libraries/LibGUI/TabWidget.h
index 9e18e51403..0b41cf3b0b 100644
--- a/Userland/Libraries/LibGUI/TabWidget.h
+++ b/Userland/Libraries/LibGUI/TabWidget.h
@@ -59,7 +59,7 @@ public:
ErrorOr<NonnullRefPtr<T>> try_add_tab(DeprecatedString title, Args&&... args)
{
auto t = TRY(T::try_create(forward<Args>(args)...));
- t->set_title(move(title));
+ t->set_title(TRY(String::from_deprecated_string(title)));
TRY(try_add_widget(*t));
return *t;
}
@@ -68,14 +68,14 @@ public:
T& add_tab(DeprecatedString title, Args&&... args)
{
auto t = T::construct(forward<Args>(args)...);
- t->set_title(move(title));
+ t->set_title(String::from_deprecated_string(title).release_value_but_fixme_should_propagate_errors());
add_widget(*t);
return *t;
}
ErrorOr<void> add_tab(NonnullRefPtr<Widget> const& tab, DeprecatedString title)
{
- tab->set_title(move(title));
+ tab->set_title(TRY(String::from_deprecated_string(title)));
TRY(try_add_widget(*tab));
return {};
}
diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp
index 5b5473009f..2edf936494 100644
--- a/Userland/Libraries/LibGUI/Widget.cpp
+++ b/Userland/Libraries/LibGUI/Widget.cpp
@@ -76,7 +76,7 @@ Widget::Widget()
REGISTER_INT_PROPERTY("font_size", m_font->presentation_size, set_font_size);
REGISTER_FONT_WEIGHT_PROPERTY("font_weight", m_font->weight, set_font_weight);
- REGISTER_DEPRECATED_STRING_PROPERTY("title", title, set_title);
+ REGISTER_STRING_PROPERTY("title", title, set_title);
register_property(
"font_type", [this] { return m_font->is_fixed_width() ? "FixedWidth" : "Normal"; },
@@ -1048,7 +1048,7 @@ void Widget::set_palette(Palette& palette)
update();
}
-void Widget::set_title(DeprecatedString title)
+void Widget::set_title(String title)
{
m_title = move(title);
layout_relevant_change_occurred();
@@ -1057,7 +1057,7 @@ void Widget::set_title(DeprecatedString title)
parent_widget()->update();
}
-DeprecatedString Widget::title() const
+String Widget::title() const
{
return m_title;
}
diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h
index f49eea7db1..0e2fd65781 100644
--- a/Userland/Libraries/LibGUI/Widget.h
+++ b/Userland/Libraries/LibGUI/Widget.h
@@ -11,6 +11,7 @@
#include <AK/JsonObject.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Optional.h>
+#include <AK/String.h>
#include <AK/Variant.h>
#include <LibCore/Object.h>
#include <LibCore/Timer.h>
@@ -334,8 +335,8 @@ public:
Gfx::Palette palette() const;
void set_palette(Gfx::Palette&);
- DeprecatedString title() const;
- void set_title(DeprecatedString);
+ String title() const;
+ void set_title(String);
Margins const& grabbable_margins() const { return m_grabbable_margins; }
void set_grabbable_margins(Margins const&);
@@ -458,7 +459,7 @@ private:
bool m_default_font { true };
NonnullRefPtr<Gfx::PaletteImpl> m_palette;
- DeprecatedString m_title { DeprecatedString::empty() };
+ String m_title;
WeakPtr<Widget> m_focus_proxy;
Vector<WeakPtr<Widget>> m_focus_delegators;