mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:47:44 +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:
parent
16f064d9be
commit
235f39e449
104 changed files with 412 additions and 397 deletions
|
@ -534,7 +534,7 @@ void DirectoryView::handle_selection_change()
|
|||
|
||||
void DirectoryView::setup_actions()
|
||||
{
|
||||
m_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&) {
|
||||
m_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&) {
|
||||
String value;
|
||||
if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecOK && !value.is_empty()) {
|
||||
auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
|
||||
|
@ -546,7 +546,7 @@ void DirectoryView::setup_actions()
|
|||
}
|
||||
});
|
||||
|
||||
m_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&) {
|
||||
m_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&) {
|
||||
String value;
|
||||
if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecOK && !value.is_empty()) {
|
||||
auto new_file_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
|
||||
|
@ -572,7 +572,7 @@ void DirectoryView::setup_actions()
|
|||
}
|
||||
});
|
||||
|
||||
m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) {
|
||||
m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
|
||||
spawn_terminal(path());
|
||||
});
|
||||
|
||||
|
@ -588,21 +588,21 @@ void DirectoryView::setup_actions()
|
|||
window());
|
||||
|
||||
m_view_as_icons_action = GUI::Action::create_checkable(
|
||||
"View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"), [&](GUI::Action const&) {
|
||||
"View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
|
||||
set_view_mode(DirectoryView::ViewMode::Icon);
|
||||
Config::write_string("FileManager", "DirectoryView", "ViewMode", "Icon");
|
||||
},
|
||||
window());
|
||||
|
||||
m_view_as_table_action = GUI::Action::create_checkable(
|
||||
"View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png"), [&](GUI::Action const&) {
|
||||
"View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
|
||||
set_view_mode(DirectoryView::ViewMode::Table);
|
||||
Config::write_string("FileManager", "DirectoryView", "ViewMode", "Table");
|
||||
},
|
||||
window());
|
||||
|
||||
m_view_as_columns_action = GUI::Action::create_checkable(
|
||||
"View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png"), [&](GUI::Action const&) {
|
||||
"View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
|
||||
set_view_mode(DirectoryView::ViewMode::Columns);
|
||||
Config::write_string("FileManager", "DirectoryView", "ViewMode", "Columns");
|
||||
},
|
||||
|
|
|
@ -39,7 +39,7 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind
|
|||
set_rect({ 0, 0, 360, 420 });
|
||||
set_resizable(false);
|
||||
|
||||
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png"));
|
||||
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png").release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto& tab_widget = main_widget.add<GUI::TabWidget>();
|
||||
|
||||
|
|
|
@ -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());
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue