mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:07:34 +00:00
KeyboardMapper: Ask for unsaved changes on window close and file open
This commit is contained in:
parent
ae9e4c6f26
commit
b6510f8e76
3 changed files with 27 additions and 0 deletions
|
@ -47,6 +47,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto open_action = GUI::CommonActions::make_open_action(
|
||||
[&](auto&) {
|
||||
if (!keyboard_mapper_widget->request_close())
|
||||
return;
|
||||
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath(window, "Open", "/res/keymaps/");
|
||||
if (!path.has_value())
|
||||
return;
|
||||
|
@ -99,6 +102,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto& help_menu = window->add_menu("&Help");
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Keyboard Mapper", app_icon, window));
|
||||
|
||||
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
|
||||
if (keyboard_mapper_widget->request_close())
|
||||
return GUI::Window::CloseRequestDecision::Close;
|
||||
return GUI::Window::CloseRequestDecision::StayOpen;
|
||||
};
|
||||
|
||||
window->show();
|
||||
|
||||
return app->exec();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue