浏览代码

ImageViewer: Show error if wallpaper could not be set

Junior Rantila 3 年之前
父节点
当前提交
e114e2e66d
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      Userland/Applications/ImageViewer/main.cpp

+ 7 - 1
Userland/Applications/ImageViewer/main.cpp

@@ -171,7 +171,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
 
 
     auto desktop_wallpaper_action = GUI::Action::create("Set as Desktop &Wallpaper",
     auto desktop_wallpaper_action = GUI::Action::create("Set as Desktop &Wallpaper",
         [&](auto&) {
         [&](auto&) {
-            GUI::Desktop::the().set_wallpaper(widget->path());
+            auto could_set_wallpaper = GUI::Desktop::the().set_wallpaper(widget->path());
+            if (!could_set_wallpaper) {
+                GUI::MessageBox::show(window,
+                    String::formatted("set_wallpaper({}) failed", widget->path()),
+                    "Could not set wallpaper",
+                    GUI::MessageBox::Type::Error);
+            }
         });
         });
 
 
     auto go_first_action = GUI::Action::create("&Go to First", { Mod_None, Key_Home }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-first.png")),
     auto go_first_action = GUI::Action::create("&Go to First", { Mod_None, Key_Home }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-first.png")),