mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00:00
GMLPlayground: Reuse request_close() in 'Open' and recent files actions
This commit is contained in:
parent
e7954f62b3
commit
8dcfb6bfbd
1 changed files with 4 additions and 16 deletions
|
@ -158,14 +158,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||||
});
|
});
|
||||||
|
|
||||||
auto open_action = GUI::CommonActions::make_open_action([&](auto&) {
|
auto open_action = GUI::CommonActions::make_open_action([&](auto&) {
|
||||||
if (window.is_modified()) {
|
if (request_close() == GUI::Window::CloseRequestDecision::StayOpen)
|
||||||
auto result = GUI::MessageBox::ask_about_unsaved_changes(&window, m_file_path, m_editor->document().undo_stack().last_unmodified_timestamp());
|
return;
|
||||||
if (result == GUI::MessageBox::ExecResult::Yes)
|
|
||||||
m_save_action->activate();
|
|
||||||
if (result != GUI::MessageBox::ExecResult::No && window.is_modified())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto response = FileSystemAccessClient::Client::the().open_file(&window);
|
auto response = FileSystemAccessClient::Client::the().open_file(&window);
|
||||||
if (response.is_error())
|
if (response.is_error())
|
||||||
return;
|
return;
|
||||||
|
@ -179,14 +173,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||||
TRY(file_menu->try_add_separator());
|
TRY(file_menu->try_add_separator());
|
||||||
|
|
||||||
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||||
if (window.is_modified()) {
|
if (request_close() == GUI::Window::CloseRequestDecision::StayOpen)
|
||||||
auto result = GUI::MessageBox::ask_about_unsaved_changes(&window, m_file_path, m_editor->document().undo_stack().last_unmodified_timestamp());
|
return;
|
||||||
if (result == GUI::MessageBox::ExecResult::Yes)
|
|
||||||
m_save_action->activate();
|
|
||||||
if (result != GUI::MessageBox::ExecResult::No && window.is_modified())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text());
|
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text());
|
||||||
if (response.is_error())
|
if (response.is_error())
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue