1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

KeyboardMapper: Ask for unsaved changes on window close and file open

This commit is contained in:
Karol Kosek 2021-11-07 10:57:03 +01:00 committed by Linus Groh
parent ae9e4c6f26
commit b6510f8e76
3 changed files with 27 additions and 0 deletions

View file

@ -21,6 +21,22 @@ KeyboardMapperWidget::KeyboardMapperWidget()
create_frame();
}
bool KeyboardMapperWidget::request_close()
{
if (!window()->is_modified())
return true;
auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_filename);
if (result == GUI::MessageBox::ExecYes) {
ErrorOr<void> error_or = save();
if (error_or.is_error())
show_error_to_user(error_or.error());
if (!window()->is_modified())
return true;
}
return result == GUI::MessageBox::ExecNo;
}
void KeyboardMapperWidget::create_frame()
{
set_fill_with_background_color(true);