diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 296cdfda6a..d934cdf35d 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -763,6 +763,8 @@ void ImageEditor::save_project() return; } set_unmodified(); + if (on_file_saved) + on_file_saved(path()); } void ImageEditor::save_project_as() @@ -779,6 +781,8 @@ void ImageEditor::save_project_as() set_path(file.filename()); set_loaded_from_image(false); set_unmodified(); + if (on_file_saved) + on_file_saved(path()); } ErrorOr ImageEditor::save_project_to_file(NonnullOwnPtr file) const diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index 34eda4c4c0..029e625b8a 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -90,6 +90,8 @@ public: Function on_leave; Function on_modified_change; + Function on_file_saved; + bool request_close(); void save_project_as(); diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index e5fa6589f7..ffa9451673 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -208,14 +208,12 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto* editor = current_image_editor(); VERIFY(editor); editor->save_project_as(); - GUI::Application::the()->set_most_recently_open_file(editor->path()); }); m_save_image_action = GUI::CommonActions::make_save_action([&](auto&) { auto* editor = current_image_editor(); VERIFY(editor); editor->save_project(); - GUI::Application::the()->set_most_recently_open_file(editor->path()); }); file_menu->add_action(*m_new_image_action); @@ -1441,6 +1439,9 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr image) if (image_editor.active_tool()) image_editor.active_tool()->on_secondary_color_change(color); }; + image_editor.on_file_saved = [](ByteString const& filename) { + GUI::Application::the()->set_most_recently_open_file(filename); + }; if (image->layer_count()) image_editor.set_active_layer(&image->layer(0));