mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
PixelPaint: Call set_modified on window
Call set_modified on window in order to reflect unsaved changed in the titlebar's close button
This commit is contained in:
parent
7eb672c457
commit
ff8a6d8e59
Notes:
sideshowbarker
2024-07-17 16:51:18 +09:00
Author: https://github.com/GeekFiftyFive 🔰 Commit: https://github.com/SerenityOS/serenity/commit/ff8a6d8e59 Pull-request: https://github.com/SerenityOS/serenity/pull/13218 Reviewed-by: https://github.com/kleinesfilmroellchen ✅ Reviewed-by: https://github.com/mustafaquraish ✅
3 changed files with 18 additions and 0 deletions
|
@ -50,9 +50,16 @@ ImageEditor::~ImageEditor()
|
|||
|
||||
void ImageEditor::did_complete_action()
|
||||
{
|
||||
if (on_modified_change)
|
||||
on_modified_change(true);
|
||||
m_undo_stack.push(make<ImageUndoCommand>(*m_image));
|
||||
}
|
||||
|
||||
bool ImageEditor::is_modified()
|
||||
{
|
||||
return undo_stack().is_current_modified();
|
||||
}
|
||||
|
||||
bool ImageEditor::undo()
|
||||
{
|
||||
if (!m_undo_stack.can_undo())
|
||||
|
@ -580,6 +587,8 @@ void ImageEditor::save_project()
|
|||
return;
|
||||
}
|
||||
undo_stack().set_current_unmodified();
|
||||
if (on_modified_change)
|
||||
on_modified_change(false);
|
||||
}
|
||||
|
||||
void ImageEditor::save_project_as()
|
||||
|
@ -596,6 +605,8 @@ void ImageEditor::save_project_as()
|
|||
set_path(file->filename());
|
||||
set_loaded_from_image(false);
|
||||
undo_stack().set_current_unmodified();
|
||||
if (on_modified_change)
|
||||
on_modified_change(false);
|
||||
}
|
||||
|
||||
Result<void, String> ImageEditor::save_project_to_file(Core::File& file) const
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
Function<void(Gfx::IntPoint const&)> on_image_mouse_position_change;
|
||||
|
||||
Function<void(void)> on_leave;
|
||||
Function<void(bool modified)> on_modified_change;
|
||||
|
||||
bool request_close();
|
||||
|
||||
|
@ -110,6 +111,8 @@ public:
|
|||
|
||||
void set_loaded_from_image(bool);
|
||||
|
||||
bool is_modified();
|
||||
|
||||
private:
|
||||
explicit ImageEditor(NonnullRefPtr<Image>);
|
||||
|
||||
|
|
|
@ -88,6 +88,10 @@ MainWidget::MainWidget()
|
|||
m_palette_widget->set_image_editor(&image_editor);
|
||||
m_layer_list_widget->set_image(&image_editor.image());
|
||||
m_layer_properties_widget->set_layer(image_editor.active_layer());
|
||||
window()->set_modified(image_editor.is_modified());
|
||||
image_editor.on_modified_change = [this](bool modified) {
|
||||
window()->set_modified(modified);
|
||||
};
|
||||
if (auto* active_tool = m_toolbox->active_tool())
|
||||
image_editor.set_active_tool(active_tool);
|
||||
m_show_guides_action->set_checked(image_editor.guide_visibility());
|
||||
|
|
Loading…
Add table
Reference in a new issue