mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +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
2 changed files with 8 additions and 2 deletions
|
@ -43,6 +43,8 @@ public:
|
||||||
bool undo();
|
bool undo();
|
||||||
bool redo();
|
bool redo();
|
||||||
|
|
||||||
|
auto& undo_stack() { return *m_undo_stack; }
|
||||||
|
|
||||||
void add_guide(NonnullRefPtr<Guide> guide) { m_guides.append(guide); }
|
void add_guide(NonnullRefPtr<Guide> guide) { m_guides.append(guide); }
|
||||||
void remove_guide(Guide const& guide)
|
void remove_guide(Guide const& guide)
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,6 +143,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
editor->image().set_path(*save_result.chosen_file);
|
editor->image().set_path(*save_result.chosen_file);
|
||||||
|
editor->undo_stack().set_current_unmodified();
|
||||||
});
|
});
|
||||||
|
|
||||||
m_save_image_action = GUI::CommonActions::make_save_action([&](auto&) {
|
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()));
|
GUI::MessageBox::show_error(&window, String::formatted("Could not save {}: {}", *response.chosen_file, result.error()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
editor->undo_stack().set_current_unmodified();
|
||||||
});
|
});
|
||||||
|
|
||||||
file_menu.add_action(*m_new_image_action);
|
file_menu.add_action(*m_new_image_action);
|
||||||
|
@ -748,10 +750,12 @@ bool MainWidget::request_close()
|
||||||
if (m_tab_widget->children().is_empty())
|
if (m_tab_widget->children().is_empty())
|
||||||
return true;
|
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) {
|
if (result == GUI::MessageBox::ExecYes) {
|
||||||
m_save_image_as_action->activate();
|
m_save_image_action->activate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue