From 1a30439b11d16726aa1b2fe54c0115ea27d9edcf Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Wed, 10 May 2023 17:00:20 -0400 Subject: [PATCH] FontEditor: Port some instances of DeprecatedString --- Userland/Applications/FontEditor/MainWidget.cpp | 17 +++++++++-------- Userland/Applications/FontEditor/MainWidget.h | 8 ++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index 027d6d32c4..146855d882 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -9,6 +9,7 @@ #include "GlyphEditorWidget.h" #include "NewFontDialog.h" #include +#include #include #include #include @@ -125,16 +126,16 @@ ErrorOr MainWidget::create_actions() if (m_path.is_empty()) return m_save_as_action->activate(); - auto response = FileSystemAccessClient::Client::the().request_file(window(), m_path, Core::File::OpenMode::Truncate | Core::File::OpenMode::Write); + auto response = FileSystemAccessClient::Client::the().request_file(window(), m_path.to_deprecated_string(), Core::File::OpenMode::Truncate | Core::File::OpenMode::Write); if (response.is_error()) return; if (auto result = save_file(m_path, response.value().release_stream()); result.is_error()) - show_error(result.release_error(), "Saving"sv, LexicalPath { m_path }.basename()); + show_error(result.release_error(), "Saving"sv, LexicalPath { m_path.to_deprecated_string() }.basename()); }); m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) { - LexicalPath lexical_path(m_path.is_empty() ? "Untitled.font" : m_path); + LexicalPath lexical_path(m_path.is_empty() ? "Untitled.font"sv : m_path); auto response = FileSystemAccessClient::Client::the().save_file(window(), lexical_path.title(), lexical_path.extension()); if (response.is_error()) @@ -604,7 +605,7 @@ MainWidget::MainWidget() }; } -ErrorOr MainWidget::initialize(DeprecatedString const& path, RefPtr&& edited_font) +ErrorOr MainWidget::initialize(StringView path, RefPtr&& edited_font) { if (m_edited_font == edited_font) return {}; @@ -615,7 +616,7 @@ ErrorOr MainWidget::initialize(DeprecatedString const& path, RefPtr(selection.start(), selection.size(), m_glyph_map_widget->active_glyph(), *edited_font, *m_glyph_map_widget)); m_undo_stack->clear(); - m_path = path; + m_path = TRY(String::from_utf8(path)); m_edited_font = edited_font; if (m_preview_label) @@ -734,12 +735,12 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) return {}; } -ErrorOr MainWidget::save_file(DeprecatedString const& path, NonnullOwnPtr file) +ErrorOr MainWidget::save_file(StringView path, NonnullOwnPtr file) { auto masked_font = TRY(m_edited_font->masked_character_set()); TRY(masked_font->write_to_file(move(file))); - m_path = path; + m_path = TRY(String::from_utf8(path)); m_undo_stack->set_current_unmodified(); window()->set_modified(false); update_title(); @@ -796,7 +797,7 @@ ErrorOr MainWidget::open_file(StringView path, NonnullOwnPtr f { auto mapped_file = TRY(Core::MappedFile::map_from_file(move(file), path)); auto unmasked_font = TRY(TRY(Gfx::BitmapFont::try_load_from_mapped_file(mapped_file))->unmasked_character_set()); - TRY(initialize(path.to_deprecated_string(), move(unmasked_font))); + TRY(initialize(path, move(unmasked_font))); return {}; } diff --git a/Userland/Applications/FontEditor/MainWidget.h b/Userland/Applications/FontEditor/MainWidget.h index e7460cd374..c3942cfb31 100644 --- a/Userland/Applications/FontEditor/MainWidget.h +++ b/Userland/Applications/FontEditor/MainWidget.h @@ -34,15 +34,15 @@ public: virtual ~MainWidget() override = default; - ErrorOr initialize(DeprecatedString const& path, RefPtr&&); + ErrorOr initialize(StringView path, RefPtr&&); ErrorOr initialize_menubar(GUI::Window&); ErrorOr open_file(StringView, NonnullOwnPtr); - ErrorOr save_file(DeprecatedString const&, NonnullOwnPtr); + ErrorOr save_file(StringView, NonnullOwnPtr); bool request_close(); void update_title(); - DeprecatedString const& path() { return m_path; } + String const& path() { return m_path; } Gfx::BitmapFont const& edited_font() { return *m_edited_font; } bool is_showing_font_metadata() { return m_font_metadata; } @@ -160,7 +160,7 @@ private: RefPtr m_preview_textbox; RefPtr m_font_preview_window; - DeprecatedString m_path; + String m_path; Vector m_font_weight_list; Vector m_font_slope_list; Vector m_unicode_block_list;