mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibGUI: Replace DeprecatedString usage in Widget
This commit is contained in:
parent
d978dd4af8
commit
174d6f1f51
4 changed files with 27 additions and 12 deletions
|
@ -90,7 +90,7 @@ ErrorOr<NonnullRefPtr<MainWidget>> MainWidget::try_create(GUI::Icon const& icon)
|
||||||
main_widget->m_editor->on_change = [main_widget = main_widget.ptr()] {
|
main_widget->m_editor->on_change = [main_widget = main_widget.ptr()] {
|
||||||
main_widget->m_preview->remove_all_children();
|
main_widget->m_preview->remove_all_children();
|
||||||
// FIXME: Parsing errors happen while the user is typing. What should we do about them?
|
// 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<NonnullRefPtr<Core::EventReceiver>> {
|
(void)main_widget->m_preview->load_from_gml(main_widget->m_editor->text(), [](StringView class_name) -> ErrorOr<NonnullRefPtr<Core::EventReceiver>> {
|
||||||
return UnregisteredWidget::try_create(class_name);
|
return UnregisteredWidget::try_create(class_name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -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?
|
// FIXME: Parsing errors happen while the user is typing. What should we do about them?
|
||||||
(void)load_from_gml(gml, [](DeprecatedString const& name) -> ErrorOr<NonnullRefPtr<Core::EventReceiver>> {
|
(void)load_from_gml(gml, [](StringView name) -> ErrorOr<NonnullRefPtr<Core::EventReceiver>> {
|
||||||
return GUI::Label::try_create(TRY(String::formatted("{} is not registered as a GML element!", name)));
|
return GUI::Label::try_create(TRY(String::formatted("{} is not registered as a GML element!", name)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ Widget::Widget()
|
||||||
REGISTER_BOOL_PROPERTY("visible", is_visible, set_visible);
|
REGISTER_BOOL_PROPERTY("visible", is_visible, set_visible);
|
||||||
REGISTER_BOOL_PROPERTY("focused", is_focused, set_focus);
|
REGISTER_BOOL_PROPERTY("focused", is_focused, set_focus);
|
||||||
REGISTER_BOOL_PROPERTY("enabled", is_enabled, set_enabled);
|
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_UI_SIZE_PROPERTY("min_size", min_size, set_min_size);
|
||||||
REGISTER_READONLY_UI_SIZE_PROPERTY("effective_min_size", effective_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("x", x, set_x);
|
||||||
REGISTER_INT_PROPERTY("y", y, set_y);
|
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_INT_PROPERTY("font_size", m_font->presentation_size, set_font_size);
|
||||||
REGISTER_FONT_WEIGHT_PROPERTY("font_weight", m_font->weight, set_font_weight);
|
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();
|
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)
|
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)
|
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);
|
m_tooltip = move(tooltip);
|
||||||
if (Application::the()->tooltip_source_widget() == this)
|
if (Application::the()->tooltip_source_widget() == this)
|
||||||
|
@ -1117,7 +1122,7 @@ void Widget::set_tooltip_deprecated(DeprecatedString tooltip)
|
||||||
void Widget::show_or_hide_tooltip()
|
void Widget::show_or_hide_tooltip()
|
||||||
{
|
{
|
||||||
if (has_tooltip())
|
if (has_tooltip())
|
||||||
Application::the()->show_tooltip(m_tooltip, this);
|
Application::the()->show_tooltip(m_tooltip.to_deprecated_string(), this);
|
||||||
else
|
else
|
||||||
Application::the()->hide_tooltip();
|
Application::the()->hide_tooltip();
|
||||||
}
|
}
|
||||||
|
@ -1140,7 +1145,7 @@ void Widget::set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<
|
||||||
|
|
||||||
ErrorOr<void> Widget::load_from_gml(StringView gml_string)
|
ErrorOr<void> Widget::load_from_gml(StringView gml_string)
|
||||||
{
|
{
|
||||||
return load_from_gml(gml_string, [](DeprecatedString const& class_name) -> ErrorOr<NonnullRefPtr<Core::EventReceiver>> {
|
return load_from_gml(gml_string, [](StringView class_name) -> ErrorOr<NonnullRefPtr<Core::EventReceiver>> {
|
||||||
dbgln("Class '{}' not registered", class_name);
|
dbgln("Class '{}' not registered", class_name);
|
||||||
return Error::from_string_literal("Class not registered");
|
return Error::from_string_literal("Class not registered");
|
||||||
});
|
});
|
||||||
|
@ -1265,4 +1270,9 @@ void Widget::add_spacer()
|
||||||
return layout()->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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,9 @@ public:
|
||||||
virtual bool is_visible_for_timer_purposes() const override;
|
virtual bool is_visible_for_timer_purposes() const override;
|
||||||
|
|
||||||
bool has_tooltip() const { return !m_tooltip.is_empty(); }
|
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);
|
void set_tooltip_deprecated(DeprecatedString);
|
||||||
|
|
||||||
bool is_auto_focusable() const { return m_auto_focusable; }
|
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*);
|
||||||
void set_font(Gfx::Font const& font) { set_font(&font); }
|
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_size(unsigned);
|
||||||
void set_font_weight(unsigned);
|
void set_font_weight(unsigned);
|
||||||
void set_font_fixed_width(bool);
|
void set_font_fixed_width(bool);
|
||||||
|
@ -343,7 +345,7 @@ public:
|
||||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> const& override_cursor() const { return m_override_cursor; }
|
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> const& override_cursor() const { return m_override_cursor; }
|
||||||
void set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>>);
|
void set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>>);
|
||||||
|
|
||||||
using UnregisteredChildHandler = ErrorOr<NonnullRefPtr<Core::EventReceiver>>(DeprecatedString const&);
|
using UnregisteredChildHandler = ErrorOr<NonnullRefPtr<Core::EventReceiver>>(StringView);
|
||||||
ErrorOr<void> load_from_gml(StringView);
|
ErrorOr<void> load_from_gml(StringView);
|
||||||
ErrorOr<void> load_from_gml(StringView, UnregisteredChildHandler);
|
ErrorOr<void> load_from_gml(StringView, UnregisteredChildHandler);
|
||||||
|
|
||||||
|
@ -421,6 +423,9 @@ private:
|
||||||
int dummy_fixed_height() { return 0; }
|
int dummy_fixed_height() { return 0; }
|
||||||
Gfx::IntSize dummy_fixed_size() { return {}; }
|
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 };
|
Window* m_window { nullptr };
|
||||||
RefPtr<Layout> m_layout;
|
RefPtr<Layout> m_layout;
|
||||||
|
|
||||||
|
@ -428,7 +433,7 @@ private:
|
||||||
Gfx::ColorRole m_background_role;
|
Gfx::ColorRole m_background_role;
|
||||||
Gfx::ColorRole m_foreground_role;
|
Gfx::ColorRole m_foreground_role;
|
||||||
NonnullRefPtr<Gfx::Font const> m_font;
|
NonnullRefPtr<Gfx::Font const> m_font;
|
||||||
DeprecatedString m_tooltip;
|
String m_tooltip;
|
||||||
|
|
||||||
UISize m_min_size { SpecialDimension::Shrink };
|
UISize m_min_size { SpecialDimension::Shrink };
|
||||||
UISize m_max_size { SpecialDimension::Grow };
|
UISize m_max_size { SpecialDimension::Grow };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue