mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
PixelPaint: Port ImageEditor title to new string
This commit is contained in:
parent
3805e4e3a9
commit
5fed25ca9a
3 changed files with 14 additions and 15 deletions
|
@ -30,7 +30,7 @@ constexpr int marching_ant_length = 4;
|
||||||
|
|
||||||
ImageEditor::ImageEditor(NonnullRefPtr<Image> image)
|
ImageEditor::ImageEditor(NonnullRefPtr<Image> image)
|
||||||
: m_image(move(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())
|
, m_gui_event_loop(Core::EventLoop::current())
|
||||||
{
|
{
|
||||||
set_focus_policy(GUI::FocusPolicy::StrongFocus);
|
set_focus_policy(GUI::FocusPolicy::StrongFocus);
|
||||||
|
@ -103,7 +103,7 @@ bool ImageEditor::redo()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageEditor::set_title(DeprecatedString title)
|
void ImageEditor::set_title(String title)
|
||||||
{
|
{
|
||||||
m_title = move(title);
|
m_title = move(title);
|
||||||
if (on_title_change)
|
if (on_title_change)
|
||||||
|
@ -113,7 +113,7 @@ void ImageEditor::set_title(DeprecatedString title)
|
||||||
void ImageEditor::set_path(DeprecatedString path)
|
void ImageEditor::set_path(DeprecatedString path)
|
||||||
{
|
{
|
||||||
m_path = move(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)
|
void ImageEditor::set_modified(DeprecatedString action_text)
|
||||||
|
@ -761,7 +761,7 @@ void ImageEditor::save_project()
|
||||||
|
|
||||||
void ImageEditor::save_project_as()
|
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())
|
if (response.is_error())
|
||||||
return;
|
return;
|
||||||
auto file = response.release_value();
|
auto file = response.release_value();
|
||||||
|
|
|
@ -52,9 +52,8 @@ public:
|
||||||
DeprecatedString const& path() const { return m_path; }
|
DeprecatedString const& path() const { return m_path; }
|
||||||
void set_path(DeprecatedString);
|
void set_path(DeprecatedString);
|
||||||
|
|
||||||
DeprecatedString const& title() const { return m_title; }
|
String const& title() const { return m_title; }
|
||||||
void set_title(DeprecatedString);
|
void set_title(String);
|
||||||
void set_title(String const& title) { set_title(title.to_deprecated_string()); }
|
|
||||||
|
|
||||||
void add_guide(NonnullRefPtr<Guide> guide) { m_guides.append(guide); }
|
void add_guide(NonnullRefPtr<Guide> guide) { m_guides.append(guide); }
|
||||||
void remove_guide(Guide const& guide)
|
void remove_guide(Guide const& guide)
|
||||||
|
@ -83,7 +82,7 @@ public:
|
||||||
|
|
||||||
Function<void(Layer*)> on_active_layer_change;
|
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;
|
Function<void(Gfx::IntPoint)> on_image_mouse_position_change;
|
||||||
|
|
||||||
|
@ -170,7 +169,7 @@ private:
|
||||||
GUI::UndoStack m_undo_stack;
|
GUI::UndoStack m_undo_stack;
|
||||||
|
|
||||||
DeprecatedString m_path;
|
DeprecatedString m_path;
|
||||||
DeprecatedString m_title;
|
String m_title;
|
||||||
|
|
||||||
Vector<NonnullRefPtr<Guide>> m_guides;
|
Vector<NonnullRefPtr<Guide>> m_guides;
|
||||||
bool m_show_guides { true };
|
bool m_show_guides { true };
|
||||||
|
|
|
@ -173,7 +173,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||||
|
|
||||||
auto& editor = create_new_editor(*image);
|
auto& editor = create_new_editor(*image);
|
||||||
auto image_title = dialog->image_name().trim_whitespace();
|
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();
|
editor.set_unmodified();
|
||||||
|
|
||||||
m_histogram_widget->set_image(image);
|
m_histogram_widget->set_image(image);
|
||||||
|
@ -223,7 +223,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||||
"As &BMP", [&](auto&) {
|
"As &BMP", [&](auto&) {
|
||||||
auto* editor = current_image_editor();
|
auto* editor = current_image_editor();
|
||||||
VERIFY(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())
|
if (response.is_error())
|
||||||
return;
|
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);
|
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();
|
auto* editor = current_image_editor();
|
||||||
VERIFY(editor);
|
VERIFY(editor);
|
||||||
// TODO: fix bmp on line below?
|
// 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())
|
if (response.is_error())
|
||||||
return;
|
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);
|
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&) {
|
"As &QOI", [&](auto&) {
|
||||||
auto* editor = current_image_editor();
|
auto* editor = current_image_editor();
|
||||||
VERIFY(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())
|
if (response.is_error())
|
||||||
return;
|
return;
|
||||||
auto result = editor->image().export_qoi_to_file(response.value().release_stream());
|
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);
|
m_layer_list_widget->set_image(image);
|
||||||
|
|
||||||
auto& editor = create_new_editor(*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_active_layer(bg_layer);
|
||||||
editor.set_unmodified();
|
editor.set_unmodified();
|
||||||
|
|
||||||
|
@ -1215,7 +1215,7 @@ ErrorOr<void> MainWidget::create_image_from_clipboard()
|
||||||
image->add_layer(*layer);
|
image->add_layer(*layer);
|
||||||
|
|
||||||
auto& editor = create_new_editor(*image);
|
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_image(image);
|
||||||
m_layer_list_widget->set_selected_layer(layer);
|
m_layer_list_widget->set_selected_layer(layer);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue