1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +00:00

LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()

This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
This commit is contained in:
Andreas Kling 2021-11-06 16:25:29 +01:00
parent 16f064d9be
commit 235f39e449
104 changed files with 412 additions and 397 deletions

View file

@ -353,7 +353,7 @@ int run_in_desktop_mode()
auto desktop_view_context_menu = GUI::Menu::construct("Directory View");
auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"), [&](auto&) {
auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto paths = directory_view.selected_file_paths();
if (paths.is_empty()) {
Desktop::Launcher::open(URL::create_with_file_protocol(directory_view.path()));
@ -366,7 +366,7 @@ int run_in_desktop_mode()
}
});
auto open_terminal_action = GUI::Action::create("Open in &Terminal", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) {
auto open_terminal_action = GUI::Action::create("Open in &Terminal", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto paths = directory_view.selected_file_paths();
if (paths.is_empty()) {
spawn_terminal(directory_view.path());
@ -380,7 +380,7 @@ int run_in_desktop_mode()
}
});
auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png"), [&](GUI::Action const&) {
auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
Desktop::Launcher::open(URL::create_with_file_protocol("/bin/DisplaySettings"));
});
@ -563,7 +563,7 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
auto directory_view_context_menu = GUI::Menu::construct("Directory View");
auto tree_view_directory_context_menu = GUI::Menu::construct("Tree View Directory");
auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](GUI::Action const&) {
auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
directory_view.open_parent_directory();
});
@ -690,7 +690,7 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
= GUI::Action::create(
"Open in New &Window",
{},
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const& action) {
Vector<String> paths;
if (action.activator() == tree_view_directory_context_menu)
@ -709,7 +709,7 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
= GUI::Action::create(
"Open in &Terminal",
{},
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const& action) {
Vector<String> paths;
if (action.activator() == tree_view_directory_context_menu)
@ -729,7 +729,7 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
= GUI::Action::create(
"Create Desktop &Shortcut",
{},
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-symlink.png"),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-symlink.png").release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const&) {
auto paths = directory_view.selected_file_paths();
if (paths.is_empty()) {
@ -836,12 +836,12 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
});
focus_dependent_delete_action->set_enabled(false);
auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [&](GUI::Action const&) {
auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
directory_view.mkdir_action().activate();
refresh_tree_view();
});
auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [&](GUI::Action const&) {
auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
directory_view.touch_action().activate();
refresh_tree_view();
});
@ -1042,7 +1042,7 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
|| !directory_view.current_view().selection().is_empty());
};
auto directory_open_action = GUI::Action::create("Open", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), [&](auto&) {
auto directory_open_action = GUI::Action::create("Open", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
directory_view.open(directory_view.selected_file_paths().first());
});