1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27:35 +00:00

DisplaySettings: Revert changes unless confirmed

This commit is contained in:
Xavier Defrang 2021-06-22 22:28:21 +02:00 committed by Andreas Kling
parent 40f7977508
commit 9dfc96f89b

View file

@ -121,12 +121,18 @@ void MonitorSettingsWidget::apply_settings()
});
// If the user selects "No", closes the window or the window gets closed by the 10 seconds timer, revert the changes.
if (box->exec() != GUI::MessageBox::ExecYes) {
if (box->exec() == GUI::MessageBox::ExecYes) {
auto save_result = GUI::WindowServerConnection::the().save_screen_layout();
if (!save_result.success()) {
GUI::MessageBox::show(window(), String::formatted("Error saving settings: {}", save_result.error_msg()),
"Unable to save setting", GUI::MessageBox::Type::Error);
}
} else {
auto restore_result = GUI::WindowServerConnection::the().set_screen_layout(current_layout, false);
if (!restore_result.success()) {
GUI::MessageBox::show(window(), String::formatted("Error restoring settings: {}", restore_result.error_msg()),
"Unable to restore setting", GUI::MessageBox::Type::Error);
}
}
} else {
GUI::MessageBox::show(window(), String::formatted("Error setting screen layout: {}", result.error_msg()),