1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:47:34 +00:00

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.
This commit is contained in:
Karol Kosek 2023-03-10 18:40:34 +01:00 committed by Andreas Kling
parent 858e55b653
commit 3805e4e3a9
7 changed files with 15 additions and 13 deletions

View file

@ -54,6 +54,7 @@ public:
DeprecatedString const& title() const { return m_title; }
void set_title(DeprecatedString);
void set_title(String const& title) { set_title(title.to_deprecated_string()); }
void add_guide(NonnullRefPtr<Guide> guide) { m_guides.append(guide); }
void remove_guide(Guide const& guide)

View file

@ -148,7 +148,7 @@ RefPtr<GUI::Menu> DebugInfoWidget::get_context_menu_for_variable(const GUI::Mode
NonnullRefPtr<GUI::Widget> DebugInfoWidget::build_variables_tab()
{
auto variables_widget = GUI::Widget::construct();
variables_widget->set_title("Variables");
variables_widget->set_title("Variables"_string.release_value_but_fixme_should_propagate_errors());
variables_widget->set_layout<GUI::HorizontalBoxLayout>();
m_variables_view = variables_widget->add<GUI::TreeView>();
@ -165,7 +165,7 @@ NonnullRefPtr<GUI::Widget> DebugInfoWidget::build_variables_tab()
NonnullRefPtr<GUI::Widget> DebugInfoWidget::build_registers_tab()
{
auto registers_widget = GUI::Widget::construct();
registers_widget->set_title("Registers");
registers_widget->set_title("Registers"_string.release_value_but_fixme_should_propagate_errors());
registers_widget->set_layout<GUI::HorizontalBoxLayout>();
m_registers_view = registers_widget->add<GUI::TableView>();

View file

@ -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);

View file

@ -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)

View file

@ -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 {};
}

View file

@ -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;
}

View file

@ -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;