mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 11:09:05 +03:00
PixelPaint: Don't overwrite images with project file on save
The ImageEditor tracks whether it was loaded from an image (the alternative being a project file.) If it was loaded from an image file we redirect save project actions to save as instead.
This commit is contained in:
parent
e74e6087b0
commit
032ffbcf64
Notes:
sideshowbarker
2024-07-17 19:44:34 +09:00
Author: https://github.com/Matthias-Sleurink 🔰 Commit: https://github.com/SerenityOS/serenity/commit/032ffbcf647 Pull-request: https://github.com/SerenityOS/serenity/pull/12268 Issue: https://github.com/SerenityOS/serenity/issues/11889 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/bgianfo
@ -587,7 +587,7 @@ bool ImageEditor::request_close()
|
||||
|
||||
void ImageEditor::save_project()
|
||||
{
|
||||
if (path().is_empty()) {
|
||||
if (path().is_empty() || m_loaded_from_image) {
|
||||
save_project_as();
|
||||
return;
|
||||
}
|
||||
@ -614,6 +614,7 @@ void ImageEditor::save_project_as()
|
||||
return;
|
||||
}
|
||||
set_path(file->filename());
|
||||
set_loaded_from_image(false);
|
||||
undo_stack().set_current_unmodified();
|
||||
}
|
||||
|
||||
@ -649,4 +650,9 @@ void ImageEditor::set_show_active_layer_boundary(bool show)
|
||||
update();
|
||||
}
|
||||
|
||||
void ImageEditor::set_loaded_from_image(bool loaded_from_image)
|
||||
{
|
||||
m_loaded_from_image = loaded_from_image;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -114,6 +114,8 @@ public:
|
||||
bool show_active_layer_boundary() const { return m_show_active_layer_boundary; }
|
||||
void set_show_active_layer_boundary(bool);
|
||||
|
||||
void set_loaded_from_image(bool);
|
||||
|
||||
private:
|
||||
explicit ImageEditor(NonnullRefPtr<Image>);
|
||||
|
||||
@ -170,6 +172,8 @@ private:
|
||||
Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> m_active_cursor { Gfx::StandardCursor::None };
|
||||
|
||||
Selection m_selection;
|
||||
|
||||
bool m_loaded_from_image { true };
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -712,6 +712,7 @@ void MainWidget::open_image(Core::File& file)
|
||||
|
||||
auto& image = *m_loader.release_image();
|
||||
auto& editor = create_new_editor(image);
|
||||
editor.set_loaded_from_image(m_loader.is_raw_image());
|
||||
editor.set_path(file.filename());
|
||||
editor.undo_stack().set_current_unmodified();
|
||||
m_layer_list_widget->set_image(&image);
|
||||
|
Loading…
Reference in New Issue
Block a user