summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint
diff options
context:
space:
mode:
authorKarol Kosek <krkk@serenityos.org>2023-03-10 20:04:43 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-16 09:58:42 +0100
commit5fed25ca9aa014372ccfbb79accb49663fc449e2 (patch)
tree2c55d12b13fd22d5f571db06bf13ed3520af95c0 /Userland/Applications/PixelPaint
parent3805e4e3a9c102779420ed91342701487fee9979 (diff)
downloadserenity-5fed25ca9aa014372ccfbb79accb49663fc449e2.zip
PixelPaint: Port ImageEditor title to new string
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.cpp8
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.h9
-rw-r--r--Userland/Applications/PixelPaint/MainWidget.cpp12
3 files changed, 14 insertions, 15 deletions
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> 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> guide) { m_guides.append(guide); }
void remove_guide(Guide const& guide)
@@ -83,7 +82,7 @@ public:
Function<void(Layer*)> on_active_layer_change;
- Function<void(DeprecatedString const&)> on_title_change;
+ Function<void(String const&)> on_title_change;
Function<void(Gfx::IntPoint)> 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<NonnullRefPtr<Guide>> 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<void> 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<void> 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<void> 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<void> 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<void> 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<void> 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);