summaryrefslogtreecommitdiff
path: root/Userland/DevTools
diff options
context:
space:
mode:
authorKarol Kosek <krkk@serenityos.org>2023-05-09 17:14:41 +0200
committerSam Atkins <atkinssj@gmail.com>2023-05-16 12:57:34 +0100
commit8dcfb6bfbd9e9cdb329871054d6692bab0880986 (patch)
treef326afd5c5f8cfdb47399c005f717d80eda34d88 /Userland/DevTools
parente7954f62b325c54463485b4e1ee4144b68002d4b (diff)
downloadserenity-8dcfb6bfbd9e9cdb329871054d6692bab0880986.zip
GMLPlayground: Reuse request_close() in 'Open' and recent files actions
Diffstat (limited to 'Userland/DevTools')
-rw-r--r--Userland/DevTools/GMLPlayground/MainWidget.cpp20
1 files 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<void> 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<void> 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;