From bfc08bc84b7adf0f7eaf8f409e23cc548e179c16 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Sun, 29 Jan 2023 08:59:36 -0500 Subject: [PATCH] Welcome: Replace instances of DeprecatedString with String --- Userland/Applications/Welcome/WelcomeWidget.cpp | 17 ++++++++++------- Userland/Applications/Welcome/WelcomeWidget.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Userland/Applications/Welcome/WelcomeWidget.cpp b/Userland/Applications/Welcome/WelcomeWidget.cpp index 8604012727..42b4bbc3c9 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.cpp +++ b/Userland/Applications/Welcome/WelcomeWidget.cpp @@ -6,6 +6,7 @@ #include "WelcomeWidget.h" #include +#include #include #include #include @@ -33,7 +34,8 @@ ErrorOr WelcomeWidget::create_widgets() TRY(load_from_gml(welcome_window_gml)); m_web_view = find_descendant_of_type_named("web_view"); - m_web_view->load(URL::create_with_file_scheme(DeprecatedString::formatted("{}/README.md", Core::StandardPaths::home_directory()))); + auto path = TRY(String::formatted("{}/README.md", Core::StandardPaths::home_directory())); + m_web_view->load(URL::create_with_file_scheme(path.to_deprecated_string())); m_tip_label = find_descendant_of_type_named("tip_label"); m_tip_frame = find_descendant_of_type_named("tip_frame"); @@ -47,7 +49,7 @@ ErrorOr WelcomeWidget::create_widgets() m_initial_tip_index++; if (m_initial_tip_index >= m_tips.size()) m_initial_tip_index = 0; - m_tip_label->set_text(m_tips[m_initial_tip_index]); + m_tip_label->set_text(m_tips[m_initial_tip_index].to_deprecated_string()); }; m_help_button = find_descendant_of_type_named("help_button"); @@ -77,8 +79,9 @@ ErrorOr WelcomeWidget::create_widgets() }; if (auto result = open_and_parse_tips_file(); result.is_error()) { - auto error = DeprecatedString::formatted("Opening \"{}/tips.txt\" failed: {}", Core::StandardPaths::documents_directory(), result.error()); - m_tip_label->set_text(error); + auto path = TRY(String::formatted("{}/tips.txt", Core::StandardPaths::documents_directory())); + auto error = TRY(String::formatted("Opening \"{}\" failed: {}", path, result.error())); + m_tip_label->set_text(error.to_deprecated_string()); warnln(error); } @@ -89,7 +92,7 @@ ErrorOr WelcomeWidget::create_widgets() ErrorOr WelcomeWidget::open_and_parse_tips_file() { - auto path = DeprecatedString::formatted("{}/tips.txt", Core::StandardPaths::documents_directory()); + auto path = TRY(String::formatted("{}/tips.txt", Core::StandardPaths::documents_directory())); auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file))); Array buffer; @@ -98,7 +101,7 @@ ErrorOr WelcomeWidget::open_and_parse_tips_file() auto line = TRY(buffered_file->read_line(buffer)); if (line.starts_with('#') || line.is_empty()) continue; - m_tips.append(line); + TRY(m_tips.try_append(TRY(String::from_utf8(line)))); } return {}; @@ -110,7 +113,7 @@ void WelcomeWidget::set_random_tip() return; m_initial_tip_index = get_random_uniform(m_tips.size()); - m_tip_label->set_text(m_tips[m_initial_tip_index]); + m_tip_label->set_text(m_tips[m_initial_tip_index].to_deprecated_string()); } void WelcomeWidget::paint_event(GUI::PaintEvent& event) diff --git a/Userland/Applications/Welcome/WelcomeWidget.h b/Userland/Applications/Welcome/WelcomeWidget.h index 945682ba4e..0306b333a3 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.h +++ b/Userland/Applications/Welcome/WelcomeWidget.h @@ -35,5 +35,5 @@ private: RefPtr m_web_view; size_t m_initial_tip_index { 0 }; - Vector m_tips; + Vector m_tips; };