1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:27:45 +00:00

FontEditor: Port some instances of DeprecatedString

This commit is contained in:
thankyouverycool 2023-05-10 17:00:20 -04:00 committed by Andreas Kling
parent 0e276e0458
commit 1a30439b11
2 changed files with 13 additions and 12 deletions

View file

@ -9,6 +9,7 @@
#include "GlyphEditorWidget.h" #include "GlyphEditorWidget.h"
#include "NewFontDialog.h" #include "NewFontDialog.h"
#include <AK/Array.h> #include <AK/Array.h>
#include <AK/String.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <AK/StringUtils.h> #include <AK/StringUtils.h>
#include <Applications/FontEditor/FontEditorWindowGML.h> #include <Applications/FontEditor/FontEditorWindowGML.h>
@ -125,16 +126,16 @@ ErrorOr<void> MainWidget::create_actions()
if (m_path.is_empty()) if (m_path.is_empty())
return m_save_as_action->activate(); 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()) if (response.is_error())
return; return;
if (auto result = save_file(m_path, response.value().release_stream()); result.is_error()) 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&) { 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()); auto response = FileSystemAccessClient::Client::the().save_file(window(), lexical_path.title(), lexical_path.extension());
if (response.is_error()) if (response.is_error())
@ -604,7 +605,7 @@ MainWidget::MainWidget()
}; };
} }
ErrorOr<void> MainWidget::initialize(DeprecatedString const& path, RefPtr<Gfx::BitmapFont>&& edited_font) ErrorOr<void> MainWidget::initialize(StringView path, RefPtr<Gfx::BitmapFont>&& edited_font)
{ {
if (m_edited_font == edited_font) if (m_edited_font == edited_font)
return {}; return {};
@ -615,7 +616,7 @@ ErrorOr<void> MainWidget::initialize(DeprecatedString const& path, RefPtr<Gfx::B
m_undo_selection = TRY(try_make_ref_counted<UndoSelection>(selection.start(), selection.size(), m_glyph_map_widget->active_glyph(), *edited_font, *m_glyph_map_widget)); m_undo_selection = TRY(try_make_ref_counted<UndoSelection>(selection.start(), selection.size(), m_glyph_map_widget->active_glyph(), *edited_font, *m_glyph_map_widget));
m_undo_stack->clear(); m_undo_stack->clear();
m_path = path; m_path = TRY(String::from_utf8(path));
m_edited_font = edited_font; m_edited_font = edited_font;
if (m_preview_label) if (m_preview_label)
@ -734,12 +735,12 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
return {}; return {};
} }
ErrorOr<void> MainWidget::save_file(DeprecatedString const& path, NonnullOwnPtr<Core::File> file) ErrorOr<void> MainWidget::save_file(StringView path, NonnullOwnPtr<Core::File> file)
{ {
auto masked_font = TRY(m_edited_font->masked_character_set()); auto masked_font = TRY(m_edited_font->masked_character_set());
TRY(masked_font->write_to_file(move(file))); TRY(masked_font->write_to_file(move(file)));
m_path = path; m_path = TRY(String::from_utf8(path));
m_undo_stack->set_current_unmodified(); m_undo_stack->set_current_unmodified();
window()->set_modified(false); window()->set_modified(false);
update_title(); update_title();
@ -796,7 +797,7 @@ ErrorOr<void> MainWidget::open_file(StringView path, NonnullOwnPtr<Core::File> f
{ {
auto mapped_file = TRY(Core::MappedFile::map_from_file(move(file), path)); 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()); 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 {}; return {};
} }

View file

@ -34,15 +34,15 @@ public:
virtual ~MainWidget() override = default; virtual ~MainWidget() override = default;
ErrorOr<void> initialize(DeprecatedString const& path, RefPtr<Gfx::BitmapFont>&&); ErrorOr<void> initialize(StringView path, RefPtr<Gfx::BitmapFont>&&);
ErrorOr<void> initialize_menubar(GUI::Window&); ErrorOr<void> initialize_menubar(GUI::Window&);
ErrorOr<void> open_file(StringView, NonnullOwnPtr<Core::File>); ErrorOr<void> open_file(StringView, NonnullOwnPtr<Core::File>);
ErrorOr<void> save_file(DeprecatedString const&, NonnullOwnPtr<Core::File>); ErrorOr<void> save_file(StringView, NonnullOwnPtr<Core::File>);
bool request_close(); bool request_close();
void update_title(); void update_title();
DeprecatedString const& path() { return m_path; } String const& path() { return m_path; }
Gfx::BitmapFont const& edited_font() { return *m_edited_font; } Gfx::BitmapFont const& edited_font() { return *m_edited_font; }
bool is_showing_font_metadata() { return m_font_metadata; } bool is_showing_font_metadata() { return m_font_metadata; }
@ -160,7 +160,7 @@ private:
RefPtr<GUI::TextBox> m_preview_textbox; RefPtr<GUI::TextBox> m_preview_textbox;
RefPtr<GUI::Window> m_font_preview_window; RefPtr<GUI::Window> m_font_preview_window;
DeprecatedString m_path; String m_path;
Vector<String> m_font_weight_list; Vector<String> m_font_weight_list;
Vector<String> m_font_slope_list; Vector<String> m_font_slope_list;
Vector<String> m_unicode_block_list; Vector<String> m_unicode_block_list;