diff --git a/Userland/DevTools/GMLPlayground/MainWidget.cpp b/Userland/DevTools/GMLPlayground/MainWidget.cpp index b96d99f8f34..02e854e6565 100644 --- a/Userland/DevTools/GMLPlayground/MainWidget.cpp +++ b/Userland/DevTools/GMLPlayground/MainWidget.cpp @@ -90,7 +90,7 @@ ErrorOr> MainWidget::try_create(GUI::Icon const& icon) main_widget->m_editor->on_change = [main_widget = main_widget.ptr()] { main_widget->m_preview->remove_all_children(); // FIXME: Parsing errors happen while the user is typing. What should we do about them? - (void)main_widget->m_preview->load_from_gml(main_widget->m_editor->text(), [](DeprecatedString const& class_name) -> ErrorOr> { + (void)main_widget->m_preview->load_from_gml(main_widget->m_editor->text(), [](StringView class_name) -> ErrorOr> { return UnregisteredWidget::try_create(class_name); }); }; diff --git a/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp b/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp index 54ab83cd21b..0628e49dcb1 100644 --- a/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp +++ b/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp @@ -28,7 +28,7 @@ void GMLPreviewWidget::load_gml(DeprecatedString const& gml) } // FIXME: Parsing errors happen while the user is typing. What should we do about them? - (void)load_from_gml(gml, [](DeprecatedString const& name) -> ErrorOr> { + (void)load_from_gml(gml, [](StringView name) -> ErrorOr> { return GUI::Label::try_create(TRY(String::formatted("{} is not registered as a GML element!", name))); }); diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp index 418049b73c0..961eb6f004e 100644 --- a/Userland/Libraries/LibGUI/Widget.cpp +++ b/Userland/Libraries/LibGUI/Widget.cpp @@ -57,7 +57,7 @@ Widget::Widget() REGISTER_BOOL_PROPERTY("visible", is_visible, set_visible); REGISTER_BOOL_PROPERTY("focused", is_focused, set_focus); REGISTER_BOOL_PROPERTY("enabled", is_enabled, set_enabled); - REGISTER_DEPRECATED_STRING_PROPERTY("tooltip", tooltip_deprecated, set_tooltip_deprecated); + REGISTER_STRING_PROPERTY("tooltip", tooltip, set_tooltip); REGISTER_UI_SIZE_PROPERTY("min_size", min_size, set_min_size); REGISTER_READONLY_UI_SIZE_PROPERTY("effective_min_size", effective_min_size); @@ -82,7 +82,7 @@ Widget::Widget() REGISTER_INT_PROPERTY("x", x, set_x); REGISTER_INT_PROPERTY("y", y, set_y); - REGISTER_DEPRECATED_STRING_PROPERTY("font", m_font->family, set_font_family); + REGISTER_STRING_PROPERTY("font", font_family, set_font_family); REGISTER_INT_PROPERTY("font_size", m_font->presentation_size, set_font_size); REGISTER_FONT_WEIGHT_PROPERTY("font_weight", m_font->weight, set_font_weight); @@ -819,9 +819,9 @@ void Widget::set_font(Gfx::Font const* font) update(); } -void Widget::set_font_family(DeprecatedString const& family) +void Widget::set_font_family(String const& family) { - set_font(Gfx::FontDatabase::the().get(family, m_font->presentation_size(), m_font->weight(), m_font->width(), m_font->slope())); + set_font(Gfx::FontDatabase::the().get(family.to_deprecated_string(), m_font->presentation_size(), m_font->weight(), m_font->width(), m_font->slope())); } void Widget::set_font_size(unsigned size) @@ -1108,6 +1108,11 @@ Gfx::IntRect Widget::relative_non_grabbable_rect() const } void Widget::set_tooltip_deprecated(DeprecatedString tooltip) +{ + set_tooltip(String::from_deprecated_string(move(tooltip)).release_value_but_fixme_should_propagate_errors()); +} + +void Widget::set_tooltip(String tooltip) { m_tooltip = move(tooltip); if (Application::the()->tooltip_source_widget() == this) @@ -1117,7 +1122,7 @@ void Widget::set_tooltip_deprecated(DeprecatedString tooltip) void Widget::show_or_hide_tooltip() { if (has_tooltip()) - Application::the()->show_tooltip(m_tooltip, this); + Application::the()->show_tooltip(m_tooltip.to_deprecated_string(), this); else Application::the()->hide_tooltip(); } @@ -1140,7 +1145,7 @@ void Widget::set_override_cursor(AK::Variant Widget::load_from_gml(StringView gml_string) { - return load_from_gml(gml_string, [](DeprecatedString const& class_name) -> ErrorOr> { + return load_from_gml(gml_string, [](StringView class_name) -> ErrorOr> { dbgln("Class '{}' not registered", class_name); return Error::from_string_literal("Class not registered"); }); @@ -1265,4 +1270,9 @@ void Widget::add_spacer() return layout()->add_spacer(); } +String Widget::font_family() const +{ + return String::from_deprecated_string(m_font->family()).release_value_but_fixme_should_propagate_errors(); +} + } diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index 3da9809f814..0b0b5ece2db 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -161,7 +161,9 @@ public: virtual bool is_visible_for_timer_purposes() const override; bool has_tooltip() const { return !m_tooltip.is_empty(); } - DeprecatedString tooltip_deprecated() const { return m_tooltip; } + String tooltip() const { return m_tooltip; } + void set_tooltip(String tooltip); + DeprecatedString tooltip_deprecated() const { return tooltip().to_deprecated_string(); } void set_tooltip_deprecated(DeprecatedString); bool is_auto_focusable() const { return m_auto_focusable; } @@ -283,7 +285,7 @@ public: void set_font(Gfx::Font const*); void set_font(Gfx::Font const& font) { set_font(&font); } - void set_font_family(DeprecatedString const&); + void set_font_family(String const&); void set_font_size(unsigned); void set_font_weight(unsigned); void set_font_fixed_width(bool); @@ -343,7 +345,7 @@ public: AK::Variant> const& override_cursor() const { return m_override_cursor; } void set_override_cursor(AK::Variant>); - using UnregisteredChildHandler = ErrorOr>(DeprecatedString const&); + using UnregisteredChildHandler = ErrorOr>(StringView); ErrorOr load_from_gml(StringView); ErrorOr load_from_gml(StringView, UnregisteredChildHandler); @@ -421,6 +423,9 @@ private: int dummy_fixed_height() { return 0; } Gfx::IntSize dummy_fixed_size() { return {}; } + // HACK: Used as property getter for the font_family property, can be removed when Font is migrated from DeprecatedString. + String font_family() const; + Window* m_window { nullptr }; RefPtr m_layout; @@ -428,7 +433,7 @@ private: Gfx::ColorRole m_background_role; Gfx::ColorRole m_foreground_role; NonnullRefPtr m_font; - DeprecatedString m_tooltip; + String m_tooltip; UISize m_min_size { SpecialDimension::Shrink }; UISize m_max_size { SpecialDimension::Grow };