summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-01-04 17:56:10 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-04 21:49:44 +0100
commit490d385d015a4f1c475dfbbc1e14fb469baa4970 (patch)
tree8ee35831fa2f52bbf45d9cded1e8de1c61c7aa04 /Userland/Applications
parent82b071943d67ac2a0eb7c6286b9e288d00351f81 (diff)
downloadserenity-490d385d015a4f1c475dfbbc1e14fb469baa4970.zip
PixelPaint: Use GUI::MessageBox::ask_about_unsaved_changes()
To make the last-saved-at timestamp show up correctly, we also now mark the editor's undo stack as unmodified on save.
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.h2
-rw-r--r--Userland/Applications/PixelPaint/MainWidget.cpp8
2 files changed, 8 insertions, 2 deletions
diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h
index 4a1701588b..3bbaae35c6 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.h
+++ b/Userland/Applications/PixelPaint/ImageEditor.h
@@ -43,6 +43,8 @@ public:
bool undo();
bool redo();
+ auto& undo_stack() { return *m_undo_stack; }
+
void add_guide(NonnullRefPtr<Guide> guide) { m_guides.append(guide); }
void remove_guide(Guide const& guide)
{
diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp
index 10c499b317..7d7997a405 100644
--- a/Userland/Applications/PixelPaint/MainWidget.cpp
+++ b/Userland/Applications/PixelPaint/MainWidget.cpp
@@ -143,6 +143,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
return;
}
editor->image().set_path(*save_result.chosen_file);
+ editor->undo_stack().set_current_unmodified();
});
m_save_image_action = GUI::CommonActions::make_save_action([&](auto&) {
@@ -161,6 +162,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
GUI::MessageBox::show_error(&window, String::formatted("Could not save {}: {}", *response.chosen_file, result.error()));
return;
}
+ editor->undo_stack().set_current_unmodified();
});
file_menu.add_action(*m_new_image_action);
@@ -748,10 +750,12 @@ bool MainWidget::request_close()
if (m_tab_widget->children().is_empty())
return true;
- auto result = GUI::MessageBox::show(window(), "Save before closing?", "Save changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel);
+ VERIFY(current_image_editor());
+
+ auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), current_image_editor()->image().path(), current_image_editor()->undo_stack().last_unmodified_timestamp());
if (result == GUI::MessageBox::ExecYes) {
- m_save_image_as_action->activate();
+ m_save_image_action->activate();
return true;
}