mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
Solitaire: Get user confirmation to close when there is a active game
This commit is contained in:
parent
779316d468
commit
c3c1a9ca1d
Notes:
sideshowbarker
2024-07-18 07:25:29 +09:00
Author: https://github.com/jamierocks Commit: https://github.com/SerenityOS/serenity/commit/c3c1a9ca1d1 Pull-request: https://github.com/SerenityOS/serenity/pull/9223 Reviewed-by: https://github.com/awesomekling
1 changed files with 18 additions and 0 deletions
|
@ -150,6 +150,24 @@ int main(int argc, char** argv)
|
|||
statusbar.set_text(2, "Timer starts after your first move");
|
||||
};
|
||||
|
||||
window->on_close_request = [&]() {
|
||||
auto game_in_progress = timer->is_active();
|
||||
if (game_in_progress) {
|
||||
auto result = GUI::MessageBox::show(window,
|
||||
"A game is still in progress, are you sure you would like to quit?",
|
||||
"Game in progress",
|
||||
GUI::MessageBox::Type::Warning,
|
||||
GUI::MessageBox::InputType::YesNo);
|
||||
|
||||
if (result == GUI::MessageBox::ExecYes)
|
||||
return GUI::Window::CloseRequestDecision::Close;
|
||||
else
|
||||
return GUI::Window::CloseRequestDecision::StayOpen;
|
||||
}
|
||||
|
||||
return GUI::Window::CloseRequestDecision::Close;
|
||||
};
|
||||
|
||||
GUI::ActionGroup draw_setting_actions;
|
||||
draw_setting_actions.set_exclusive(true);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue