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

PixelPaint: Display an error message if saving to PP file fails

This commit is contained in:
Andreas Kling 2021-06-14 21:46:29 +02:00
parent fa7bb98b1e
commit c333aec9f3
3 changed files with 17 additions and 10 deletions

View file

@ -115,10 +115,14 @@ int main(int argc, char** argv)
auto save_image_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
if (!image_editor.image())
return;
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, "untitled", "pp");
auto save_path = GUI::FilePicker::get_save_filepath(window, "untitled", "pp");
if (!save_path.has_value())
return;
image_editor.image()->save(save_path.value());
auto result = image_editor.image()->write_to_file(save_path.value());
if (result.is_error()) {
GUI::MessageBox::show_error(window, String::formatted("Could not save {}: {}", save_path.value(), result.error()));
return;
}
});
auto menubar = GUI::Menubar::construct();