1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

PixelPaint: Display an error message if exporting to PNG/BMP fails

This commit is contained in:
Andreas Kling 2021-06-15 11:30:34 +02:00
parent ba807c2d44
commit 91100f2f94
3 changed files with 53 additions and 27 deletions

View file

@ -138,10 +138,12 @@ int main(int argc, char** argv)
"As &BMP", [&](auto&) {
if (!image_editor.image())
return;
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, "untitled", "bmp");
auto save_path = GUI::FilePicker::get_save_filepath(window, "untitled", "bmp");
if (!save_path.has_value())
return;
image_editor.image()->export_bmp(save_path.value());
auto result = image_editor.image()->export_bmp_to_file(save_path.value());
if (result.is_error())
GUI::MessageBox::show_error(window, String::formatted("Export to BMP failed: {}", result.error()));
},
window));
export_submenu.add_action(
@ -149,13 +151,12 @@ int main(int argc, char** argv)
"As &PNG", [&](auto&) {
if (!image_editor.image())
return;
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, "untitled", "png");
auto save_path = GUI::FilePicker::get_save_filepath(window, "untitled", "png");
if (!save_path.has_value())
return;
image_editor.image()->export_png(save_path.value());
auto result = image_editor.image()->export_bmp_to_file(save_path.value());
if (result.is_error())
GUI::MessageBox::show_error(window, String::formatted("Export to PNG failed: {}", result.error()));
},
window));