summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeekFiftyFive <amylouisepellatt@gmail.com>2022-03-23 19:25:54 +0000
committerAndreas Kling <kling@serenityos.org>2022-03-24 03:03:50 +0100
commitff8a6d8e59170ec866d7259da956c51dd7cb5be0 (patch)
tree79c22b751950e2a96e1850aa8b74253c735e4169
parent7eb672c457611f8746c6253412963c17930462c6 (diff)
downloadserenity-ff8a6d8e59170ec866d7259da956c51dd7cb5be0.zip
PixelPaint: Call set_modified on window
Call set_modified on window in order to reflect unsaved changed in the titlebar's close button
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.cpp11
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.h3
-rw-r--r--Userland/Applications/PixelPaint/MainWidget.cpp4
3 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp
index 1381153fbd..72f0574e9f 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.cpp
+++ b/Userland/Applications/PixelPaint/ImageEditor.cpp
@@ -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
diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h
index 9d9cc2fa40..88df7cb922 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.h
+++ b/Userland/Applications/PixelPaint/ImageEditor.h
@@ -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>);
diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp
index 7455852da8..abb28a1377 100644
--- a/Userland/Applications/PixelPaint/MainWidget.cpp
+++ b/Userland/Applications/PixelPaint/MainWidget.cpp
@@ -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());