mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
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.
This commit is contained in:
parent
82b071943d
commit
490d385d01
Notes:
sideshowbarker
2024-07-17 23:07:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/490d385d015
2 changed files with 8 additions and 2 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue