From 8dcfb6bfbd9e9cdb329871054d6692bab0880986 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Tue, 9 May 2023 17:14:41 +0200 Subject: [PATCH] GMLPlayground: Reuse request_close() in 'Open' and recent files actions --- .../DevTools/GMLPlayground/MainWidget.cpp | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/Userland/DevTools/GMLPlayground/MainWidget.cpp b/Userland/DevTools/GMLPlayground/MainWidget.cpp index 68e85528ab..33a142174f 100644 --- a/Userland/DevTools/GMLPlayground/MainWidget.cpp +++ b/Userland/DevTools/GMLPlayground/MainWidget.cpp @@ -158,14 +158,8 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) }); auto open_action = GUI::CommonActions::make_open_action([&](auto&) { - if (window.is_modified()) { - auto result = GUI::MessageBox::ask_about_unsaved_changes(&window, m_file_path, m_editor->document().undo_stack().last_unmodified_timestamp()); - if (result == GUI::MessageBox::ExecResult::Yes) - m_save_action->activate(); - if (result != GUI::MessageBox::ExecResult::No && window.is_modified()) - return; - } - + if (request_close() == GUI::Window::CloseRequestDecision::StayOpen) + return; auto response = FileSystemAccessClient::Client::the().open_file(&window); if (response.is_error()) return; @@ -179,14 +173,8 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) TRY(file_menu->try_add_separator()); TRY(file_menu->add_recent_files_list([&](auto& action) { - if (window.is_modified()) { - auto result = GUI::MessageBox::ask_about_unsaved_changes(&window, m_file_path, m_editor->document().undo_stack().last_unmodified_timestamp()); - if (result == GUI::MessageBox::ExecResult::Yes) - m_save_action->activate(); - if (result != GUI::MessageBox::ExecResult::No && window.is_modified()) - return; - } - + if (request_close() == GUI::Window::CloseRequestDecision::StayOpen) + return; auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text()); if (response.is_error()) return;