1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 16:47:34 +00:00

Playground: Ask to save changes even when the document was never saved

This makes sure to ask the user whether they want to save changes to
their current document when opening a file even if the document has
never been saved before.
This commit is contained in:
Gunnar Beutner 2021-06-22 19:19:47 +02:00 committed by Andreas Kling
parent 3d42297ecd
commit de84b3fa1c

View file

@ -172,11 +172,11 @@ int main(int argc, char** argv)
});
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
if (!file_path.is_empty() && window->is_modified()) {
if (window->is_modified()) {
auto save_document_first_result = GUI::MessageBox::show(window, "Save changes to current document first?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel);
if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes)
save_action->activate();
if (save_document_first_result == GUI::Dialog::ExecResult::ExecCancel)
if (save_document_first_result != GUI::Dialog::ExecResult::ExecNo && window->is_modified())
return;
}