From 5fed25ca9aa014372ccfbb79accb49663fc449e2 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Fri, 10 Mar 2023 20:04:43 +0100 Subject: PixelPaint: Port ImageEditor title to new string --- Userland/Applications/PixelPaint/ImageEditor.cpp | 8 ++++---- Userland/Applications/PixelPaint/ImageEditor.h | 9 ++++----- Userland/Applications/PixelPaint/MainWidget.cpp | 12 ++++++------ 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'Userland/Applications/PixelPaint') diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 74056c1104..c87690e5f7 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -30,7 +30,7 @@ constexpr int marching_ant_length = 4; ImageEditor::ImageEditor(NonnullRefPtr image) : m_image(move(image)) - , m_title("Untitled") + , m_title("Untitled"_string.release_value_but_fixme_should_propagate_errors()) , m_gui_event_loop(Core::EventLoop::current()) { set_focus_policy(GUI::FocusPolicy::StrongFocus); @@ -103,7 +103,7 @@ bool ImageEditor::redo() return true; } -void ImageEditor::set_title(DeprecatedString title) +void ImageEditor::set_title(String title) { m_title = move(title); if (on_title_change) @@ -113,7 +113,7 @@ void ImageEditor::set_title(DeprecatedString title) void ImageEditor::set_path(DeprecatedString path) { m_path = move(path); - set_title(LexicalPath::title(m_path)); + set_title(String::from_deprecated_string(LexicalPath::title(m_path)).release_value_but_fixme_should_propagate_errors()); } void ImageEditor::set_modified(DeprecatedString action_text) @@ -761,7 +761,7 @@ void ImageEditor::save_project() void ImageEditor::save_project_as() { - auto response = FileSystemAccessClient::Client::the().save_file(window(), m_title, "pp"); + auto response = FileSystemAccessClient::Client::the().save_file(window(), m_title.to_deprecated_string(), "pp"); if (response.is_error()) return; auto file = response.release_value(); diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index 4b226993cd..c8228fc2aa 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -52,9 +52,8 @@ public: DeprecatedString const& path() const { return m_path; } void set_path(DeprecatedString); - DeprecatedString const& title() const { return m_title; } - void set_title(DeprecatedString); - void set_title(String const& title) { set_title(title.to_deprecated_string()); } + String const& title() const { return m_title; } + void set_title(String); void add_guide(NonnullRefPtr guide) { m_guides.append(guide); } void remove_guide(Guide const& guide) @@ -83,7 +82,7 @@ public: Function on_active_layer_change; - Function on_title_change; + Function on_title_change; Function on_image_mouse_position_change; @@ -170,7 +169,7 @@ private: GUI::UndoStack m_undo_stack; DeprecatedString m_path; - DeprecatedString m_title; + String m_title; Vector> m_guides; bool m_show_guides { true }; diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index 31b8300e1c..47da838a65 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -173,7 +173,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto& editor = create_new_editor(*image); auto image_title = dialog->image_name().trim_whitespace(); - editor.set_title(image_title.is_empty() ? "Untitled" : image_title); + editor.set_title((image_title.is_empty() ? "Untitled"_string : String::from_deprecated_string(image_title)).release_value_but_fixme_should_propagate_errors()); editor.set_unmodified(); m_histogram_widget->set_image(image); @@ -223,7 +223,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) "As &BMP", [&](auto&) { auto* editor = current_image_editor(); VERIFY(editor); - auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title(), "bmp"); + auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title().to_deprecated_string(), "bmp"); if (response.is_error()) return; auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?"sv, "Preserve transparency?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); @@ -238,7 +238,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto* editor = current_image_editor(); VERIFY(editor); // TODO: fix bmp on line below? - auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title(), "png"); + auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title().to_deprecated_string(), "png"); if (response.is_error()) return; auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?"sv, "Preserve transparency?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); @@ -252,7 +252,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) "As &QOI", [&](auto&) { auto* editor = current_image_editor(); VERIFY(editor); - auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title(), "qoi"); + auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title().to_deprecated_string(), "qoi"); if (response.is_error()) return; auto result = editor->image().export_qoi_to_file(response.value().release_stream()); @@ -1196,7 +1196,7 @@ ErrorOr MainWidget::create_default_image() m_layer_list_widget->set_image(image); auto& editor = create_new_editor(*image); - editor.set_title("Untitled"); + editor.set_title(TRY("Untitled"_string)); editor.set_active_layer(bg_layer); editor.set_unmodified(); @@ -1215,7 +1215,7 @@ ErrorOr MainWidget::create_image_from_clipboard() image->add_layer(*layer); auto& editor = create_new_editor(*image); - editor.set_title("Untitled"); + editor.set_title(TRY("Untitled"_string)); m_layer_list_widget->set_image(image); m_layer_list_widget->set_selected_layer(layer); -- cgit v1.2.3