1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:38:13 +00:00

LibGUI: Replace uses of JsonObject::get_deprecated()/get_ptr()

This commit is contained in:
Sam Atkins 2022-12-21 17:27:41 +00:00 committed by Tim Flynn
parent 4313c17d95
commit 2fce19a451
3 changed files with 10 additions and 8 deletions

View file

@ -56,8 +56,8 @@ ErrorOr<void> CommonLocationsProvider::load_from_json(StringView json_path)
if (!entry_value.is_object())
continue;
auto entry = entry_value.as_object();
auto name = entry.get_deprecated("name"sv).to_deprecated_string();
auto path = entry.get_deprecated("path"sv).to_deprecated_string();
auto name = entry.get_deprecated_string("name"sv).value_or({});
auto path = entry.get_deprecated_string("path"sv).value_or({});
TRY(s_common_locations.try_append({ name, path }));
}

View file

@ -119,12 +119,14 @@ Variant JsonArrayModel::data(ModelIndex const& index, ModelRole role) const
if (role == ModelRole::Display) {
auto& json_field_name = field_spec.json_field_name;
auto data = object.get_deprecated(json_field_name);
auto data = object.get(json_field_name);
if (field_spec.massage_for_display)
return field_spec.massage_for_display(object);
if (data.is_number())
return data;
return object.get_deprecated(json_field_name).to_deprecated_string();
if (!data.has_value())
return "";
if (data->is_number())
return data.value();
return data->to_deprecated_string();
}
if (role == ModelRole::Sort) {

View file

@ -306,9 +306,9 @@ inline auto clamp<GUI::UIDimension>(GUI::UIDimension const& input, GUI::UIDimens
if (!value.is_object()) \
return false; \
auto result_width = GUI::UIDimension::construct_from_json_value( \
value.as_object().get_deprecated("width"sv)); \
value.as_object().get("width"sv).value_or({})); \
auto result_height = GUI::UIDimension::construct_from_json_value( \
value.as_object().get_deprecated("height"sv)); \
value.as_object().get("height"sv).value_or({})); \
if (result_width.has_value() && result_height.has_value()) { \
GUI::UISize size(result_width.value(), result_height.value()); \
setter(size); \