1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-10-14 01:12:06 +00:00

Spreadsheet: Prompt user before closing with unsaved changes

This commit is contained in:
Xavier Cooney 2020-12-22 16:15:15 +11:00 committed by Andreas Kling
parent 23febb9d8e
commit 5f58fe1643
6 changed files with 44 additions and 1 deletions

View file

@ -114,9 +114,17 @@ int main(int argc, char* argv[])
app_menu.add_separator();
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
if (!spreadsheet_widget.request_close())
return;
app->quit(0);
}));
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
if (spreadsheet_widget.request_close())
return GUI::Window::CloseRequestDecision::Close;
return GUI::Window::CloseRequestDecision::StayOpen;
};
auto& file_menu = menubar->add_menu("File");
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
Optional<String> load_path = GUI::FilePicker::get_open_filepath(window);