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
Notes: sideshowbarker 2024-07-18 01:24:26 +09:00
104 changed files with 412 additions and 397 deletions

View file

@ -46,11 +46,11 @@ public:
update(); update();
}; };
m_volume_level_bitmaps.append({ 66, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-high.png") }); m_volume_level_bitmaps.append({ 66, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-high.png").release_value_but_fixme_should_propagate_errors() });
m_volume_level_bitmaps.append({ 33, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-medium.png") }); m_volume_level_bitmaps.append({ 33, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-medium.png").release_value_but_fixme_should_propagate_errors() });
m_volume_level_bitmaps.append({ 1, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-low.png") }); m_volume_level_bitmaps.append({ 1, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-low.png").release_value_but_fixme_should_propagate_errors() });
m_volume_level_bitmaps.append({ 0, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-zero.png") }); m_volume_level_bitmaps.append({ 0, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-zero.png").release_value_but_fixme_should_propagate_errors() });
m_volume_level_bitmaps.append({ 0, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-muted.png") }); m_volume_level_bitmaps.append({ 0, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-muted.png").release_value_but_fixme_should_propagate_errors() });
m_slider_window = add<GUI::Window>(window()); m_slider_window = add<GUI::Window>(window());
m_slider_window->set_frameless(true); m_slider_window->set_frameless(true);

View file

@ -151,8 +151,8 @@ private:
String m_adapter_info; String m_adapter_info;
bool m_connected = false; bool m_connected = false;
bool m_notifications = true; bool m_notifications = true;
RefPtr<Gfx::Bitmap> m_connected_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network.png"); RefPtr<Gfx::Bitmap> m_connected_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network.png").release_value_but_fixme_should_propagate_errors();
RefPtr<Gfx::Bitmap> m_disconnected_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-disconnected.png"); RefPtr<Gfx::Bitmap> m_disconnected_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-disconnected.png").release_value_but_fixme_should_propagate_errors();
}; };
int main(int argc, char* argv[]) int main(int argc, char* argv[])

View file

@ -250,7 +250,9 @@ bool GLContextWidget::load_file(Core::File& file, String const& filename)
// Attempt to open the texture file from disk // Attempt to open the texture file from disk
RefPtr<Gfx::Bitmap> texture_image; RefPtr<Gfx::Bitmap> texture_image;
if (Core::File::exists(texture_path)) { if (Core::File::exists(texture_path)) {
texture_image = Gfx::Bitmap::try_load_from_file(texture_path); auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(texture_path);
if (!bitmap_or_error.is_error())
texture_image = bitmap_or_error.release_value_but_fixme_should_propagate_errors();
} else { } else {
auto result = FileSystemAccessClient::Client::the().request_file(window()->window_id(), builder.string_view(), Core::OpenMode::ReadOnly); auto result = FileSystemAccessClient::Client::the().request_file(window()->window_id(), builder.string_view(), Core::OpenMode::ReadOnly);
@ -258,7 +260,9 @@ bool GLContextWidget::load_file(Core::File& file, String const& filename)
return false; return false;
} }
texture_image = Gfx::Bitmap::try_load_from_fd_and_close(*result.fd, *result.chosen_file); auto bitmap_or_error = Gfx::Bitmap::try_load_from_fd_and_close(*result.fd, *result.chosen_file);
if (!bitmap_or_error.is_error())
texture_image = bitmap_or_error.release_value_but_fixme_should_propagate_errors();
} }
GLuint tex; GLuint tex;

View file

@ -190,7 +190,7 @@ void BookmarksBarWidget::model_did_update(unsigned)
button.set_button_style(Gfx::ButtonStyle::Coolbar); button.set_button_style(Gfx::ButtonStyle::Coolbar);
button.set_text(title); button.set_text(title);
button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png")); button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png").release_value_but_fixme_should_propagate_errors());
button.set_fixed_size(font().width(title) + 32, 20); button.set_fixed_size(font().width(title) + 32, 20);
button.set_relative_rect(rect); button.set_relative_rect(rect);
button.set_focus_policy(GUI::FocusPolicy::TabFocus); button.set_focus_policy(GUI::FocusPolicy::TabFocus);
@ -242,7 +242,7 @@ void BookmarksBarWidget::update_content_size()
auto& bookmark = m_bookmarks.at(i); auto& bookmark = m_bookmarks.at(i);
bookmark.set_visible(false); bookmark.set_visible(false);
m_additional_menu->add_action(GUI::Action::create(bookmark.text(), m_additional_menu->add_action(GUI::Action::create(bookmark.text(),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"), Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
bookmark.on_click(0); bookmark.on_click(0);
})); }));

View file

@ -238,7 +238,7 @@ void BrowserWindow::build_menus()
m_search_engine_actions.set_exclusive(true); m_search_engine_actions.set_exclusive(true);
auto& search_engine_menu = settings_menu.add_submenu("&Search Engine"); auto& search_engine_menu = settings_menu.add_submenu("&Search Engine");
search_engine_menu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png")); search_engine_menu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors());
bool search_engine_set = false; bool search_engine_set = false;
auto add_search_engine = [&](auto& name, auto& url_format) { auto add_search_engine = [&](auto& name, auto& url_format) {
auto action = GUI::Action::create_checkable( auto action = GUI::Action::create_checkable(
@ -301,7 +301,7 @@ void BrowserWindow::build_menus()
} }
auto& color_scheme_menu = settings_menu.add_submenu("&Color Scheme"); auto& color_scheme_menu = settings_menu.add_submenu("&Color Scheme");
color_scheme_menu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png")); color_scheme_menu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png").release_value_but_fixme_should_propagate_errors());
{ {
auto current_setting = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser", "Preferences", "ColorScheme", "auto")); auto current_setting = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser", "Preferences", "ColorScheme", "auto"));
m_color_scheme_actions.set_exclusive(true); m_color_scheme_actions.set_exclusive(true);

View file

@ -60,7 +60,7 @@ ConsoleWidget::ConsoleWidget()
auto& clear_button = bottom_container.add<GUI::Button>(); auto& clear_button = bottom_container.add<GUI::Button>();
clear_button.set_fixed_size(22, 22); clear_button.set_fixed_size(22, 22);
clear_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png")); clear_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png").release_value_but_fixme_should_propagate_errors());
clear_button.set_tooltip("Clear the console output"); clear_button.set_tooltip("Clear the console output");
clear_button.on_click = [this](auto) { clear_button.on_click = [this](auto) {
clear_output(); clear_output();

View file

@ -73,7 +73,7 @@ void Tab::view_source(const URL& url, const String& source)
editor.set_ruler_visible(true); editor.set_ruler_visible(true);
window->resize(640, 480); window->resize(640, 480);
window->set_title(url.to_string()); window->set_title(url.to_string());
window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-text.png")); window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-text.png").release_value_but_fixme_should_propagate_errors());
window->show(); window->show();
} }
@ -98,7 +98,7 @@ Tab::Tab(BrowserWindow& window)
for (auto& url : m_history.get_back_title_history()) { for (auto& url : m_history.get_back_title_history()) {
i++; i++;
m_go_back_context_menu->add_action(GUI::Action::create(url.to_string(), m_go_back_context_menu->add_action(GUI::Action::create(url.to_string(),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"), Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png").release_value_but_fixme_should_propagate_errors(),
[this, i](auto&) { go_back(i); })); [this, i](auto&) { go_back(i); }));
} }
m_go_back_context_menu->popup(context_menu_event.screen_position()); m_go_back_context_menu->popup(context_menu_event.screen_position());
@ -113,7 +113,7 @@ Tab::Tab(BrowserWindow& window)
for (auto& url : m_history.get_forward_title_history()) { for (auto& url : m_history.get_forward_title_history()) {
i++; i++;
m_go_forward_context_menu->add_action(GUI::Action::create(url.to_string(), m_go_forward_context_menu->add_action(GUI::Action::create(url.to_string(),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"), Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png").release_value_but_fixme_should_propagate_errors(),
[this, i](auto&) { go_forward(i); })); [this, i](auto&) { go_forward(i); }));
} }
m_go_forward_context_menu->popup(context_menu_event.screen_position()); m_go_forward_context_menu->popup(context_menu_event.screen_position());
@ -148,7 +148,7 @@ Tab::Tab(BrowserWindow& window)
m_bookmark_button = toolbar.add<GUI::Button>(); m_bookmark_button = toolbar.add<GUI::Button>();
m_bookmark_button->set_button_style(Gfx::ButtonStyle::Coolbar); m_bookmark_button->set_button_style(Gfx::ButtonStyle::Coolbar);
m_bookmark_button->set_focus_policy(GUI::FocusPolicy::TabFocus); m_bookmark_button->set_focus_policy(GUI::FocusPolicy::TabFocus);
m_bookmark_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png")); m_bookmark_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png").release_value_but_fixme_should_propagate_errors());
m_bookmark_button->set_fixed_size(22, 22); m_bookmark_button->set_fixed_size(22, 22);
m_bookmark_button->on_click = [this](auto) { m_bookmark_button->on_click = [this](auto) {
@ -411,10 +411,10 @@ void Tab::bookmark_current_url()
void Tab::update_bookmark_button(const String& url) void Tab::update_bookmark_button(const String& url)
{ {
if (BookmarksBarWidget::the().contains_bookmark(url)) { if (BookmarksBarWidget::the().contains_bookmark(url)) {
m_bookmark_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-filled.png")); m_bookmark_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-filled.png").release_value_but_fixme_should_propagate_errors());
m_bookmark_button->set_tooltip("Remove Bookmark"); m_bookmark_button->set_tooltip("Remove Bookmark");
} else { } else {
m_bookmark_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png")); m_bookmark_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png").release_value_but_fixme_should_propagate_errors());
m_bookmark_button->set_tooltip("Add Bookmark"); m_bookmark_button->set_tooltip("Add Bookmark");
} }
} }
@ -483,7 +483,7 @@ void Tab::show_inspector_window(Browser::Tab::InspectorTarget inspector_target)
auto window = GUI::Window::construct(&this->window()); auto window = GUI::Window::construct(&this->window());
window->resize(300, 500); window->resize(300, 500);
window->set_title("Inspector"); window->set_title("Inspector");
window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
window->on_close = [&]() { window->on_close = [&]() {
m_web_content_view->clear_inspected_dom_node(); m_web_content_view->clear_inspected_dom_node();
}; };
@ -512,7 +512,7 @@ void Tab::show_console_window()
auto console_window = GUI::Window::construct(&window()); auto console_window = GUI::Window::construct(&window());
console_window->resize(500, 300); console_window->resize(500, 300);
console_window->set_title("JS Console"); console_window->set_title("JS Console");
console_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png")); console_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png").release_value_but_fixme_should_propagate_errors());
m_console_widget = console_window->set_main_widget<ConsoleWidget>(); m_console_widget = console_window->set_main_widget<ConsoleWidget>();
m_console_widget->on_js_input = [this](String const& js_source) { m_console_widget->on_js_input = [this](String const& js_source) {
m_web_content_view->js_console_input(js_source); m_web_content_view->js_console_input(js_source);

View file

@ -24,7 +24,7 @@ WindowActions::WindowActions(GUI::Window& window)
VERIFY(!s_the); VERIFY(!s_the);
s_the = this; s_the = this;
m_create_new_tab_action = GUI::Action::create( m_create_new_tab_action = GUI::Action::create(
"&New Tab", { Mod_Ctrl, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"), [this](auto&) { "&New Tab", { Mod_Ctrl, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (on_create_new_tab) if (on_create_new_tab)
on_create_new_tab(); on_create_new_tab();
}, },

View file

@ -53,7 +53,7 @@ int main(int argc, char** argv)
auto toolbar = main_widget.find_descendant_of_type_named<GUI::Toolbar>("toolbar"); auto toolbar = main_widget.find_descendant_of_type_named<GUI::Toolbar>("toolbar");
auto calendar = main_widget.find_descendant_of_type_named<GUI::Calendar>("calendar"); auto calendar = main_widget.find_descendant_of_type_named<GUI::Calendar>("calendar");
auto prev_date_action = GUI::Action::create({}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"), [&](const GUI::Action&) { auto prev_date_action = GUI::Action::create({}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
unsigned view_month = calendar->view_month(); unsigned view_month = calendar->view_month();
unsigned view_year = calendar->view_year(); unsigned view_year = calendar->view_year();
if (calendar->mode() == GUI::Calendar::Month) { if (calendar->mode() == GUI::Calendar::Month) {
@ -68,7 +68,7 @@ int main(int argc, char** argv)
calendar->update_tiles(view_year, view_month); calendar->update_tiles(view_year, view_month);
}); });
auto next_date_action = GUI::Action::create({}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), [&](const GUI::Action&) { auto next_date_action = GUI::Action::create({}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
unsigned view_month = calendar->view_month(); unsigned view_month = calendar->view_month();
unsigned view_year = calendar->view_year(); unsigned view_year = calendar->view_year();
if (calendar->mode() == GUI::Calendar::Month) { if (calendar->mode() == GUI::Calendar::Month) {
@ -83,22 +83,22 @@ int main(int argc, char** argv)
calendar->update_tiles(view_year, view_month); calendar->update_tiles(view_year, view_month);
}); });
auto add_event_action = GUI::Action::create("&Add Event", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png"), [&](const GUI::Action&) { auto add_event_action = GUI::Action::create("&Add Event", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
AddEventDialog::show(calendar->selected_date(), window); AddEventDialog::show(calendar->selected_date(), window);
}); });
auto jump_to_action = GUI::Action::create("Jump to &Today", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png"), [&](const GUI::Action&) { auto jump_to_action = GUI::Action::create("Jump to &Today", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
calendar->set_selected_date(Core::DateTime::now()); calendar->set_selected_date(Core::DateTime::now());
calendar->update_tiles(Core::DateTime::now().year(), Core::DateTime::now().month()); calendar->update_tiles(Core::DateTime::now().year(), Core::DateTime::now().month());
}); });
auto view_month_action = GUI::Action::create_checkable("&Month View", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-month-view.png"), [&](const GUI::Action&) { auto view_month_action = GUI::Action::create_checkable("&Month View", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-month-view.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
if (calendar->mode() == GUI::Calendar::Year) if (calendar->mode() == GUI::Calendar::Year)
calendar->toggle_mode(); calendar->toggle_mode();
}); });
view_month_action->set_checked(true); view_month_action->set_checked(true);
auto view_year_action = GUI::Action::create_checkable("&Year View", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) { auto view_year_action = GUI::Action::create_checkable("&Year View", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
if (calendar->mode() == GUI::Calendar::Month) if (calendar->mode() == GUI::Calendar::Month)
calendar->toggle_mode(); calendar->toggle_mode();
}); });
@ -126,7 +126,7 @@ int main(int argc, char** argv)
}; };
auto& file_menu = window->add_menu("&File"); auto& file_menu = window->add_menu("&File");
file_menu.add_action(GUI::Action::create("&Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png"), file_menu.add_action(GUI::Action::create("&Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png").release_value_but_fixme_should_propagate_errors(),
[&](const GUI::Action&) { [&](const GUI::Action&) {
AddEventDialog::show(calendar->selected_date(), window); AddEventDialog::show(calendar->selected_date(), window);
})); }));

View file

@ -65,7 +65,7 @@ void BackgroundSettingsWidget::create_frame()
}; };
m_context_menu = GUI::Menu::construct(); m_context_menu = GUI::Menu::construct();
m_show_in_file_manager_action = GUI::Action::create("Show in File Manager", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"), [this](GUI::Action const&) { m_show_in_file_manager_action = GUI::Action::create("Show in File Manager", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), [this](GUI::Action const&) {
LexicalPath path { m_monitor_widget->wallpaper() }; LexicalPath path { m_monitor_widget->wallpaper() };
Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename())); Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename()));
}); });

View file

@ -30,7 +30,7 @@ void DesktopSettingsWidget::create_frame()
load_from_gml(desktop_settings_gml); load_from_gml(desktop_settings_gml);
auto& light_bulb_label = *find_descendant_of_type_named<GUI::Label>("light_bulb_label"); auto& light_bulb_label = *find_descendant_of_type_named<GUI::Label>("light_bulb_label");
light_bulb_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-welcome.png")); light_bulb_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-welcome.png").release_value_but_fixme_should_propagate_errors());
m_virtual_desktop_rows_spinbox = *find_descendant_of_type_named<GUI::SpinBox>("virtual_desktop_rows_spinbox"); m_virtual_desktop_rows_spinbox = *find_descendant_of_type_named<GUI::SpinBox>("virtual_desktop_rows_spinbox");
m_virtual_desktop_columns_spinbox = *find_descendant_of_type_named<GUI::SpinBox>("virtual_desktop_columns_spinbox"); m_virtual_desktop_columns_spinbox = *find_descendant_of_type_named<GUI::SpinBox>("virtual_desktop_columns_spinbox");

View file

@ -19,7 +19,7 @@ namespace DisplaySettings {
MonitorWidget::MonitorWidget() MonitorWidget::MonitorWidget()
{ {
m_desktop_resolution = GUI::Desktop::the().rect().size(); m_desktop_resolution = GUI::Desktop::the().rect().size();
m_monitor_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/monitor.png"); m_monitor_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/monitor.png").release_value_but_fixme_should_propagate_errors();
m_desktop_bitmap = Gfx::Bitmap::try_create(m_monitor_bitmap->format(), { 280, 158 }); m_desktop_bitmap = Gfx::Bitmap::try_create(m_monitor_bitmap->format(), { 280, 158 });
m_monitor_rect = { { 12, 13 }, m_desktop_bitmap->size() }; m_monitor_rect = { { 12, 13 }, m_desktop_bitmap->size() };
set_fixed_size(304, 201); set_fixed_size(304, 201);
@ -34,7 +34,7 @@ bool MonitorWidget::set_wallpaper(String path)
[path](auto&) { [path](auto&) {
RefPtr<Gfx::Bitmap> bmp; RefPtr<Gfx::Bitmap> bmp;
if (!path.is_empty()) if (!path.is_empty())
bmp = Gfx::Bitmap::try_load_from_file(path); bmp = Gfx::Bitmap::try_load_from_file(path).release_value_but_fixme_should_propagate_errors();
return bmp; return bmp;
}, },

View file

@ -534,7 +534,7 @@ void DirectoryView::handle_selection_change()
void DirectoryView::setup_actions() 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; String value;
if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecOK && !value.is_empty()) { 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)); 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; String value;
if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecOK && !value.is_empty()) { 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)); 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()); spawn_terminal(path());
}); });
@ -588,21 +588,21 @@ void DirectoryView::setup_actions()
window()); window());
m_view_as_icons_action = GUI::Action::create_checkable( 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); set_view_mode(DirectoryView::ViewMode::Icon);
Config::write_string("FileManager", "DirectoryView", "ViewMode", "Icon"); Config::write_string("FileManager", "DirectoryView", "ViewMode", "Icon");
}, },
window()); window());
m_view_as_table_action = GUI::Action::create_checkable( 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); set_view_mode(DirectoryView::ViewMode::Table);
Config::write_string("FileManager", "DirectoryView", "ViewMode", "Table"); Config::write_string("FileManager", "DirectoryView", "ViewMode", "Table");
}, },
window()); window());
m_view_as_columns_action = GUI::Action::create_checkable( 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); set_view_mode(DirectoryView::ViewMode::Columns);
Config::write_string("FileManager", "DirectoryView", "ViewMode", "Columns"); Config::write_string("FileManager", "DirectoryView", "ViewMode", "Columns");
}, },

View file

@ -39,7 +39,7 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind
set_rect({ 0, 0, 360, 420 }); set_rect({ 0, 0, 360, 420 });
set_resizable(false); 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>(); auto& tab_widget = main_widget.add<GUI::TabWidget>();

View file

@ -353,7 +353,7 @@ int run_in_desktop_mode()
auto desktop_view_context_menu = GUI::Menu::construct("Directory View"); 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(); auto paths = directory_view.selected_file_paths();
if (paths.is_empty()) { if (paths.is_empty()) {
Desktop::Launcher::open(URL::create_with_file_protocol(directory_view.path())); 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(); auto paths = directory_view.selected_file_paths();
if (paths.is_empty()) { if (paths.is_empty()) {
spawn_terminal(directory_view.path()); 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")); 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 directory_view_context_menu = GUI::Menu::construct("Directory View");
auto tree_view_directory_context_menu = GUI::Menu::construct("Tree View Directory"); 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(); 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( = GUI::Action::create(
"Open in New &Window", "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) { [&](GUI::Action const& action) {
Vector<String> paths; Vector<String> paths;
if (action.activator() == tree_view_directory_context_menu) 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( = GUI::Action::create(
"Open in &Terminal", "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) { [&](GUI::Action const& action) {
Vector<String> paths; Vector<String> paths;
if (action.activator() == tree_view_directory_context_menu) 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( = GUI::Action::create(
"Create Desktop &Shortcut", "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&) { [&](GUI::Action const&) {
auto paths = directory_view.selected_file_paths(); auto paths = directory_view.selected_file_paths();
if (paths.is_empty()) { 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); 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(); directory_view.mkdir_action().activate();
refresh_tree_view(); 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(); directory_view.touch_action().activate();
refresh_tree_view(); 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()); || !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()); directory_view.open(directory_view.selected_file_paths().first());
}); });

View file

@ -92,7 +92,7 @@ static RefPtr<GUI::Window> create_font_preview_window(FontEditorWidget& editor)
}; };
auto& reload_button = textbox_button_container.add<GUI::Button>(); auto& reload_button = textbox_button_container.add<GUI::Button>();
reload_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")); reload_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png").release_value_but_fixme_should_propagate_errors());
reload_button.set_fixed_width(22); reload_button.set_fixed_width(22);
reload_button.on_click = [&](auto) { reload_button.on_click = [&](auto) {
static int i = 1; static int i = 1;
@ -131,7 +131,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
m_glyph_editor_widget = m_glyph_editor_container->add<GlyphEditorWidget>(); m_glyph_editor_widget = m_glyph_editor_container->add<GlyphEditorWidget>();
m_glyph_map_widget = glyph_map_container.add<GlyphMapWidget>(); m_glyph_map_widget = glyph_map_container.add<GlyphMapWidget>();
m_new_action = GUI::Action::create("&New Font...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-font.png"), [&](auto&) { m_new_action = GUI::Action::create("&New Font...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-font.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
if (window()->is_modified()) { if (window()->is_modified()) {
auto result = GUI::MessageBox::show(window(), "Save changes to the current font?", "Unsaved changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); auto result = GUI::MessageBox::show(window(), "Save changes to the current font?", "Unsaved changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel);
if (result == GUI::Dialog::ExecResult::ExecYes) { if (result == GUI::Dialog::ExecResult::ExecYes) {
@ -214,7 +214,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
m_redo_action = GUI::CommonActions::make_redo_action([&](auto&) { m_redo_action = GUI::CommonActions::make_redo_action([&](auto&) {
redo(); redo();
}); });
m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [&](auto&) { m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
if (!m_font_preview_window) if (!m_font_preview_window)
m_font_preview_window = create_font_preview_window(*this); m_font_preview_window = create_font_preview_window(*this);
m_font_preview_window->show(); m_font_preview_window->show();
@ -227,7 +227,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
}); });
m_show_metadata_action->set_checked(true); m_show_metadata_action->set_checked(true);
m_show_metadata_action->set_status_tip("Show or hide metadata about the current font"); m_show_metadata_action->set_status_tip("Show or hide metadata about the current font");
m_go_to_glyph_action = GUI::Action::create("&Go to Glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"), [&](auto&) { m_go_to_glyph_action = GUI::Action::create("&Go to Glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
String input; String input;
if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to Glyph") == GUI::InputBox::ExecOK && !input.is_empty()) { if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to Glyph") == GUI::InputBox::ExecOK && !input.is_empty()) {
int code_point = strtoul(&input[0], nullptr, 16); int code_point = strtoul(&input[0], nullptr, 16);
@ -238,7 +238,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
} }
}); });
m_go_to_glyph_action->set_status_tip("Go to the specified code point"); m_go_to_glyph_action->set_status_tip("Go to the specified code point");
m_previous_glyph_action = GUI::Action::create("Pre&vious Glyph", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"), [&](auto&) { m_previous_glyph_action = GUI::Action::create("Pre&vious Glyph", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
bool search_wrapped = false; bool search_wrapped = false;
for (int i = m_glyph_map_widget->selected_glyph() - 1;; --i) { for (int i = m_glyph_map_widget->selected_glyph() - 1;; --i) {
if (i < 0 && !search_wrapped) { if (i < 0 && !search_wrapped) {
@ -256,7 +256,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
} }
}); });
m_previous_glyph_action->set_status_tip("Seek the previous visible glyph"); m_previous_glyph_action->set_status_tip("Seek the previous visible glyph");
m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), [&](auto&) { m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
bool search_wrapped = false; bool search_wrapped = false;
for (int i = m_glyph_map_widget->selected_glyph() + 1;; ++i) { for (int i = m_glyph_map_widget->selected_glyph() + 1;; ++i) {
if (i > 0x10FFFF && !search_wrapped) { if (i > 0x10FFFF && !search_wrapped) {
@ -327,7 +327,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
m_glyph_editor_widget->set_mode(GlyphEditorWidget::Paint); m_glyph_editor_widget->set_mode(GlyphEditorWidget::Paint);
}; };
move_glyph_button.set_checkable(true); move_glyph_button.set_checkable(true);
move_glyph_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png")); move_glyph_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png").release_value_but_fixme_should_propagate_errors());
GUI::Clipboard::the().on_change = [&](const String& data_type) { GUI::Clipboard::the().on_change = [&](const String& data_type) {
m_paste_action->set_enabled(data_type == "glyph/x-fonteditor"); m_paste_action->set_enabled(data_type == "glyph/x-fonteditor");

View file

@ -25,9 +25,9 @@ static ManualSectionNode s_sections[] = {
ManualModel::ManualModel() ManualModel::ManualModel()
{ {
m_section_open_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png")); m_section_open_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors());
m_section_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png")); m_section_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png").release_value_but_fixme_should_propagate_errors());
m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png")); m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png").release_value_but_fixme_should_propagate_errors());
} }
Optional<GUI::ModelIndex> ManualModel::index_from_path(const StringView& path) const Optional<GUI::ModelIndex> ManualModel::index_from_path(const StringView& path) const

View file

@ -69,7 +69,7 @@ HexEditorWidget::HexEditorWidget()
m_editor->update(); m_editor->update();
}; };
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) { m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
String value; String value;
if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:", "New file size") == GUI::InputBox::ExecOK && !value.is_empty()) { if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:", "New file size") == GUI::InputBox::ExecOK && !value.is_empty()) {
auto file_size = value.to_int(); auto file_size = value.to_int();
@ -149,7 +149,7 @@ HexEditorWidget::HexEditorWidget()
dbgln("Wrote document to {}", *response.chosen_file); dbgln("Wrote document to {}", *response.chosen_file);
}); });
m_find_action = GUI::Action::create("&Find", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [&](const GUI::Action&) { m_find_action = GUI::Action::create("&Find", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
auto old_buffer = m_search_buffer; auto old_buffer = m_search_buffer;
bool find_all = false; bool find_all = false;
if (FindDialog::show(window(), m_search_text, m_search_buffer, find_all) == GUI::InputBox::ExecOK) { if (FindDialog::show(window(), m_search_text, m_search_buffer, find_all) == GUI::InputBox::ExecOK) {
@ -186,7 +186,7 @@ HexEditorWidget::HexEditorWidget()
} }
}); });
m_goto_offset_action = GUI::Action::create("&Go to Offset ...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"), [this](const GUI::Action&) { m_goto_offset_action = GUI::Action::create("&Go to Offset ...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
int new_offset; int new_offset;
auto result = GoToOffsetDialog::show( auto result = GoToOffsetDialog::show(
window(), window(),
@ -253,7 +253,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window)
edit_menu.add_action(GUI::Action::create("Copy &Hex", { Mod_Ctrl, Key_C }, [&](const GUI::Action&) { edit_menu.add_action(GUI::Action::create("Copy &Hex", { Mod_Ctrl, Key_C }, [&](const GUI::Action&) {
m_editor->copy_selected_hex_to_clipboard(); m_editor->copy_selected_hex_to_clipboard();
})); }));
edit_menu.add_action(GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"), [&](const GUI::Action&) { edit_menu.add_action(GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
m_editor->copy_selected_text_to_clipboard(); m_editor->copy_selected_text_to_clipboard();
})); }));
edit_menu.add_action(GUI::Action::create("Copy as &C Code", { Mod_Alt | Mod_Shift, Key_C }, [&](const GUI::Action&) { edit_menu.add_action(GUI::Action::create("Copy as &C Code", { Mod_Alt | Mod_Shift, Key_C }, [&](const GUI::Action&) {
@ -261,7 +261,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window)
})); }));
edit_menu.add_separator(); edit_menu.add_separator();
edit_menu.add_action(*m_find_action); edit_menu.add_action(*m_find_action);
edit_menu.add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png"), [&](const GUI::Action&) { edit_menu.add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
if (m_search_text.is_empty() || m_search_buffer.is_empty()) { if (m_search_text.is_empty() || m_search_buffer.is_empty()) {
GUI::MessageBox::show(&window, "Nothing to search for", "Not found", GUI::MessageBox::Type::Warning); GUI::MessageBox::show(&window, "Nothing to search for", "Not found", GUI::MessageBox::Type::Warning);
return; return;
@ -276,7 +276,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window)
m_last_found_index = result.value(); m_last_found_index = result.value();
})); }));
edit_menu.add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [&](const GUI::Action&) { edit_menu.add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
int min_length = 4; int min_length = 4;
auto matches = m_editor->find_all_strings(min_length); auto matches = m_editor->find_all_strings(min_length);
m_search_results->set_model(*new SearchResultsModel(move(matches))); m_search_results->set_model(*new SearchResultsModel(move(matches)));

View file

@ -187,22 +187,22 @@ int main(int argc, char** argv)
GUI::Desktop::the().set_wallpaper(widget.path()); GUI::Desktop::the().set_wallpaper(widget.path());
}); });
auto go_first_action = GUI::Action::create("&Go to First", { Mod_None, Key_Home }, 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 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-first.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
widget.navigate(ViewWidget::Directions::First); widget.navigate(ViewWidget::Directions::First);
}); });
auto go_back_action = GUI::Action::create("Go &Back", { Mod_None, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"), auto go_back_action = GUI::Action::create("Go &Back", { Mod_None, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
widget.navigate(ViewWidget::Directions::Back); widget.navigate(ViewWidget::Directions::Back);
}); });
auto go_forward_action = GUI::Action::create("Go &Forward", { Mod_None, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), auto go_forward_action = GUI::Action::create("Go &Forward", { Mod_None, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
widget.navigate(ViewWidget::Directions::Forward); widget.navigate(ViewWidget::Directions::Forward);
}); });
auto go_last_action = GUI::Action::create("Go to &Last", { Mod_None, Key_End }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png"), auto go_last_action = GUI::Action::create("Go to &Last", { Mod_None, Key_End }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
widget.navigate(ViewWidget::Directions::Last); widget.navigate(ViewWidget::Directions::Last);
}); });

View file

@ -10,9 +10,9 @@
MailboxTreeModel::MailboxTreeModel(AccountHolder const& account_holder) MailboxTreeModel::MailboxTreeModel(AccountHolder const& account_holder)
: m_account_holder(account_holder) : m_account_holder(account_holder)
{ {
m_mail_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mail.png")); m_mail_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mail.png").release_value_but_fixme_should_propagate_errors());
m_folder_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-folder.png")); m_folder_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-folder.png").release_value_but_fixme_should_propagate_errors());
m_account_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/home-directory.png")); m_account_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/home-directory.png").release_value_but_fixme_should_propagate_errors());
} }
MailboxTreeModel::~MailboxTreeModel() MailboxTreeModel::~MailboxTreeModel()

View file

@ -57,10 +57,10 @@ MailSettingsWindow::MailSettingsWindow()
mail_widget.load_from_gml(mail_settings_window_gml); mail_widget.load_from_gml(mail_settings_window_gml);
auto& server_settings_image_label = *main_widget.find_descendant_of_type_named<GUI::Label>("server_settings_image_label"); auto& server_settings_image_label = *main_widget.find_descendant_of_type_named<GUI::Label>("server_settings_image_label");
server_settings_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mail-server-settings.png")); server_settings_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mail-server-settings.png").release_value_but_fixme_should_propagate_errors());
auto& user_settings_image_label = *main_widget.find_descendant_of_type_named<GUI::Label>("user_settings_image_label"); auto& user_settings_image_label = *main_widget.find_descendant_of_type_named<GUI::Label>("user_settings_image_label");
user_settings_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mail-user-settings.png")); user_settings_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mail-user-settings.png").release_value_but_fixme_should_propagate_errors());
m_server_inputbox = *main_widget.find_descendant_of_type_named<GUI::TextBox>("server_input"); m_server_inputbox = *main_widget.find_descendant_of_type_named<GUI::TextBox>("server_input");
m_server_inputbox->set_text(Config::read_string("Mail", "Connection", "Server", "")); m_server_inputbox->set_text(Config::read_string("Mail", "Connection", "Server", ""));

View file

@ -27,7 +27,7 @@ void DoubleClickArrowWidget::set_double_click_speed(int speed)
DoubleClickArrowWidget::DoubleClickArrowWidget() DoubleClickArrowWidget::DoubleClickArrowWidget()
{ {
m_arrow_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/double-click-down-arrow.png"); m_arrow_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/double-click-down-arrow.png").release_value_but_fixme_should_propagate_errors();
} }
void DoubleClickArrowWidget::paint_event(GUI::PaintEvent& event) void DoubleClickArrowWidget::paint_event(GUI::PaintEvent& event)

View file

@ -32,10 +32,10 @@ MouseWidget::MouseWidget()
m_speed_slider->set_value(slider_value); m_speed_slider->set_value(slider_value);
auto& cursor_speed_image_label = *find_descendant_of_type_named<GUI::Label>("cursor_speed_image_label"); auto& cursor_speed_image_label = *find_descendant_of_type_named<GUI::Label>("cursor_speed_image_label");
cursor_speed_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mouse-cursor-speed.png")); cursor_speed_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mouse-cursor-speed.png").release_value_but_fixme_should_propagate_errors());
auto& scroll_step_size_image_label = *find_descendant_of_type_named<GUI::Label>("scroll_step_size_image_label"); auto& scroll_step_size_image_label = *find_descendant_of_type_named<GUI::Label>("scroll_step_size_image_label");
scroll_step_size_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/scroll-wheel-step-size.png")); scroll_step_size_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/scroll-wheel-step-size.png").release_value_but_fixme_should_propagate_errors());
m_scroll_length_spinbox = *find_descendant_of_type_named<GUI::SpinBox>("scroll_length_spinbox"); m_scroll_length_spinbox = *find_descendant_of_type_named<GUI::SpinBox>("scroll_length_spinbox");
m_scroll_length_spinbox->set_min(WindowServer::scroll_step_size_min); m_scroll_length_spinbox->set_min(WindowServer::scroll_step_size_min);
@ -54,7 +54,7 @@ MouseWidget::MouseWidget()
m_switch_buttons_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("switch_buttons_input"); m_switch_buttons_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("switch_buttons_input");
m_switch_buttons_checkbox->set_checked(GUI::WindowServerConnection::the().get_buttons_switched()); m_switch_buttons_checkbox->set_checked(GUI::WindowServerConnection::the().get_buttons_switched());
auto& switch_buttons_image_label = *find_descendant_of_type_named<GUI::Label>("switch_buttons_image_label"); auto& switch_buttons_image_label = *find_descendant_of_type_named<GUI::Label>("switch_buttons_image_label");
switch_buttons_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/switch-mouse-buttons.png")); switch_buttons_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/switch-mouse-buttons.png").release_value_but_fixme_should_propagate_errors());
} }
void MouseWidget::update_window_server() void MouseWidget::update_window_server()

View file

@ -63,7 +63,7 @@ void MouseCursorModel::invalidate()
cursor.name = LexicalPath::basename(cursor.path); cursor.name = LexicalPath::basename(cursor.path);
// FIXME: Animated cursor bitmaps // FIXME: Animated cursor bitmaps
auto cursor_bitmap = Gfx::Bitmap::try_load_from_file(cursor.path); auto cursor_bitmap = Gfx::Bitmap::try_load_from_file(cursor.path).release_value_but_fixme_should_propagate_errors();
auto cursor_bitmap_rect = cursor_bitmap->rect(); auto cursor_bitmap_rect = cursor_bitmap->rect();
cursor.params = Gfx::CursorParams::parse_from_filename(cursor.name, cursor_bitmap_rect.center()).constrained(*cursor_bitmap); cursor.params = Gfx::CursorParams::parse_from_filename(cursor.name, cursor_bitmap_rect.center()).constrained(*cursor_bitmap);
cursor.bitmap = cursor_bitmap->cropped(Gfx::IntRect(Gfx::FloatRect(cursor_bitmap_rect).scaled(1.0 / cursor.params.frames(), 1.0))).release_value_but_fixme_should_propagate_errors(); cursor.bitmap = cursor_bitmap->cropped(Gfx::IntRect(Gfx::FloatRect(cursor_bitmap_rect).scaled(1.0 / cursor.params.frames(), 1.0))).release_value_but_fixme_should_propagate_errors();

View file

@ -15,8 +15,8 @@ NonnullRefPtr<OutlineModel> OutlineModel::create(const NonnullRefPtr<PDF::Outlin
OutlineModel::OutlineModel(const NonnullRefPtr<PDF::OutlineDict>& outline) OutlineModel::OutlineModel(const NonnullRefPtr<PDF::OutlineDict>& outline)
: m_outline(outline) : m_outline(outline)
{ {
m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png")); m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png").release_value_but_fixme_should_propagate_errors());
m_open_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png")); m_open_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors());
} }
void OutlineModel::set_index_open_state(const GUI::ModelIndex& index, bool is_open) void OutlineModel::set_index_open_state(const GUI::ModelIndex& index, bool is_open)

View file

@ -66,7 +66,7 @@ void PDFViewerWidget::create_toolbar()
auto& toolbar = toolbar_container.add<GUI::Toolbar>(); auto& toolbar = toolbar_container.add<GUI::Toolbar>();
auto open_outline_action = GUI::Action::create( auto open_outline_action = GUI::Action::create(
"Open &Sidebar", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/sidebar.png"), [&](auto& action) { "Open &Sidebar", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/sidebar.png").release_value_but_fixme_should_propagate_errors(), [&](auto& action) {
m_sidebar_open = !m_sidebar_open; m_sidebar_open = !m_sidebar_open;
m_sidebar->set_fixed_width(m_sidebar_open ? 0 : 200); m_sidebar->set_fixed_width(m_sidebar_open ? 0 : 200);
action.set_text(m_sidebar_open ? "Open &Sidebar" : "Close &Sidebar"); action.set_text(m_sidebar_open ? "Open &Sidebar" : "Close &Sidebar");
@ -78,13 +78,13 @@ void PDFViewerWidget::create_toolbar()
toolbar.add_action(*open_outline_action); toolbar.add_action(*open_outline_action);
toolbar.add_separator(); toolbar.add_separator();
m_go_to_prev_page_action = GUI::Action::create("Go to &Previous Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-up.png"), [&](auto&) { m_go_to_prev_page_action = GUI::Action::create("Go to &Previous Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-up.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
VERIFY(m_viewer->current_page() > 0); VERIFY(m_viewer->current_page() > 0);
m_page_text_box->set_current_number(m_viewer->current_page()); m_page_text_box->set_current_number(m_viewer->current_page());
}); });
m_go_to_prev_page_action->set_enabled(false); m_go_to_prev_page_action->set_enabled(false);
m_go_to_next_page_action = GUI::Action::create("Go to &Next Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-down.png"), [&](auto&) { m_go_to_next_page_action = GUI::Action::create("Go to &Next Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-down.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
VERIFY(m_viewer->current_page() < m_viewer->document()->get_page_count() - 1); VERIFY(m_viewer->current_page() < m_viewer->document()->get_page_count() - 1);
m_page_text_box->set_current_number(m_viewer->current_page() + 2); m_page_text_box->set_current_number(m_viewer->current_page() + 2);
}); });

View file

@ -19,10 +19,10 @@ PlayerWidget::PlayerWidget(TrackManager& manager, AudioPlayerLoop& loop)
set_layout<GUI::HorizontalBoxLayout>(); set_layout<GUI::HorizontalBoxLayout>();
set_fill_with_background_color(true); set_fill_with_background_color(true);
m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"); m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png").release_value_but_fixme_should_propagate_errors();
m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"); m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png").release_value_but_fixme_should_propagate_errors();
m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"); // Go back a note m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(); // Go back a note
m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"); // Advance a note m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(); // Advance a note
m_play_button = add<GUI::Button>(); m_play_button = add<GUI::Button>();
m_play_button->set_icon(*m_pause_icon); m_play_button->set_icon(*m_pause_icon);

View file

@ -84,7 +84,7 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager)
m_open_button = m_open_button_and_recorded_sample_name_container->add<GUI::Button>(); m_open_button = m_open_button_and_recorded_sample_name_container->add<GUI::Button>();
m_open_button->set_fixed_size(24, 24); m_open_button->set_fixed_size(24, 24);
m_open_button->set_focus_policy(GUI::FocusPolicy::TabFocus); m_open_button->set_focus_policy(GUI::FocusPolicy::TabFocus);
m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png")); m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors());
m_open_button->on_click = [this](auto) { m_open_button->on_click = [this](auto) {
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window()); Optional<String> open_path = GUI::FilePicker::get_open_filepath(window());
if (!open_path.has_value()) if (!open_path.has_value())

View file

@ -91,7 +91,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
auto& file_menu = window.add_menu("&File"); auto& file_menu = window.add_menu("&File");
m_new_image_action = GUI::Action::create( m_new_image_action = GUI::Action::create(
"&New Image...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [&](auto&) { "&New Image...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto dialog = PixelPaint::CreateNewImageDialog::construct(&window); auto dialog = PixelPaint::CreateNewImageDialog::construct(&window);
if (dialog->exec() == GUI::Dialog::ExecOK) { if (dialog->exec() == GUI::Dialog::ExecOK) {
auto image = PixelPaint::Image::try_create_with_size(dialog->image_size()); auto image = PixelPaint::Image::try_create_with_size(dialog->image_size());
@ -198,7 +198,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
}); });
m_copy_merged_action = GUI::Action::create( m_copy_merged_action = GUI::Action::create(
"Copy &Merged", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"), "Copy &Merged", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
auto* editor = current_image_editor(); auto* editor = current_image_editor();
if (!editor) if (!editor)
@ -434,7 +434,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
auto& layer_menu = window.add_menu("&Layer"); auto& layer_menu = window.add_menu("&Layer");
layer_menu.add_action(GUI::Action::create( layer_menu.add_action(GUI::Action::create(
"New &Layer...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-layer.png"), [&](auto&) { "New &Layer...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-layer.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto* editor = current_image_editor(); auto* editor = current_image_editor();
if (!editor) if (!editor)
return; return;
@ -461,11 +461,11 @@ void MainWidget::initialize_menubar(GUI::Window& window)
m_layer_list_widget->cycle_through_selection(-1); m_layer_list_widget->cycle_through_selection(-1);
})); }));
layer_menu.add_action(GUI::Action::create( layer_menu.add_action(GUI::Action::create(
"Select &Top Layer", { 0, Key_Home }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/top-layer.png"), [&](auto&) { "Select &Top Layer", { 0, Key_Home }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/top-layer.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_layer_list_widget->select_top_layer(); m_layer_list_widget->select_top_layer();
})); }));
layer_menu.add_action(GUI::Action::create( layer_menu.add_action(GUI::Action::create(
"Select B&ottom Layer", { 0, Key_End }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bottom-layer.png"), [&](auto&) { "Select B&ottom Layer", { 0, Key_End }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bottom-layer.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_layer_list_widget->select_bottom_layer(); m_layer_list_widget->select_bottom_layer();
})); }));
layer_menu.add_separator(); layer_menu.add_separator();
@ -514,7 +514,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
})); }));
layer_menu.add_separator(); layer_menu.add_separator();
layer_menu.add_action(GUI::Action::create( layer_menu.add_action(GUI::Action::create(
"&Remove Active Layer", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), [&](auto&) { "&Remove Active Layer", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto* editor = current_image_editor(); auto* editor = current_image_editor();
if (!editor) if (!editor)
return; return;

View file

@ -52,7 +52,7 @@ ToolboxWidget::~ToolboxWidget()
void ToolboxWidget::setup_tools() void ToolboxWidget::setup_tools()
{ {
auto add_tool = [&](String name, StringView const& icon_name, GUI::Shortcut const& shortcut, NonnullOwnPtr<Tool> tool) { auto add_tool = [&](String name, StringView const& icon_name, GUI::Shortcut const& shortcut, NonnullOwnPtr<Tool> tool) {
auto action = GUI::Action::create_checkable(move(name), shortcut, Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/pixelpaint/{}.png", icon_name)), auto action = GUI::Action::create_checkable(move(name), shortcut, Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/pixelpaint/{}.png", icon_name)).release_value_but_fixme_should_propagate_errors(),
[this, tool = tool.ptr()](auto& action) { [this, tool = tool.ptr()](auto& action) {
if (action.is_checked()) { if (action.is_checked()) {
on_tool_selection(tool); on_tool_selection(tool);

View file

@ -20,9 +20,7 @@ namespace PixelPaint {
BucketTool::BucketTool() BucketTool::BucketTool()
{ {
auto bucket_icon = Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/bucket.png"); m_cursor = Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/bucket.png").release_value_but_fixme_should_propagate_errors();
if (!bucket_icon.is_null())
m_cursor = bucket_icon.release_nonnull();
} }
BucketTool::~BucketTool() BucketTool::~BucketTool()

View file

@ -142,7 +142,7 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event)
if (!m_context_menu) { if (!m_context_menu) {
m_context_menu = GUI::Menu::construct(); m_context_menu = GUI::Menu::construct();
m_context_menu->add_action(GUI::Action::create( m_context_menu->add_action(GUI::Action::create(
"Set &Offset", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/gear.png"), [this](auto&) { "Set &Offset", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/gear.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (!m_context_menu_guide) if (!m_context_menu_guide)
return; return;
auto dialog = EditGuideDialog::construct( auto dialog = EditGuideDialog::construct(
@ -160,7 +160,7 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event)
}, },
editor())); editor()));
m_context_menu->add_action(GUI::Action::create( m_context_menu->add_action(GUI::Action::create(
"&Delete Guide", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), [this](auto&) { "&Delete Guide", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (!m_context_menu_guide) if (!m_context_menu_guide)
return; return;
editor()->remove_guide(*m_context_menu_guide); editor()->remove_guide(*m_context_menu_guide);

View file

@ -20,11 +20,9 @@ void NoVisualizationWidget::paint_event(GUI::PaintEvent& event)
Frame::paint_event(event); Frame::paint_event(event);
GUI::Painter painter(*this); GUI::Painter painter(*this);
if (m_serenity_bg.is_null()) { if (!m_serenity_bg)
m_serenity_bg = Gfx::Bitmap::try_load_from_file("/res/wallpapers/sunset-retro.png"); m_serenity_bg = Gfx::Bitmap::try_load_from_file("/res/wallpapers/sunset-retro.png").release_value_but_fixme_should_propagate_errors();
}
painter.draw_scaled_bitmap(frame_inner_rect(), *m_serenity_bg, m_serenity_bg->rect(), 1.0f); painter.draw_scaled_bitmap(frame_inner_rect(), *m_serenity_bg, m_serenity_bg->rect(), 1.0f);
return;
} }
void NoVisualizationWidget::set_buffer(RefPtr<Audio::Buffer>) void NoVisualizationWidget::set_buffer(RefPtr<Audio::Buffer>)

View file

@ -43,11 +43,11 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window
m_player_view->set_layout<GUI::VerticalBoxLayout>(); m_player_view->set_layout<GUI::VerticalBoxLayout>();
m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"); m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png").release_value_but_fixme_should_propagate_errors();
m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"); m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png").release_value_but_fixme_should_propagate_errors();
m_stop_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop.png"); m_stop_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop.png").release_value_but_fixme_should_propagate_errors();
m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"); m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors();
m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"); m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors();
m_visualization = m_player_view->add<BarsVisualizationWidget>(); m_visualization = m_player_view->add<BarsVisualizationWidget>();

View file

@ -332,14 +332,14 @@ int main(int argc, char* argv[])
help_menu.add_action(GUI::CommonActions::make_about_action(APP_NAME, app_icon, window)); help_menu.add_action(GUI::CommonActions::make_about_action(APP_NAME, app_icon, window));
// Configure the nodes context menu. // Configure the nodes context menu.
auto open_folder_action = GUI::Action::create("Open Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), [&](auto&) { auto open_folder_action = GUI::Action::create("Open Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
Desktop::Launcher::open(URL::create_with_file_protocol(get_absolute_path_to_selected_node(treemapwidget))); Desktop::Launcher::open(URL::create_with_file_protocol(get_absolute_path_to_selected_node(treemapwidget)));
}); });
auto open_containing_folder_action = GUI::Action::create("Open Containing Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), [&](auto&) { auto open_containing_folder_action = GUI::Action::create("Open Containing Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
LexicalPath path { get_absolute_path_to_selected_node(treemapwidget) }; LexicalPath path { get_absolute_path_to_selected_node(treemapwidget) };
Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename())); Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename()));
}); });
auto copy_path_action = GUI::Action::create("Copy Path to Clipboard", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"), [&](auto&) { auto copy_path_action = GUI::Action::create("Copy Path to Clipboard", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
GUI::Clipboard::the().set_plain_text(get_absolute_path_to_selected_node(treemapwidget)); GUI::Clipboard::the().set_plain_text(get_absolute_path_to_selected_node(treemapwidget));
}); });
auto delete_action = GUI::CommonActions::make_delete_action([&](auto&) { auto delete_action = GUI::CommonActions::make_delete_action([&](auto&) {

View file

@ -63,7 +63,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
{ {
resize(530, 365); resize(530, 365);
set_title("Spreadsheet Functions Help"); set_title("Spreadsheet Functions Help");
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png")); set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors());
set_accessory(true); set_accessory(true);
auto& widget = set_main_widget<GUI::Widget>(); auto& widget = set_main_widget<GUI::Widget>();

View file

@ -114,7 +114,7 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s
setup_tabs(m_workbook->sheets()); setup_tabs(m_workbook->sheets());
m_new_action = GUI::Action::create("Add New Sheet", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"), [&](auto&) { m_new_action = GUI::Action::create("Add New Sheet", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
add_sheet(); add_sheet();
}); });

View file

@ -19,8 +19,8 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
layout()->set_margins(4); layout()->set_margins(4);
set_fill_with_background_color(true); set_fill_with_background_color(true);
m_network_connected_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-connected.png"); m_network_connected_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-connected.png").release_value_but_fixme_should_propagate_errors();
m_network_disconnected_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-disconnected.png"); m_network_disconnected_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-disconnected.png").release_value_but_fixme_should_propagate_errors();
m_network_link_down_bitmap = Gfx::Bitmap::try_create(m_network_connected_bitmap->format(), m_network_connected_bitmap->size()); m_network_link_down_bitmap = Gfx::Bitmap::try_create(m_network_connected_bitmap->format(), m_network_connected_bitmap->size());
{ {

View file

@ -255,7 +255,7 @@ int main(int argc, char** argv)
}; };
auto kill_action = GUI::Action::create( auto kill_action = GUI::Action::create(
"&Kill Process", { Mod_Ctrl, Key_K }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/kill.png"), [&](const GUI::Action&) { "&Kill Process", { Mod_Ctrl, Key_K }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/kill.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
pid_t pid = selected_id(ProcessModel::Column::PID); pid_t pid = selected_id(ProcessModel::Column::PID);
if (pid != -1) if (pid != -1)
kill(pid, SIGKILL); kill(pid, SIGKILL);
@ -263,7 +263,7 @@ int main(int argc, char** argv)
&process_table_view); &process_table_view);
auto stop_action = GUI::Action::create( auto stop_action = GUI::Action::create(
"&Stop Process", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop-hand.png"), [&](const GUI::Action&) { "&Stop Process", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop-hand.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
pid_t pid = selected_id(ProcessModel::Column::PID); pid_t pid = selected_id(ProcessModel::Column::PID);
if (pid != -1) if (pid != -1)
kill(pid, SIGSTOP); kill(pid, SIGSTOP);
@ -271,7 +271,7 @@ int main(int argc, char** argv)
&process_table_view); &process_table_view);
auto continue_action = GUI::Action::create( auto continue_action = GUI::Action::create(
"&Continue Process", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/continue.png"), [&](const GUI::Action&) { "&Continue Process", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/continue.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
pid_t pid = selected_id(ProcessModel::Column::PID); pid_t pid = selected_id(ProcessModel::Column::PID);
if (pid != -1) if (pid != -1)
kill(pid, SIGCONT); kill(pid, SIGCONT);
@ -280,7 +280,7 @@ int main(int argc, char** argv)
auto profile_action = GUI::Action::create( auto profile_action = GUI::Action::create(
"&Profile Process", { Mod_Ctrl, Key_P }, "&Profile Process", { Mod_Ctrl, Key_P },
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png"), [&](auto&) { Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
pid_t pid = selected_id(ProcessModel::Column::PID); pid_t pid = selected_id(ProcessModel::Column::PID);
if (pid != -1) { if (pid != -1) {
auto pid_string = String::number(pid); auto pid_string = String::number(pid);

View file

@ -202,10 +202,10 @@ static RefPtr<GUI::Window> create_find_window(VT::TerminalWidget& terminal)
find_textbox.set_text(terminal.selected_text().replace("\n", " ", true)); find_textbox.set_text(terminal.selected_text().replace("\n", " ", true));
auto& find_backwards = find.add<GUI::Button>(); auto& find_backwards = find.add<GUI::Button>();
find_backwards.set_fixed_width(25); find_backwards.set_fixed_width(25);
find_backwards.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png")); find_backwards.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png").release_value_but_fixme_should_propagate_errors());
auto& find_forwards = find.add<GUI::Button>(); auto& find_forwards = find.add<GUI::Button>();
find_forwards.set_fixed_width(25); find_forwards.set_fixed_width(25);
find_forwards.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png")); find_forwards.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").release_value_but_fixme_should_propagate_errors());
find_textbox.on_return_pressed = [&]() { find_textbox.on_return_pressed = [&]() {
find_backwards.click(); find_backwards.click();
@ -345,7 +345,7 @@ int main(int argc, char** argv)
auto new_scrollback_size = Config::read_i32("Terminal", "Terminal", "MaxHistorySize", terminal.max_history_size()); auto new_scrollback_size = Config::read_i32("Terminal", "Terminal", "MaxHistorySize", terminal.max_history_size());
terminal.set_max_history_size(new_scrollback_size); terminal.set_max_history_size(new_scrollback_size);
auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"), auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png").release_value_but_fixme_should_propagate_errors(),
[&](const GUI::Action&) { [&](const GUI::Action&) {
if (!settings_window) if (!settings_window)
settings_window = create_settings_window(terminal); settings_window = create_settings_window(terminal);
@ -369,7 +369,7 @@ int main(int argc, char** argv)
}); });
terminal.context_menu().add_separator(); terminal.context_menu().add_separator();
auto pick_font_action = GUI::Action::create("&Terminal Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"), auto pick_font_action = GUI::Action::create("&Terminal Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
auto picker = GUI::FontPicker::construct(window, &terminal.font(), true); auto picker = GUI::FontPicker::construct(window, &terminal.font(), true);
if (picker->exec() == GUI::Dialog::ExecOK) { if (picker->exec() == GUI::Dialog::ExecOK) {
@ -385,7 +385,7 @@ int main(int argc, char** argv)
terminal.context_menu().add_action(open_settings_action); terminal.context_menu().add_action(open_settings_action);
auto& file_menu = window->add_menu("&File"); auto& file_menu = window->add_menu("&File");
file_menu.add_action(GUI::Action::create("Open New &Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { file_menu.add_action(GUI::Action::create("Open New &Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
Core::Process::spawn("/bin/Terminal"); Core::Process::spawn("/bin/Terminal");
})); }));
@ -400,7 +400,7 @@ int main(int argc, char** argv)
edit_menu.add_action(terminal.copy_action()); edit_menu.add_action(terminal.copy_action());
edit_menu.add_action(terminal.paste_action()); edit_menu.add_action(terminal.paste_action());
edit_menu.add_separator(); edit_menu.add_separator();
edit_menu.add_action(GUI::Action::create("&Find...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), edit_menu.add_action(GUI::Action::create("&Find...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
if (!find_window) if (!find_window)
find_window = create_find_window(terminal); find_window = create_find_window(terminal);

View file

@ -92,7 +92,7 @@ MainWidget::MainWidget()
}; };
m_wrap_around_checkbox->set_checked(true); m_wrap_around_checkbox->set_checked(true);
m_find_next_action = GUI::Action::create("Find &Next", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png"), [&](auto&) { m_find_next_action = GUI::Action::create("Find &Next", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto needle = m_find_textbox->text(); auto needle = m_find_textbox->text();
if (needle.is_empty()) if (needle.is_empty())
return; return;
@ -111,7 +111,7 @@ MainWidget::MainWidget()
} }
}); });
m_find_previous_action = GUI::Action::create("Find Pr&evious", { Mod_Ctrl | Mod_Shift, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png"), [&](auto&) { m_find_previous_action = GUI::Action::create("Find Pr&evious", { Mod_Ctrl | Mod_Shift, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto needle = m_find_textbox->text(); auto needle = m_find_textbox->text();
if (needle.is_empty()) if (needle.is_empty())
return; return;
@ -174,11 +174,11 @@ MainWidget::MainWidget()
m_find_previous_button = *find_descendant_of_type_named<GUI::Button>("find_previous_button"); m_find_previous_button = *find_descendant_of_type_named<GUI::Button>("find_previous_button");
m_find_previous_button->set_action(*m_find_previous_action); m_find_previous_button->set_action(*m_find_previous_action);
m_find_previous_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png")); m_find_previous_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png").release_value_but_fixme_should_propagate_errors());
m_find_next_button = *find_descendant_of_type_named<GUI::Button>("find_next_button"); m_find_next_button = *find_descendant_of_type_named<GUI::Button>("find_next_button");
m_find_next_button->set_action(*m_find_next_action); m_find_next_button->set_action(*m_find_next_action);
m_find_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png")); m_find_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png").release_value_but_fixme_should_propagate_errors());
m_find_textbox->on_return_pressed = [this] { m_find_textbox->on_return_pressed = [this] {
m_find_next_button->click(); m_find_next_button->click();
@ -212,7 +212,7 @@ MainWidget::MainWidget()
}); });
m_vim_emulation_setting_action->set_checked(false); m_vim_emulation_setting_action->set_checked(false);
m_find_replace_action = GUI::Action::create("&Find/Replace...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [this](auto&) { m_find_replace_action = GUI::Action::create("&Find/Replace...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
m_find_replace_widget->set_visible(true); m_find_replace_widget->set_visible(true);
m_find_widget->set_visible(true); m_find_widget->set_visible(true);
m_replace_widget->set_visible(true); m_replace_widget->set_visible(true);
@ -245,7 +245,7 @@ MainWidget::MainWidget()
m_editor->on_cursor_change = [this] { update_statusbar(); }; m_editor->on_cursor_change = [this] { update_statusbar(); };
m_editor->on_selection_change = [this] { update_statusbar(); }; m_editor->on_selection_change = [this] { update_statusbar(); };
m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [this](GUI::Action const&) { m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [this](GUI::Action const&) {
if (editor().document().is_modified()) { if (editor().document().is_modified()) {
auto save_document_first_result = GUI::MessageBox::show(window(), "Save changes to current document first?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); auto save_document_first_result = GUI::MessageBox::show(window(), "Save changes to current document first?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel);
if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes) if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes)
@ -448,7 +448,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
view_menu.add_separator(); view_menu.add_separator();
view_menu.add_action(GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"), view_menu.add_action(GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
auto picker = GUI::FontPicker::construct(&window, &m_editor->font(), false); auto picker = GUI::FontPicker::construct(&window, &m_editor->font(), false);
if (picker->exec() == GUI::Dialog::ExecOK) { if (picker->exec() == GUI::Dialog::ExecOK) {

View file

@ -79,12 +79,12 @@ private:
PreviewWidget::PreviewWidget(const Gfx::Palette& preview_palette) PreviewWidget::PreviewWidget(const Gfx::Palette& preview_palette)
: m_preview_palette(preview_palette) : m_preview_palette(preview_palette)
{ {
m_active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); m_active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors();
m_inactive_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); m_inactive_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors();
m_default_close_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png"); m_default_close_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png").release_value_but_fixme_should_propagate_errors();
m_default_maximize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png"); m_default_maximize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png").release_value_but_fixme_should_propagate_errors();
m_default_minimize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png"); m_default_minimize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").release_value_but_fixme_should_propagate_errors();
VERIFY(m_active_window_icon); VERIFY(m_active_window_icon);
VERIFY(m_inactive_window_icon); VERIFY(m_inactive_window_icon);
@ -105,15 +105,17 @@ PreviewWidget::~PreviewWidget()
void PreviewWidget::load_theme_bitmaps() void PreviewWidget::load_theme_bitmaps()
{ {
auto load_bitmap = [](String const& path, String& last_path, RefPtr<Gfx::Bitmap>& bitmap) { auto load_bitmap = [](String const& path, String& last_path, RefPtr<Gfx::Bitmap>& bitmap) {
bitmap = nullptr;
if (path.is_empty()) { if (path.is_empty()) {
last_path = String::empty(); last_path = String::empty();
bitmap = nullptr;
} else if (last_path != path) { } else if (last_path != path) {
bitmap = Gfx::Bitmap::try_load_from_file(path); auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(path);
if (bitmap) if (bitmap_or_error.is_error()) {
last_path = path;
else
last_path = String::empty(); last_path = String::empty();
} else {
last_path = path;
bitmap = bitmap_or_error.release_value();
}
} }
}; };

View file

@ -30,14 +30,14 @@ WelcomeWidget::WelcomeWidget()
tip_frame.set_fill_with_background_color(true); tip_frame.set_fill_with_background_color(true);
auto& light_bulb_label = *find_descendant_of_type_named<GUI::Label>("light_bulb_label"); auto& light_bulb_label = *find_descendant_of_type_named<GUI::Label>("light_bulb_label");
light_bulb_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-welcome.png")); light_bulb_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-welcome.png").release_value_but_fixme_should_propagate_errors());
m_web_view = *find_descendant_of_type_named<Web::OutOfProcessWebView>("web_view"); m_web_view = *find_descendant_of_type_named<Web::OutOfProcessWebView>("web_view");
m_tip_label = *find_descendant_of_type_named<GUI::Label>("tip_label"); m_tip_label = *find_descendant_of_type_named<GUI::Label>("tip_label");
m_next_button = *find_descendant_of_type_named<GUI::Button>("next_button"); m_next_button = *find_descendant_of_type_named<GUI::Button>("next_button");
m_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")); m_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors());
m_next_button->on_click = [&](auto) { m_next_button->on_click = [&](auto) {
if (!tip_frame.is_visible()) { if (!tip_frame.is_visible()) {
m_web_view->set_visible(false); m_web_view->set_visible(false);
@ -52,7 +52,7 @@ WelcomeWidget::WelcomeWidget()
}; };
m_help_button = *find_descendant_of_type_named<GUI::Button>("help_button"); m_help_button = *find_descendant_of_type_named<GUI::Button>("help_button");
m_help_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png")); m_help_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors());
m_help_button->on_click = [](auto) { m_help_button->on_click = [](auto) {
Core::Process::spawn("/bin/Help"sv); Core::Process::spawn("/bin/Help"sv);
}; };

View file

@ -49,28 +49,28 @@ private:
bool m_up, m_down, m_left, m_right, m_sleeping = false; bool m_up, m_down, m_left, m_right, m_sleeping = false;
bool m_roaming { true }; bool m_roaming { true };
AK::NonnullRefPtr<Gfx::Bitmap> m_alert = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/alert.png"); NonnullRefPtr<Gfx::Bitmap> m_alert = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/alert.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_erun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun1.png"); NonnullRefPtr<Gfx::Bitmap> m_erun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun1.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_erun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun2.png"); NonnullRefPtr<Gfx::Bitmap> m_erun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun2.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_nerun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun1.png"); NonnullRefPtr<Gfx::Bitmap> m_nerun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun1.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_nerun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun2.png"); NonnullRefPtr<Gfx::Bitmap> m_nerun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun2.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_nrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun1.png"); NonnullRefPtr<Gfx::Bitmap> m_nrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun1.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_nrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun2.png"); NonnullRefPtr<Gfx::Bitmap> m_nrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun2.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_nwrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun1.png"); NonnullRefPtr<Gfx::Bitmap> m_nwrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun1.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_nwrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun2.png"); NonnullRefPtr<Gfx::Bitmap> m_nwrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun2.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_serun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun1.png"); NonnullRefPtr<Gfx::Bitmap> m_serun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun1.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_serun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun2.png"); NonnullRefPtr<Gfx::Bitmap> m_serun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun2.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_sleep1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep1.png"); NonnullRefPtr<Gfx::Bitmap> m_sleep1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep1.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_sleep2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep2.png"); NonnullRefPtr<Gfx::Bitmap> m_sleep2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep2.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_srun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun1.png"); NonnullRefPtr<Gfx::Bitmap> m_srun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun1.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_srun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun2.png"); NonnullRefPtr<Gfx::Bitmap> m_srun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun2.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_still = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/still.png"); NonnullRefPtr<Gfx::Bitmap> m_still = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/still.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_swrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun1.png"); NonnullRefPtr<Gfx::Bitmap> m_swrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun1.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_swrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun2.png"); NonnullRefPtr<Gfx::Bitmap> m_swrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun2.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_wrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun1.png"); NonnullRefPtr<Gfx::Bitmap> m_wrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun1.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_wrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun2.png"); NonnullRefPtr<Gfx::Bitmap> m_wrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun2.png").release_value_but_fixme_should_propagate_errors();
AK::NonnullRefPtr<Gfx::Bitmap> m_curr_bmp = m_alert; NonnullRefPtr<Gfx::Bitmap> m_curr_bmp = m_alert;
CatDog() CatDog()
: m_temp_pos { 0, 0 } : m_temp_pos { 0, 0 }
{ {

View file

@ -108,7 +108,7 @@ void Canvas::draw()
painter.draw_line({ 740, 140 }, { 640, 240 }, Color::Red, 5, Gfx::Painter::LineStyle::Solid); painter.draw_line({ 740, 140 }, { 640, 240 }, Color::Red, 5, Gfx::Painter::LineStyle::Solid);
painter.draw_line({ 690, 140 }, { 640, 240 }, Color::Blue, 10, Gfx::Painter::LineStyle::Solid); painter.draw_line({ 690, 140 }, { 640, 240 }, Color::Blue, 10, Gfx::Painter::LineStyle::Solid);
auto bg = Gfx::Bitmap::try_load_from_file("/res/html/misc/90s-bg.png"); auto bg = Gfx::Bitmap::try_load_from_file("/res/html/misc/90s-bg.png").release_value_but_fixme_should_propagate_errors();
painter.draw_tiled_bitmap({ 20, 260, 480, 320 }, *bg); painter.draw_tiled_bitmap({ 20, 260, 480, 320 }, *bg);
painter.draw_line({ 40, 480 }, { 20, 260 }, Color::Red); painter.draw_line({ 40, 480 }, { 20, 260 }, Color::Red);
@ -129,7 +129,7 @@ void Canvas::draw()
path.close(); path.close();
painter.fill_path(path, Color::Yellow, Gfx::Painter::WindingRule::EvenOdd); painter.fill_path(path, Color::Yellow, Gfx::Painter::WindingRule::EvenOdd);
auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png"); auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png").release_value_but_fixme_should_propagate_errors();
painter.blit({ 280, 280 }, *buggie, buggie->rect(), 0.5); painter.blit({ 280, 280 }, *buggie, buggie->rect(), 0.5);
painter.draw_scaled_bitmap({ 360, 280, buggie->rect().width() * 2, buggie->rect().height() * 2 }, *buggie, buggie->rect()); painter.draw_scaled_bitmap({ 360, 280, buggie->rect().width() * 2, buggie->rect().height() * 2 }, *buggie, buggie->rect());

View file

@ -75,14 +75,14 @@ void Canvas::paint_event(GUI::PaintEvent& event)
void Canvas::draw(Gfx::Painter& painter) void Canvas::draw(Gfx::Painter& painter)
{ {
auto active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); auto active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors();
Gfx::WindowTheme::current().paint_normal_frame(painter, Gfx::WindowTheme::WindowState::Active, { 4, 18, WIDTH - 8, HEIGHT - 29 }, "Well hello friends 🐞", *active_window_icon, palette(), { WIDTH - 20, 6, 16, 16 }, 0, false); Gfx::WindowTheme::current().paint_normal_frame(painter, Gfx::WindowTheme::WindowState::Active, { 4, 18, WIDTH - 8, HEIGHT - 29 }, "Well hello friends 🐞", *active_window_icon, palette(), { WIDTH - 20, 6, 16, 16 }, 0, false);
painter.draw_rect({ 20, 34, WIDTH - 40, HEIGHT - 45 }, palette().color(Gfx::ColorRole::Selection), true); painter.draw_rect({ 20, 34, WIDTH - 40, HEIGHT - 45 }, palette().color(Gfx::ColorRole::Selection), true);
painter.draw_rect({ 24, 38, WIDTH - 48, HEIGHT - 53 }, palette().color(Gfx::ColorRole::Selection)); painter.draw_rect({ 24, 38, WIDTH - 48, HEIGHT - 53 }, palette().color(Gfx::ColorRole::Selection));
// buggie.png has an alpha channel. // buggie.png has an alpha channel.
auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png"); auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png").release_value_but_fixme_should_propagate_errors();
painter.blit({ 25, 39 }, *buggie, { 2, 30, 62, 20 }); painter.blit({ 25, 39 }, *buggie, { 2, 30, 62, 20 });
painter.draw_scaled_bitmap({ 88, 39, 62 * 2, 20 * 2 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 }); painter.draw_scaled_bitmap({ 88, 39, 62 * 2, 20 * 2 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 });
painter.draw_scaled_bitmap({ 202, 39, 80, 40 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 }); painter.draw_scaled_bitmap({ 202, 39, 80, 40 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 });
@ -92,7 +92,7 @@ void Canvas::draw(Gfx::Painter& painter)
painter.blit({ 25, 101 }, *buggie, { 2, 30, 3 * buggie->width(), 20 }); painter.blit({ 25, 101 }, *buggie, { 2, 30, 3 * buggie->width(), 20 });
// grid does not have an alpha channel. // grid does not have an alpha channel.
auto grid = Gfx::Bitmap::try_load_from_file("/res/wallpapers/grid.png"); auto grid = Gfx::Bitmap::try_load_from_file("/res/wallpapers/grid.png").release_value_but_fixme_should_propagate_errors();
VERIFY(!grid->has_alpha_channel()); VERIFY(!grid->has_alpha_channel());
painter.fill_rect({ 25, 122, 62, 20 }, Color::Green); painter.fill_rect({ 25, 122, 62, 20 }, Color::Green);
painter.blit({ 25, 122 }, *grid, { (grid->width() - 62) / 2, (grid->height() - 20) / 2 + 40, 62, 20 }, 0.9); painter.blit({ 25, 122 }, *grid, { (grid->width() - 62) / 2, (grid->height() - 20) / 2 + 40, 62, 20 }, 0.9);

View file

@ -400,7 +400,7 @@ int main(int argc, char** argv)
auto& mandelbrot = window->set_main_widget<Mandelbrot>(); auto& mandelbrot = window->set_main_widget<Mandelbrot>();
auto& file_menu = window->add_menu("&File"); auto& file_menu = window->add_menu("&File");
file_menu.add_action(GUI::Action::create("&Export...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"), file_menu.add_action(GUI::Action::create("&Export...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png").release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action&) { [&](GUI::Action&) {
Optional<String> export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "png"); Optional<String> export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "png");
if (!export_path.has_value()) if (!export_path.has_value())

View file

@ -47,8 +47,8 @@ void GalleryWidget::load_basic_model_tab()
m_add_new_item = *tab.find_descendant_of_type_named<GUI::Button>("add_new_item"); m_add_new_item = *tab.find_descendant_of_type_named<GUI::Button>("add_new_item");
m_remove_selected_item = *tab.find_descendant_of_type_named<GUI::Button>("remove_selected_item"); m_remove_selected_item = *tab.find_descendant_of_type_named<GUI::Button>("remove_selected_item");
m_add_new_item->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png")); m_add_new_item->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors());
m_remove_selected_item->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png")); m_remove_selected_item->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png").release_value_but_fixme_should_propagate_errors());
m_new_item_name->on_return_pressed = [&] { add_textbox_contents_to_basic_model(); }; m_new_item_name->on_return_pressed = [&] { add_textbox_contents_to_basic_model(); };
m_add_new_item->on_click = [&](auto) { add_textbox_contents_to_basic_model(); }; m_add_new_item->on_click = [&](auto) { add_textbox_contents_to_basic_model(); };

View file

@ -73,7 +73,7 @@ public:
cursor.name = LexicalPath::basename(cursor.path); cursor.name = LexicalPath::basename(cursor.path);
// FIXME: Animated cursor bitmaps // FIXME: Animated cursor bitmaps
auto cursor_bitmap = Gfx::Bitmap::try_load_from_file(cursor.path); auto cursor_bitmap = Gfx::Bitmap::try_load_from_file(cursor.path).release_value_but_fixme_should_propagate_errors();
auto cursor_bitmap_rect = cursor_bitmap->rect(); auto cursor_bitmap_rect = cursor_bitmap->rect();
cursor.params = Gfx::CursorParams::parse_from_filename(cursor.name, cursor_bitmap_rect.center()).constrained(*cursor_bitmap); cursor.params = Gfx::CursorParams::parse_from_filename(cursor.name, cursor_bitmap_rect.center()).constrained(*cursor_bitmap);
@ -158,7 +158,7 @@ public:
if (!path.contains("filetype-") && !path.contains("app-")) if (!path.contains("filetype-") && !path.contains("app-"))
continue; continue;
IconSet icon_set; IconSet icon_set;
icon_set.big_icon = Gfx::Bitmap::try_load_from_file(path); icon_set.big_icon = Gfx::Bitmap::try_load_from_file(path).release_value_but_fixme_should_propagate_errors();
icon_set.name = LexicalPath::basename(path); icon_set.name = LexicalPath::basename(path);
m_icon_sets.append(move(icon_set)); m_icon_sets.append(move(icon_set));
} }
@ -172,7 +172,7 @@ public:
if (!path.contains("filetype-") && !path.contains("app-")) if (!path.contains("filetype-") && !path.contains("app-"))
continue; continue;
IconSet icon_set; IconSet icon_set;
icon_set.little_icon = Gfx::Bitmap::try_load_from_file(path); icon_set.little_icon = Gfx::Bitmap::try_load_from_file(path).release_value_but_fixme_should_propagate_errors();
icon_set.name = LexicalPath::basename(path); icon_set.name = LexicalPath::basename(path);
for (size_t i = 0; i < big_icons_found; i++) { for (size_t i = 0; i < big_icons_found; i++) {
if (icon_set.name == m_icon_sets[i].name) { if (icon_set.name == m_icon_sets[i].name) {

View file

@ -73,9 +73,9 @@ GalleryWidget::GalleryWidget()
m_label_frame->set_frame_thickness(value); m_label_frame->set_frame_thickness(value);
}; };
m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png")); m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors());
m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladybug.png")); m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladybug.png").release_value_but_fixme_should_propagate_errors());
m_icon_button = basics_tab.find_descendant_of_type_named<GUI::Button>("icon_button"); m_icon_button = basics_tab.find_descendant_of_type_named<GUI::Button>("icon_button");
m_icon_button->set_icon(*m_button_icons[2]); m_icon_button->set_icon(*m_button_icons[2]);
@ -95,7 +95,7 @@ GalleryWidget::GalleryWidget()
m_text_editor = basics_tab.find_descendant_of_type_named<GUI::TextEditor>("text_editor"); m_text_editor = basics_tab.find_descendant_of_type_named<GUI::TextEditor>("text_editor");
m_font_button = basics_tab.find_descendant_of_type_named<GUI::Button>("font_button"); m_font_button = basics_tab.find_descendant_of_type_named<GUI::Button>("font_button");
m_font_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png")); m_font_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors());
m_font_button->on_click = [&](auto) { m_font_button->on_click = [&](auto) {
auto picker = GUI::FontPicker::construct(window(), &m_text_editor->font(), false); auto picker = GUI::FontPicker::construct(window(), &m_text_editor->font(), false);
@ -105,7 +105,7 @@ GalleryWidget::GalleryWidget()
}; };
m_file_button = basics_tab.find_descendant_of_type_named<GUI::Button>("file_button"); m_file_button = basics_tab.find_descendant_of_type_named<GUI::Button>("file_button");
m_file_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png")); m_file_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors());
m_file_button->on_click = [&](auto) { m_file_button->on_click = [&](auto) {
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window()); Optional<String> open_path = GUI::FilePicker::get_open_filepath(window());
@ -115,7 +115,7 @@ GalleryWidget::GalleryWidget()
}; };
m_input_button = basics_tab.find_descendant_of_type_named<GUI::Button>("input_button"); m_input_button = basics_tab.find_descendant_of_type_named<GUI::Button>("input_button");
m_input_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png")); m_input_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png").release_value_but_fixme_should_propagate_errors());
m_input_button->on_click = [&](auto) { m_input_button->on_click = [&](auto) {
String value; String value;
@ -133,7 +133,7 @@ GalleryWidget::GalleryWidget()
}; };
m_msgbox_button = basics_tab.find_descendant_of_type_named<GUI::Button>("msgbox_button"); m_msgbox_button = basics_tab.find_descendant_of_type_named<GUI::Button>("msgbox_button");
m_msgbox_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-browser.png")); m_msgbox_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-browser.png").release_value_but_fixme_should_propagate_errors());
m_msgbox_type = GUI::MessageBox::Type::None; m_msgbox_type = GUI::MessageBox::Type::None;
m_msgbox_input_type = GUI::MessageBox::InputType::OK; m_msgbox_input_type = GUI::MessageBox::InputType::OK;

View file

@ -25,19 +25,19 @@ namespace HackStudio {
void DebugInfoWidget::init_toolbar() void DebugInfoWidget::init_toolbar()
{ {
m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-continue.png"), [](auto&) { m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-continue.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Continue); Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Continue);
}); });
m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-over.png"), [](auto&) { m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-over.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOver); Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOver);
}); });
m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-in.png"), [](auto&) { m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-in.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceSingleStep); Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceSingleStep);
}); });
m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-out.png"), [](auto&) { m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-out.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOut); Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOut);
}); });

View file

@ -31,7 +31,7 @@ private:
: m_variables(move(variables)) : m_variables(move(variables))
, m_regs(regs) , m_regs(regs)
{ {
m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
} }
NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables; NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables;
PtraceRegisters m_regs; PtraceRegisters m_regs;

View file

@ -433,13 +433,13 @@ void Editor::clear_execution_position()
const Gfx::Bitmap& Editor::breakpoint_icon_bitmap() const Gfx::Bitmap& Editor::breakpoint_icon_bitmap()
{ {
static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/breakpoint.png"); static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/breakpoint.png").release_value_but_fixme_should_propagate_errors();
return *bitmap; return *bitmap;
} }
const Gfx::Bitmap& Editor::current_position_icon_bitmap() const Gfx::Bitmap& Editor::current_position_icon_bitmap()
{ {
static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"); static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors();
return *bitmap; return *bitmap;
} }

View file

@ -31,7 +31,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
unstaged_header.set_layout<GUI::HorizontalBoxLayout>(); unstaged_header.set_layout<GUI::HorizontalBoxLayout>();
auto& refresh_button = unstaged_header.add<GUI::Button>(); auto& refresh_button = unstaged_header.add<GUI::Button>();
refresh_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")); refresh_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png").release_value_but_fixme_should_propagate_errors());
refresh_button.set_fixed_size(16, 16); refresh_button.set_fixed_size(16, 16);
refresh_button.set_tooltip("refresh"); refresh_button.set_tooltip("refresh");
refresh_button.on_click = [this](int) { refresh(); }; refresh_button.on_click = [this](int) { refresh(); };
@ -42,7 +42,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
unstaged_header.set_fixed_height(20); unstaged_header.set_fixed_height(20);
m_unstaged_files = unstaged.add<GitFilesView>( m_unstaged_files = unstaged.add<GitFilesView>(
[this](const auto& file) { stage_file(file); }, [this](const auto& file) { stage_file(file); },
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_nonnull()); Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors());
m_unstaged_files->on_selection_change = [this] { m_unstaged_files->on_selection_change = [this] {
const auto& index = m_unstaged_files->selection().first(); const auto& index = m_unstaged_files->selection().first();
const auto& selected = index.data().as_string(); const auto& selected = index.data().as_string();
@ -56,7 +56,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
staged_header.set_layout<GUI::HorizontalBoxLayout>(); staged_header.set_layout<GUI::HorizontalBoxLayout>();
auto& commit_button = staged_header.add<GUI::Button>(); auto& commit_button = staged_header.add<GUI::Button>();
commit_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/commit.png")); commit_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/commit.png").release_value_but_fixme_should_propagate_errors());
commit_button.set_fixed_size(16, 16); commit_button.set_fixed_size(16, 16);
commit_button.set_tooltip("commit"); commit_button.set_tooltip("commit");
commit_button.on_click = [this](int) { commit(); }; commit_button.on_click = [this](int) { commit(); };
@ -67,7 +67,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
staged_header.set_fixed_height(20); staged_header.set_fixed_height(20);
m_staged_files = staged.add<GitFilesView>( m_staged_files = staged.add<GitFilesView>(
[this](const auto& file) { unstage_file(file); }, [this](const auto& file) { unstage_file(file); },
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png").release_nonnull()); Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png").release_value_but_fixme_should_propagate_errors());
} }
bool GitWidget::initialize() bool GitWidget::initialize()

View file

@ -418,7 +418,7 @@ NonnullRefPtr<GUI::Menu> HackStudioWidget::create_project_tree_view_context_menu
NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(String const& label, String const& icon, String const& extension) NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(String const& label, String const& icon, String const& extension)
{ {
return GUI::Action::create(label, Gfx::Bitmap::try_load_from_file(icon), [this, extension](const GUI::Action&) { return GUI::Action::create(label, Gfx::Bitmap::try_load_from_file(icon).release_value_but_fixme_should_propagate_errors(), [this, extension](const GUI::Action&) {
String filename; String filename;
if (GUI::InputBox::show(window(), filename, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecOK) if (GUI::InputBox::show(window(), filename, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecOK)
return; return;
@ -459,7 +459,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(String const
NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action()
{ {
return GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [this](const GUI::Action&) { return 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(), [this](const GUI::Action&) {
String directory_name; String directory_name;
if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecOK) if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecOK)
return; return;
@ -569,7 +569,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_project_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_project_action()
{ {
return GUI::Action::create("&New Project...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hackstudio-project.png"), [this](const GUI::Action&) { return GUI::Action::create("&New Project...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hackstudio-project.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
auto dialog = NewProjectDialog::construct(window()); auto dialog = NewProjectDialog::construct(window());
dialog->set_icon(window()->icon()); dialog->set_icon(window()->icon());
auto result = dialog->exec(); auto result = dialog->exec();
@ -666,7 +666,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_remove_current_editor_action
NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_action()
{ {
return GUI::Action::create("&Open Project...", { Mod_Ctrl | Mod_Shift, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), [this](auto&) { return GUI::Action::create("&Open Project...", { Mod_Ctrl | Mod_Shift, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
auto open_path = GUI::FilePicker::get_open_filepath(window(), "Open project", m_project->root_path(), true); auto open_path = GUI::FilePicker::get_open_filepath(window(), "Open project", m_project->root_path(), true);
if (!open_path.has_value()) if (!open_path.has_value())
return; return;
@ -746,7 +746,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_remove_current_terminal_acti
NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_editor_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_editor_action()
{ {
return GUI::Action::create("Add New &Editor", { Mod_Ctrl | Mod_Alt, Key_E }, return GUI::Action::create("Add New &Editor", { Mod_Ctrl | Mod_Alt, Key_E },
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-text-editor.png"), Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-text-editor.png").release_value_but_fixme_should_propagate_errors(),
[this](auto&) { [this](auto&) {
add_new_editor(*m_editors_splitter); add_new_editor(*m_editors_splitter);
update_actions(); update_actions();
@ -756,7 +756,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_editor_action()
NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_terminal_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_terminal_action()
{ {
return GUI::Action::create("Add New &Terminal", { Mod_Ctrl | Mod_Alt, Key_T }, return GUI::Action::create("Add New &Terminal", { Mod_Ctrl | Mod_Alt, Key_T },
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(),
[this](auto&) { [this](auto&) {
auto& terminal_wrapper = m_action_tab_widget->add_tab<TerminalWrapper>("Terminal"); auto& terminal_wrapper = m_action_tab_widget->add_tab<TerminalWrapper>("Terminal");
reveal_action_tab(terminal_wrapper); reveal_action_tab(terminal_wrapper);
@ -774,7 +774,7 @@ void HackStudioWidget::reveal_action_tab(GUI::Widget& widget)
NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action()
{ {
return GUI::Action::create("&Debug", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-run.png"), [this](auto&) { return GUI::Action::create("&Debug", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-run.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (!Core::File::exists(get_project_executable_path())) { if (!Core::File::exists(get_project_executable_path())) {
GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error", GUI::MessageBox::Type::Error); GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error", GUI::MessageBox::Type::Error);
return; return;
@ -1024,7 +1024,7 @@ void HackStudioWidget::create_toolbar(GUI::Widget& parent)
NonnullRefPtr<GUI::Action> HackStudioWidget::create_build_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_build_action()
{ {
return GUI::Action::create("&Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/build.png"), [this](auto&) { return GUI::Action::create("&Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/build.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (warn_unsaved_changes("There are unsaved changes, do you want to save before building?") == ContinueDecision::No) if (warn_unsaved_changes("There are unsaved changes, do you want to save before building?") == ContinueDecision::No)
return; return;
@ -1036,7 +1036,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_build_action()
NonnullRefPtr<GUI::Action> HackStudioWidget::create_run_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_run_action()
{ {
return GUI::Action::create("&Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-run.png"), [this](auto&) { return GUI::Action::create("&Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-run.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
reveal_action_tab(*m_terminal_wrapper); reveal_action_tab(*m_terminal_wrapper);
run(*m_terminal_wrapper); run(*m_terminal_wrapper);
m_stop_action->set_enabled(true); m_stop_action->set_enabled(true);
@ -1125,7 +1125,7 @@ void HackStudioWidget::create_project_menu(GUI::Window& window)
void HackStudioWidget::create_edit_menu(GUI::Window& window) void HackStudioWidget::create_edit_menu(GUI::Window& window)
{ {
auto& edit_menu = window.add_menu("&Edit"); auto& edit_menu = window.add_menu("&Edit");
edit_menu.add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [this](auto&) { edit_menu.add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
reveal_action_tab(*m_find_in_files_widget); reveal_action_tab(*m_find_in_files_widget);
m_find_in_files_widget->focus_textbox_and_select_all(); m_find_in_files_widget->focus_textbox_and_select_all();
})); }));
@ -1196,7 +1196,7 @@ void HackStudioWidget::create_view_menu(GUI::Window& window)
m_no_wrapping_action->set_checked(true); m_no_wrapping_action->set_checked(true);
m_editor_font_action = GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"), m_editor_font_action = GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(),
[&](auto&) { [&](auto&) {
auto picker = GUI::FontPicker::construct(&window, m_editor_font, false); auto picker = GUI::FontPicker::construct(&window, m_editor_font, false);
if (picker->exec() == GUI::Dialog::ExecOK) { if (picker->exec() == GUI::Dialog::ExecOK) {
@ -1226,7 +1226,7 @@ void HackStudioWidget::create_help_menu(GUI::Window& window)
NonnullRefPtr<GUI::Action> HackStudioWidget::create_stop_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_stop_action()
{ {
auto action = GUI::Action::create("&Stop", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-stop.png"), [this](auto&) { auto action = GUI::Action::create("&Stop", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-stop.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (!Debugger::the().session()) { if (!Debugger::the().session()) {
m_terminal_wrapper->kill_running_command(); m_terminal_wrapper->kill_running_command();
return; return;
@ -1380,7 +1380,7 @@ void HackStudioWidget::on_cursor_change()
void HackStudioWidget::create_location_history_actions() void HackStudioWidget::create_location_history_actions()
{ {
m_locations_history_back_action = GUI::Action::create("Go Back", { Mod_Alt | Mod_Shift, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"), [this](auto&) { m_locations_history_back_action = GUI::Action::create("Go Back", { Mod_Alt | Mod_Shift, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (m_locations_history_end_index <= 1) if (m_locations_history_end_index <= 1)
return; return;
@ -1394,7 +1394,7 @@ void HackStudioWidget::create_location_history_actions()
update_history_actions(); update_history_actions();
}); });
m_locations_history_forward_action = GUI::Action::create("Go Forward", { Mod_Alt | Mod_Shift, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), [this](auto&) { m_locations_history_forward_action = GUI::Action::create("Go Forward", { Mod_Alt | Mod_Shift, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (m_locations_history_end_index == m_locations_history.size()) if (m_locations_history_end_index == m_locations_history.size())
return; return;

View file

@ -185,7 +185,7 @@ void ServerConnectionWrapper::on_crash()
void ServerConnectionWrapper::show_frequenct_crashes_notification() const void ServerConnectionWrapper::show_frequenct_crashes_notification() const
{ {
auto notification = GUI::Notification::construct(); auto notification = GUI::Notification::construct();
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png")); notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png").release_value_but_fixme_should_propagate_errors());
notification->set_title("LanguageServer Crashes too much!"); notification->set_title("LanguageServer Crashes too much!");
notification->set_text("LanguageServer aided features will not be available in this session"); notification->set_text("LanguageServer aided features will not be available in this session");
notification->show(); notification->show();
@ -193,7 +193,7 @@ void ServerConnectionWrapper::show_frequenct_crashes_notification() const
void ServerConnectionWrapper::show_crash_notification() const void ServerConnectionWrapper::show_crash_notification() const
{ {
auto notification = GUI::Notification::construct(); auto notification = GUI::Notification::construct();
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png")); notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png").release_value_but_fixme_should_propagate_errors());
notification->set_title("Oops!"); notification->set_title("Oops!");
notification->set_text(String::formatted("LanguageServer has crashed")); notification->set_text(String::formatted("LanguageServer has crashed"));
notification->show(); notification->show();

View file

@ -20,13 +20,13 @@ void HackStudio::ProjectDeclarations::set_declared_symbols(const String& filenam
Optional<GUI::Icon> HackStudio::ProjectDeclarations::get_icon_for(GUI::AutocompleteProvider::DeclarationType type) Optional<GUI::Icon> HackStudio::ProjectDeclarations::get_icon_for(GUI::AutocompleteProvider::DeclarationType type)
{ {
static GUI::Icon struct_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Struct.png")); static GUI::Icon struct_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Struct.png").release_value_but_fixme_should_propagate_errors());
static GUI::Icon class_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Class.png")); static GUI::Icon class_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Class.png").release_value_but_fixme_should_propagate_errors());
static GUI::Icon function_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Function.png")); static GUI::Icon function_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Function.png").release_value_but_fixme_should_propagate_errors());
static GUI::Icon variable_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Variable.png")); static GUI::Icon variable_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Variable.png").release_value_but_fixme_should_propagate_errors());
static GUI::Icon preprocessor_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Preprocessor.png")); static GUI::Icon preprocessor_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Preprocessor.png").release_value_but_fixme_should_propagate_errors());
static GUI::Icon member_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Member.png")); static GUI::Icon member_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Member.png").release_value_but_fixme_should_propagate_errors());
static GUI::Icon namespace_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Namespace.png")); static GUI::Icon namespace_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Namespace.png").release_value_but_fixme_should_propagate_errors());
switch (type) { switch (type) {
case GUI::AutocompleteProvider::DeclarationType::Struct: case GUI::AutocompleteProvider::DeclarationType::Struct:
return struct_icon; return struct_icon;

View file

@ -50,8 +50,9 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(const String& manife
auto bitmap_path_32 = String::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x")); auto bitmap_path_32 = String::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
if (Core::File::exists(bitmap_path_32)) { if (Core::File::exists(bitmap_path_32)) {
auto bitmap32 = Gfx::Bitmap::try_load_from_file(bitmap_path_32); auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(bitmap_path_32);
icon = GUI::Icon(move(bitmap32)); if (!bitmap_or_error.is_error())
icon = GUI::Icon(bitmap_or_error.release_value());
} }
return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority)); return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority));

View file

@ -43,7 +43,7 @@ int main(int argc, char** argv)
auto window = GUI::Window::construct(); auto window = GUI::Window::construct();
window->resize(840, 600); window->resize(840, 600);
window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png")); window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png").release_value_but_fixme_should_propagate_errors());
update_path_environment_variable(); update_path_environment_variable();
@ -103,7 +103,7 @@ static bool make_is_available()
static void notify_make_not_available() static void notify_make_not_available()
{ {
auto notification = GUI::Notification::construct(); auto notification = GUI::Notification::construct();
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png")); notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png").release_value_but_fixme_should_propagate_errors());
notification->set_title("'make' Not Available"); notification->set_title("'make' Not Available");
notification->set_text("You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository"); notification->set_text("You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository");
notification->show(); notification->show();

View file

@ -16,10 +16,10 @@ namespace Inspector {
RemoteObjectGraphModel::RemoteObjectGraphModel(RemoteProcess& process) RemoteObjectGraphModel::RemoteObjectGraphModel(RemoteProcess& process)
: m_process(process) : m_process(process)
{ {
m_object_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); m_object_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
m_window_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png")); m_window_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors());
m_layout_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png")); m_layout_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png").release_value_but_fixme_should_propagate_errors());
m_timer_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/timer.png")); m_timer_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/timer.png").release_value_but_fixme_should_propagate_errors());
} }
RemoteObjectGraphModel::~RemoteObjectGraphModel() RemoteObjectGraphModel::~RemoteObjectGraphModel()

View file

@ -153,7 +153,7 @@ int main(int argc, char** argv)
auto properties_tree_view_context_menu = GUI::Menu::construct("Properties Tree View"); auto properties_tree_view_context_menu = GUI::Menu::construct("Properties Tree View");
auto copy_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"); auto copy_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors();
auto copy_property_name_action = GUI::Action::create("Copy Property Name", copy_bitmap, [&](auto&) { auto copy_property_name_action = GUI::Action::create("Copy Property Name", copy_bitmap, [&](auto&) {
GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().data().to_string()); GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().data().to_string());
}); });

View file

@ -15,8 +15,8 @@ namespace Profiler {
ProfileModel::ProfileModel(Profile& profile) ProfileModel::ProfileModel(Profile& profile)
: m_profile(profile) : m_profile(profile)
{ {
m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png")); m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png").release_value_but_fixme_should_propagate_errors());
} }
ProfileModel::~ProfileModel() ProfileModel::~ProfileModel()

View file

@ -13,8 +13,8 @@ namespace Profiler {
SamplesModel::SamplesModel(Profile& profile) SamplesModel::SamplesModel(Profile& profile)
: m_profile(profile) : m_profile(profile)
{ {
m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png")); m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png").release_value_but_fixme_should_propagate_errors());
} }
SamplesModel::~SamplesModel() SamplesModel::~SamplesModel()

View file

@ -158,7 +158,7 @@ int main(int argc, char** argv)
update_disassembly_model(); update_disassembly_model();
}; };
auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png"), [&](auto& action) { auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png").release_value_but_fixme_should_propagate_errors(), [&](auto& action) {
disassembly_view.set_visible(action.is_checked()); disassembly_view.set_visible(action.is_checked());
update_disassembly_model(); update_disassembly_model();
}); });
@ -277,7 +277,7 @@ static bool prompt_to_stop_profiling(pid_t pid, const String& process_name)
auto window = GUI::Window::construct(); auto window = GUI::Window::construct();
window->set_title(String::formatted("Profiling {}({})", process_name, pid)); window->set_title(String::formatted("Profiling {}({})", process_name, pid));
window->resize(240, 100); window->resize(240, 100);
window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png")); window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png").release_value_but_fixme_should_propagate_errors());
window->center_on_screen(); window->center_on_screen();
auto& widget = window->set_main_widget<GUI::Widget>(); auto& widget = window->set_main_widget<GUI::Widget>();
@ -305,7 +305,7 @@ static bool prompt_to_stop_profiling(pid_t pid, const String& process_name)
bool generate_profile(pid_t& pid) bool generate_profile(pid_t& pid)
{ {
if (!pid) { if (!pid) {
auto process_chooser = GUI::ProcessChooser::construct("Profiler", "Profile", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png")); auto process_chooser = GUI::ProcessChooser::construct("Profiler", "Profile", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png").release_value_but_fixme_should_propagate_errors());
if (process_chooser->exec() == GUI::Dialog::ExecCancel) if (process_chooser->exec() == GUI::Dialog::ExecCancel)
return false; return false;
pid = process_chooser->pid(); pid = process_chooser->pid();

View file

@ -373,7 +373,7 @@ static RefPtr<Gfx::Bitmap> get_piece(const StringView& set, const StringView& im
builder.append(set); builder.append(set);
builder.append('/'); builder.append('/');
builder.append(image); builder.append(image);
return Gfx::Bitmap::try_load_from_file(builder.build()); return Gfx::Bitmap::try_load_from_file(builder.build()).release_value_but_fixme_should_propagate_errors();
} }
void ChessWidget::set_piece_set(const StringView& set) void ChessWidget::set_piece_set(const StringView& set)

View file

@ -155,7 +155,7 @@ int main(int argc, char** argv)
GUI::ActionGroup board_theme_action_group; GUI::ActionGroup board_theme_action_group;
board_theme_action_group.set_exclusive(true); board_theme_action_group.set_exclusive(true);
auto& board_theme_menu = style_menu.add_submenu("Board Theme"); auto& board_theme_menu = style_menu.add_submenu("Board Theme");
board_theme_menu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/chess/mini-board.png")); board_theme_menu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/chess/mini-board.png").release_value_but_fixme_should_propagate_errors());
for (auto& theme : Vector({ "Beige", "Green", "Blue" })) { for (auto& theme : Vector({ "Beige", "Green", "Blue" })) {
auto action = GUI::Action::create_checkable(theme, [&](auto& action) { auto action = GUI::Action::create_checkable(theme, [&](auto& action) {

View file

@ -43,8 +43,8 @@ private:
const float x { 50 }; const float x { 50 };
const float radius { 16 }; const float radius { 16 };
const float starting_y { 200 }; const float starting_y { 200 };
const RefPtr<Gfx::Bitmap> falling_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/falling.png") }; NonnullRefPtr<Gfx::Bitmap> falling_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/falling.png").release_value_but_fixme_should_propagate_errors() };
const RefPtr<Gfx::Bitmap> flapping_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/flapping.png") }; NonnullRefPtr<Gfx::Bitmap> flapping_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/flapping.png").release_value_but_fixme_should_propagate_errors() };
float y {}; float y {};
float velocity {}; float velocity {};
@ -106,10 +106,10 @@ private:
}; };
struct Cloud { struct Cloud {
const Vector<RefPtr<Gfx::Bitmap>> cloud_bitmaps { Vector<NonnullRefPtr<Gfx::Bitmap>> const cloud_bitmaps {
Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_0.png"), Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_0.png").release_value_but_fixme_should_propagate_errors(),
Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_1.png"), Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_1.png").release_value_but_fixme_should_propagate_errors(),
Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_2.png"), Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_2.png").release_value_but_fixme_should_propagate_errors(),
}; };
float x {}; float x {};
float y {}; float y {};
@ -147,7 +147,7 @@ private:
float m_last_score {}; float m_last_score {};
float m_difficulty {}; float m_difficulty {};
float m_restart_cooldown {}; float m_restart_cooldown {};
const RefPtr<Gfx::Bitmap> m_background_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/background.png") }; NonnullRefPtr<Gfx::Bitmap> m_background_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/background.png").release_value_but_fixme_should_propagate_errors() };
const Gfx::IntRect m_score_rect { 10, 10, 20, 20 }; const Gfx::IntRect m_score_rect { 10, 10, 20, 20 };
const Gfx::IntRect m_text_rect { game_width / 2 - 80, game_height / 2 - 40, 160, 80 }; const Gfx::IntRect m_text_rect { game_width / 2 - 80, game_height / 2 - 40, 160, 80 };
}; };

View file

@ -96,8 +96,8 @@ int main(int argc, char** argv)
interval_spinbox.set_value(150); interval_spinbox.set_value(150);
auto paused_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"); auto paused_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png").release_value_but_fixme_should_propagate_errors();
auto play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"); auto play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png").release_value_but_fixme_should_propagate_errors();
auto toggle_running_action = GUI::Action::create("&Toggle Running", { Mod_None, Key_Return }, *play_icon, [&](GUI::Action&) { auto toggle_running_action = GUI::Action::create("&Toggle Running", { Mod_None, Key_Return }, *play_icon, [&](GUI::Action&) {
board_widget.set_running(!board_widget.is_running()); board_widget.set_running(!board_widget.is_running());
@ -106,27 +106,27 @@ int main(int argc, char** argv)
toggle_running_action->set_checkable(true); toggle_running_action->set_checkable(true);
auto& toggle_running_toolbar_button = main_toolbar.add_action(toggle_running_action); auto& toggle_running_toolbar_button = main_toolbar.add_action(toggle_running_action);
auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), [&](const GUI::Action&) { auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
statusbar.set_text(click_tip); statusbar.set_text(click_tip);
board_widget.run_generation(); board_widget.run_generation();
}); });
main_toolbar.add_action(run_one_generation_action); main_toolbar.add_action(run_one_generation_action);
auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), [&](auto&) { auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
statusbar.set_text(click_tip); statusbar.set_text(click_tip);
board_widget.clear_cells(); board_widget.clear_cells();
board_widget.update(); board_widget.update();
}); });
main_toolbar.add_action(clear_board_action); main_toolbar.add_action(clear_board_action);
auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"), [&](auto&) { auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
statusbar.set_text(click_tip); statusbar.set_text(click_tip);
board_widget.randomize_cells(); board_widget.randomize_cells();
board_widget.update(); board_widget.update();
}); });
main_toolbar.add_action(randomize_cells_action); main_toolbar.add_action(randomize_cells_action);
auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png"), [&](auto&) { auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
board_widget.selected_pattern()->rotate_clockwise(); board_widget.selected_pattern()->rotate_clockwise();
}); });
rotate_pattern_action->set_enabled(false); rotate_pattern_action->set_enabled(false);

View file

@ -117,15 +117,15 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b
m_time_label.set_text(String::formatted("{}.{}", m_time_elapsed / 10, m_time_elapsed % 10)); m_time_label.set_text(String::formatted("{}.{}", m_time_elapsed / 10, m_time_elapsed % 10));
}; };
m_timer->set_interval(100); m_timer->set_interval(100);
m_mine_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/mine.png"); m_mine_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/mine.png").release_value_but_fixme_should_propagate_errors();
m_flag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png"); m_flag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png").release_value_but_fixme_should_propagate_errors();
m_badflag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/badflag.png"); m_badflag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/badflag.png").release_value_but_fixme_should_propagate_errors();
m_consider_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/consider.png"); m_consider_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/consider.png").release_value_but_fixme_should_propagate_errors();
m_default_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-default.png"); m_default_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-default.png").release_value_but_fixme_should_propagate_errors();
m_good_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-good.png"); m_good_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-good.png").release_value_but_fixme_should_propagate_errors();
m_bad_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-bad.png"); m_bad_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-bad.png").release_value_but_fixme_should_propagate_errors();
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
m_number_bitmap[i] = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/minesweeper/{}.png", i + 1)); m_number_bitmap[i] = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/minesweeper/{}.png", i + 1)).release_value_but_fixme_should_propagate_errors();
// Square with mine will be filled with background color later, i.e. red // Square with mine will be filled with background color later, i.e. red
m_mine_palette.set_color(Gfx::ColorRole::Base, Color::from_rgb(0xff4040)); m_mine_palette.set_color(Gfx::ColorRole::Base, Color::from_rgb(0xff4040));

View file

@ -67,7 +67,7 @@ int main(int argc, char** argv)
container.layout()->add_spacer(); container.layout()->add_spacer();
auto& flag_image = container.add<GUI::Label>(); auto& flag_image = container.add<GUI::Label>();
flag_image.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png")); flag_image.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png").release_value_but_fixme_should_propagate_errors());
flag_image.set_fixed_width(16); flag_image.set_fixed_width(16);
auto& flag_label = container.add<GUI::Label>(); auto& flag_label = container.add<GUI::Label>();
@ -85,7 +85,7 @@ int main(int argc, char** argv)
auto& time_image = container.add<GUI::Label>(); auto& time_image = container.add<GUI::Label>();
time_image.set_fixed_width(16); time_image.set_fixed_width(16);
time_image.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/timer.png")); time_image.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/timer.png").release_value_but_fixme_should_propagate_errors());
auto& time_label = container.add<GUI::Label>(); auto& time_label = container.add<GUI::Label>();
time_label.set_fixed_width(50); time_label.set_fixed_width(50);

View file

@ -16,10 +16,10 @@
SnakeGame::SnakeGame() SnakeGame::SnakeGame()
{ {
set_font(Gfx::FontDatabase::default_fixed_width_font().bold_variant()); set_font(Gfx::FontDatabase::default_fixed_width_font().bold_variant());
m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/paprika.png")); m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/paprika.png").release_value_but_fixme_should_propagate_errors());
m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/eggplant.png")); m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/eggplant.png").release_value_but_fixme_should_propagate_errors());
m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/cauliflower.png")); m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/cauliflower.png").release_value_but_fixme_should_propagate_errors());
m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/tomato.png")); m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/tomato.png").release_value_but_fixme_should_propagate_errors());
reset(); reset();
m_high_score = Config::read_i32("Snake", "Snake", "HighScore", 0); m_high_score = Config::read_i32("Snake", "Snake", "HighScore", 0);

View file

@ -75,8 +75,7 @@ Card::Card(Type type, uint8_t value)
s_background = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { width, height }); s_background = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { width, height });
Gfx::Painter bg_painter(*s_background); Gfx::Painter bg_painter(*s_background);
auto image = Gfx::Bitmap::try_load_from_file("/res/icons/cards/buggie-deck.png"); auto image = Gfx::Bitmap::try_load_from_file("/res/icons/cards/buggie-deck.png").release_value_but_fixme_should_propagate_errors();
VERIFY(!image.is_null());
float aspect_ratio = image->width() / static_cast<float>(image->height()); float aspect_ratio = image->width() / static_cast<float>(image->height());
auto target_size = Gfx::IntSize(static_cast<int>(aspect_ratio * (height - 5)), height - 5); auto target_size = Gfx::IntSize(static_cast<int>(aspect_ratio * (height - 5)), height - 5);

View file

@ -52,13 +52,13 @@ public:
if (index.column() == Column::Icon) { if (index.column() == Column::Icon) {
if (suggestion.language == GUI::AutocompleteProvider::Language::Cpp) { if (suggestion.language == GUI::AutocompleteProvider::Language::Cpp) {
if (!s_cpp_identifier_icon) { if (!s_cpp_identifier_icon) {
s_cpp_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/cpp-identifier.png"); s_cpp_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/cpp-identifier.png").release_value_but_fixme_should_propagate_errors();
} }
return *s_cpp_identifier_icon; return *s_cpp_identifier_icon;
} }
if (suggestion.language == GUI::AutocompleteProvider::Language::Unspecified) { if (suggestion.language == GUI::AutocompleteProvider::Language::Unspecified) {
if (!s_unspecified_identifier_icon) { if (!s_unspecified_identifier_icon) {
s_unspecified_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/unspecified-identifier.png"); s_unspecified_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/unspecified-identifier.png").release_value_but_fixme_should_propagate_errors();
} }
return *s_unspecified_identifier_icon; return *s_unspecified_identifier_icon;
} }

View file

@ -184,7 +184,7 @@ ColorPicker::ColorPicker(Color color, Window* parent_window, String title)
: Dialog(parent_window) : Dialog(parent_window)
, m_color(color) , m_color(color)
{ {
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png")); set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png").release_value_but_fixme_should_propagate_errors());
set_title(title); set_title(title);
set_resizable(false); set_resizable(false);
resize(458, 326); resize(458, 326);

View file

@ -88,7 +88,7 @@ ComboBox::ComboBox()
m_open_button = add<Button>(); m_open_button = add<Button>();
m_open_button->set_button_style(Gfx::ButtonStyle::ThickCap); m_open_button->set_button_style(Gfx::ButtonStyle::ThickCap);
m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png")); m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").release_value_but_fixme_should_propagate_errors());
m_open_button->set_focus_policy(GUI::FocusPolicy::NoFocus); m_open_button->set_focus_policy(GUI::FocusPolicy::NoFocus);
m_open_button->on_click = [this](auto) { m_open_button->on_click = [this](auto) {
if (m_list_window->is_visible()) if (m_list_window->is_visible())

View file

@ -27,71 +27,71 @@ NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_
NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("&Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), move(callback), parent); auto action = Action::create("&Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Open an existing file"); action->set_status_tip("Open an existing file");
return action; return action;
} }
NonnullRefPtr<Action> make_save_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_save_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("&Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"), move(callback), parent); auto action = Action::create("&Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Save the current file"); action->set_status_tip("Save the current file");
return action; return action;
} }
NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("Save &As...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"), move(callback), parent); auto action = Action::create("Save &As...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Save the current file with a new name"); action->set_status_tip("Save the current file with a new name");
return action; return action;
} }
NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("Move to &Front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent); auto action = Action::create("Move to &Front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move-to-front.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Move to the top of the stack"); action->set_status_tip("Move to the top of the stack");
return action; return action;
} }
NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("Move to &Back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent); auto action = Action::create("Move to &Back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move-to-back.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Move to the bottom of the stack"); action->set_status_tip("Move to the bottom of the stack");
return action; return action;
} }
NonnullRefPtr<Action> make_undo_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_undo_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return Action::create("&Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/undo.png"), move(callback), parent); return Action::create("&Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/undo.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return Action::create("&Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png"), move(callback), parent); return Action::create("&Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return Action::create("&Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), move(callback), parent); return Action::create("&Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("Cu&t", { Mod_Ctrl, Key_X }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-cut.png"), move(callback), parent); auto action = Action::create("Cu&t", { Mod_Ctrl, Key_X }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-cut.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Cut to clipboard"); action->set_status_tip("Cut to clipboard");
return action; return action;
} }
NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("&Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent); auto action = Action::create("&Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Copy to clipboard"); action->set_status_tip("Copy to clipboard");
return action; return action;
} }
NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("&Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/paste.png"), move(callback), parent); auto action = Action::create("&Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/paste.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Paste from clipboard"); action->set_status_tip("Paste from clipboard");
return action; return action;
} }
@ -112,70 +112,70 @@ NonnullRefPtr<Action> make_quit_action(Function<void(Action&)> callback)
NonnullRefPtr<Action> make_help_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_help_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("&Contents", { Mod_None, Key_F1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"), move(callback), parent); auto action = Action::create("&Contents", { Mod_None, Key_F1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Show help contents"); action->set_status_tip("Show help contents");
return action; return action;
} }
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("Go &Back", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent); auto action = Action::create("Go &Back", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Move one step backward in history"); action->set_status_tip("Move one step backward in history");
return action; return action;
} }
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("Go &Forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent); auto action = Action::create("Go &Forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Move one step forward in history"); action->set_status_tip("Move one step forward in history");
return action; return action;
} }
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return Action::create("Go &Home", { Mod_Alt, Key_Home }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent); return Action::create("Go &Home", { Mod_Alt, Key_Home }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-home.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_close_tab_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_close_tab_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
auto action = Action::create("&Close Tab", { Mod_Ctrl, Key_W }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png"), move(callback), parent); auto action = Action::create("&Close Tab", { Mod_Ctrl, Key_W }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Close current tab"); action->set_status_tip("Close current tab");
return action; return action;
} }
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return Action::create("&Reload", { Mod_Ctrl, Key_R }, Key_F5, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"), move(callback), parent); return Action::create("&Reload", { Mod_Ctrl, Key_R }, Key_F5, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return Action::create("Select &All", { Mod_Ctrl, Key_A }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/select-all.png"), move(callback), parent); return Action::create("Select &All", { Mod_Ctrl, Key_A }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/select-all.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_rename_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_rename_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return Action::create("Re&name", Key_F2, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/rename.png"), move(callback), parent); return Action::create("Re&name", Key_F2, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/rename.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_properties_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_properties_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return Action::create("P&roperties", { Mod_Alt, Key_Return }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png"), move(callback), parent); return Action::create("P&roperties", { Mod_Alt, Key_Return }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_zoom_in_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_zoom_in_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return GUI::Action::create("Zoom &In", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/zoom-in.png"), move(callback), parent); return GUI::Action::create("Zoom &In", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/zoom-in.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_reset_zoom_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_reset_zoom_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return GUI::Action::create("&Reset Zoom", { Mod_Ctrl, Key_0 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/zoom-reset.png"), move(callback), parent); return GUI::Action::create("&Reset Zoom", { Mod_Ctrl, Key_0 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/zoom-reset.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
NonnullRefPtr<Action> make_zoom_out_action(Function<void(Action&)> callback, Core::Object* parent) NonnullRefPtr<Action> make_zoom_out_action(Function<void(Action&)> callback, Core::Object* parent)
{ {
return GUI::Action::create("Zoom &Out", { Mod_Ctrl, Key_Minus }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/zoom-out.png"), move(callback), parent); return GUI::Action::create("Zoom &Out", { Mod_Ctrl, Key_Minus }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/zoom-out.png").release_value_but_fixme_should_propagate_errors(), move(callback), parent);
} }
} }

View file

@ -65,8 +65,8 @@ static void initialize_if_needed()
auto config = Core::ConfigFile::open("/etc/FileIconProvider.ini"); auto config = Core::ConfigFile::open("/etc/FileIconProvider.ini");
s_symlink_emblem = Gfx::Bitmap::try_load_from_file("/res/icons/symlink-emblem.png"); s_symlink_emblem = Gfx::Bitmap::try_load_from_file("/res/icons/symlink-emblem.png").release_value_but_fixme_should_propagate_errors();
s_symlink_emblem_small = Gfx::Bitmap::try_load_from_file("/res/icons/symlink-emblem-small.png"); s_symlink_emblem_small = Gfx::Bitmap::try_load_from_file("/res/icons/symlink-emblem-small.png").release_value_but_fixme_should_propagate_errors();
s_hard_disk_icon = Icon::default_icon("hard-disk"); s_hard_disk_icon = Icon::default_icon("hard-disk");
s_directory_icon = Icon::default_icon("filetype-folder"); s_directory_icon = Icon::default_icon("filetype-folder");

View file

@ -75,11 +75,11 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen
case Mode::OpenMultiple: case Mode::OpenMultiple:
case Mode::OpenFolder: case Mode::OpenFolder:
set_title("Open"); set_title("Open");
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png")); set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors());
break; break;
case Mode::Save: case Mode::Save:
set_title("Save as"); set_title("Save as");
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png")); set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png").release_value_but_fixme_should_propagate_errors());
break; break;
} }
resize(560, 320); resize(560, 320);
@ -115,7 +115,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen
}; };
auto open_parent_directory_action = Action::create( auto open_parent_directory_action = Action::create(
"Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png"), [this](const Action&) { "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(), [this](const Action&) {
set_path(String::formatted("{}/..", m_model->root_path())); set_path(String::formatted("{}/..", m_model->root_path()));
}, },
this); this);
@ -129,7 +129,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen
toolbar.add_separator(); toolbar.add_separator();
auto mkdir_action = Action::create( auto mkdir_action = Action::create(
"New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) { "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(), [this](const Action&) {
String value; String value;
if (InputBox::show(this, value, "Enter name:", "New directory") == InputBox::ExecOK && !value.is_empty()) { if (InputBox::show(this, value, "Enter name:", "New directory") == InputBox::ExecOK && !value.is_empty()) {
auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_model->root_path(), value)); auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_model->root_path(), value));

View file

@ -617,17 +617,18 @@ static HashMap<String, RefPtr<Gfx::Bitmap>> s_thumbnail_cache;
static RefPtr<Gfx::Bitmap> render_thumbnail(StringView const& path) static RefPtr<Gfx::Bitmap> render_thumbnail(StringView const& path)
{ {
auto png_bitmap = Gfx::Bitmap::try_load_from_file(path); auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(path);
if (!png_bitmap) if (bitmap_or_error.is_error())
return nullptr; return nullptr;
auto bitmap = bitmap_or_error.release_value_but_fixme_should_propagate_errors();
double scale = min(32 / (double)png_bitmap->width(), 32 / (double)png_bitmap->height()); double scale = min(32 / (double)bitmap->width(), 32 / (double)bitmap->height());
auto thumbnail = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { 32, 32 }); auto thumbnail = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { 32, 32 });
auto destination = Gfx::IntRect(0, 0, (int)(png_bitmap->width() * scale), (int)(png_bitmap->height() * scale)).centered_within(thumbnail->rect()); auto destination = Gfx::IntRect(0, 0, (int)(bitmap->width() * scale), (int)(bitmap->height() * scale)).centered_within(thumbnail->rect());
Painter painter(*thumbnail); Painter painter(*thumbnail);
painter.draw_scaled_bitmap(destination, *png_bitmap, png_bitmap->rect()); painter.draw_scaled_bitmap(destination, *bitmap, bitmap->rect());
return thumbnail; return thumbnail;
} }

View file

@ -23,7 +23,7 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, boo
{ {
set_title("Font picker"); set_title("Font picker");
resize(430, 280); resize(430, 280);
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png")); set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors());
auto& widget = set_main_widget<GUI::Widget>(); auto& widget = set_main_widget<GUI::Widget>();
if (!widget.load_from_gml(font_picker_dialog_gml)) if (!widget.load_from_gml(font_picker_dialog_gml))

View file

@ -74,8 +74,12 @@ void IconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap)
Icon Icon::default_icon(const StringView& name) Icon Icon::default_icon(const StringView& name)
{ {
auto bitmap16 = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/16x16/{}.png", name)); RefPtr<Gfx::Bitmap> bitmap16;
auto bitmap32 = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/32x32/{}.png", name)); RefPtr<Gfx::Bitmap> bitmap32;
if (auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/16x16/{}.png", name)); !bitmap_or_error.is_error())
bitmap16 = bitmap_or_error.release_value();
if (auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/32x32/{}.png", name)); !bitmap_or_error.is_error())
bitmap32 = bitmap_or_error.release_value();
return Icon(move(bitmap16), move(bitmap32)); return Icon(move(bitmap16), move(bitmap32));
} }

View file

@ -28,7 +28,7 @@ LinkLabel::LinkLabel(String text)
void LinkLabel::setup_actions() void LinkLabel::setup_actions()
{ {
m_open_action = GUI::Action::create("Show in File Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"), [&](const GUI::Action&) { m_open_action = GUI::Action::create("Show in File Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
if (on_click) if (on_click)
on_click(); on_click();
}); });

View file

@ -44,13 +44,13 @@ RefPtr<Gfx::Bitmap> MessageBox::icon() const
{ {
switch (m_type) { switch (m_type) {
case Type::Information: case Type::Information:
return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-information.png"); return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-information.png").release_value_but_fixme_should_propagate_errors();
case Type::Warning: case Type::Warning:
return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-warning.png"); return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-warning.png").release_value_but_fixme_should_propagate_errors();
case Type::Error: case Type::Error:
return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-error.png"); return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-error.png").release_value_but_fixme_should_propagate_errors();
case Type::Question: case Type::Question:
return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-question.png"); return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-question.png").release_value_but_fixme_should_propagate_errors();
default: default:
return nullptr; return nullptr;
} }

View file

@ -104,19 +104,19 @@ void MultiView::set_column_visible(int column_index, bool visible)
void MultiView::build_actions() void MultiView::build_actions()
{ {
m_view_as_icons_action = Action::create_checkable( m_view_as_icons_action = Action::create_checkable(
"Icon view", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"), [this](auto&) { "Icon view", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
set_view_mode(ViewMode::Icon); set_view_mode(ViewMode::Icon);
}, },
this); this);
m_view_as_table_action = Action::create_checkable( m_view_as_table_action = Action::create_checkable(
"Table view", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png"), [this](auto&) { "Table view", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
set_view_mode(ViewMode::Table); set_view_mode(ViewMode::Table);
}, },
this); this);
m_view_as_columns_action = Action::create_checkable( m_view_as_columns_action = Action::create_checkable(
"Columns view", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png"), [this](auto&) { "Columns view", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
set_view_mode(ViewMode::Columns); set_view_mode(ViewMode::Columns);
}, },
this); this);

View file

@ -27,7 +27,7 @@ PasswordInputDialog::PasswordInputDialog(Window* parent_window, String title, St
auto& key_icon_label = *widget.find_descendant_of_type_named<GUI::Label>("key_icon_label"); auto& key_icon_label = *widget.find_descendant_of_type_named<GUI::Label>("key_icon_label");
key_icon_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/key.png")); key_icon_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/key.png").release_value_but_fixme_should_propagate_errors());
auto& server_label = *widget.find_descendant_of_type_named<GUI::Label>("server_label"); auto& server_label = *widget.find_descendant_of_type_named<GUI::Label>("server_label");
server_label.set_text(move(server)); server_label.set_text(move(server));

View file

@ -34,13 +34,13 @@ SpinBox::SpinBox()
m_increment_button = add<Button>(); m_increment_button = add<Button>();
m_increment_button->set_button_style(Gfx::ButtonStyle::ThickCap); m_increment_button->set_button_style(Gfx::ButtonStyle::ThickCap);
m_increment_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png")); m_increment_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png").release_value_but_fixme_should_propagate_errors());
m_increment_button->set_focus_policy(GUI::FocusPolicy::NoFocus); m_increment_button->set_focus_policy(GUI::FocusPolicy::NoFocus);
m_increment_button->on_click = [this](auto) { set_value(m_value + 1); }; m_increment_button->on_click = [this](auto) { set_value(m_value + 1); };
m_increment_button->set_auto_repeat_interval(150); m_increment_button->set_auto_repeat_interval(150);
m_decrement_button = add<Button>(); m_decrement_button = add<Button>();
m_decrement_button->set_button_style(Gfx::ButtonStyle::ThickCap); m_decrement_button->set_button_style(Gfx::ButtonStyle::ThickCap);
m_decrement_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png")); m_decrement_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").release_value_but_fixme_should_propagate_errors());
m_decrement_button->set_focus_policy(GUI::FocusPolicy::NoFocus); m_decrement_button->set_focus_policy(GUI::FocusPolicy::NoFocus);
m_decrement_button->on_click = [this](auto) { set_value(m_value - 1); }; m_decrement_button->on_click = [this](auto) { set_value(m_value - 1); };
m_decrement_button->set_auto_repeat_interval(150); m_decrement_button->set_auto_repeat_interval(150);

View file

@ -87,7 +87,7 @@ void TextEditor::create_actions()
m_delete_action = CommonActions::make_delete_action([&](auto&) { do_delete(); }, this); m_delete_action = CommonActions::make_delete_action([&](auto&) { do_delete(); }, this);
if (is_multi_line()) { if (is_multi_line()) {
m_go_to_line_action = Action::create( m_go_to_line_action = Action::create(
"Go to line...", { Mod_Ctrl, Key_L }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), [this](auto&) { "Go to line...", { Mod_Ctrl, Key_L }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
String value; String value;
if (InputBox::show(window(), value, "Line:", "Go to line") == InputBox::ExecOK) { if (InputBox::show(window(), value, "Line:", "Go to line") == InputBox::ExecOK) {
auto line_target = value.to_uint(); auto line_target = value.to_uint();

View file

@ -39,8 +39,8 @@ TreeView::TreeView()
set_background_role(ColorRole::Base); set_background_role(ColorRole::Base);
set_foreground_role(ColorRole::BaseText); set_foreground_role(ColorRole::BaseText);
set_column_headers_visible(false); set_column_headers_visible(false);
m_expand_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/serenity/treeview-expand.png"); m_expand_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/serenity/treeview-expand.png").release_value_but_fixme_should_propagate_errors();
m_collapse_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/serenity/treeview-collapse.png"); m_collapse_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/serenity/treeview-collapse.png").release_value_but_fixme_should_propagate_errors();
} }
TreeView::~TreeView() TreeView::~TreeView()

View file

@ -110,15 +110,15 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_wrapper(BitmapFormat format, I
return adopt_ref(*new Bitmap(format, size, scale_factor, pitch, data)); return adopt_ref(*new Bitmap(format, size, scale_factor, pitch, data));
} }
RefPtr<Bitmap> Bitmap::try_load_from_file(String const& path, int scale_factor) ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_load_from_file(String const& path, int scale_factor)
{ {
int fd = open(path.characters(), O_RDONLY); int fd = open(path.characters(), O_RDONLY);
if (fd < 0) if (fd < 0)
return nullptr; return Error::from_errno(errno);
return try_load_from_fd_and_close(fd, path, scale_factor); return try_load_from_fd_and_close(fd, path, scale_factor);
} }
RefPtr<Bitmap> Bitmap::try_load_from_fd_and_close(int fd, String const& path, int scale_factor) ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_load_from_fd_and_close(int fd, String const& path, int scale_factor)
{ {
if (scale_factor > 1 && path.starts_with("/res/")) { if (scale_factor > 1 && path.starts_with("/res/")) {
LexicalPath lexical_path { path }; LexicalPath lexical_path { path };
@ -144,20 +144,22 @@ RefPtr<Bitmap> Bitmap::try_load_from_fd_and_close(int fd, String const& path, in
bmp->m_size.set_width(bmp->width() / scale_factor); bmp->m_size.set_width(bmp->width() / scale_factor);
bmp->m_size.set_height(bmp->height() / scale_factor); bmp->m_size.set_height(bmp->height() / scale_factor);
bmp->m_scale = scale_factor; bmp->m_scale = scale_factor;
return bmp; return bmp.release_nonnull();
} }
} }
#define __ENUMERATE_IMAGE_FORMAT(Name, Ext) \ #define __ENUMERATE_IMAGE_FORMAT(Name, Ext) \
if (path.ends_with(Ext, CaseSensitivity::CaseInsensitive)) { \ if (path.ends_with(Ext, CaseSensitivity::CaseInsensitive)) { \
auto file = MappedFile::map_from_fd_and_close(fd, path); \ auto file = MappedFile::map_from_fd_and_close(fd, path); \
if (!file.is_error()) \ if (!file.is_error()) { \
return load_##Name##_from_memory((u8 const*)file.value()->data(), file.value()->size(), path); \ if (auto bitmap = load_##Name##_from_memory((u8 const*)file.value()->data(), file.value()->size(), path)) \
return bitmap.release_nonnull(); \
} \
} }
ENUMERATE_IMAGE_FORMATS ENUMERATE_IMAGE_FORMATS
#undef __ENUMERATE_IMAGE_FORMAT #undef __ENUMERATE_IMAGE_FORMAT
return nullptr; return Error::from_string_literal("Gfx::Bitmap unable to load from fd"sv);
} }
Bitmap::Bitmap(BitmapFormat format, IntSize const& size, int scale_factor, size_t pitch, void* data) Bitmap::Bitmap(BitmapFormat format, IntSize const& size, int scale_factor, size_t pitch, void* data)

View file

@ -93,8 +93,8 @@ public:
[[nodiscard]] static RefPtr<Bitmap> try_create(BitmapFormat, IntSize const&, int intrinsic_scale = 1); [[nodiscard]] static RefPtr<Bitmap> try_create(BitmapFormat, IntSize const&, int intrinsic_scale = 1);
[[nodiscard]] static ErrorOr<NonnullRefPtr<Bitmap>> try_create_shareable(BitmapFormat, IntSize const&, int intrinsic_scale = 1); [[nodiscard]] static ErrorOr<NonnullRefPtr<Bitmap>> try_create_shareable(BitmapFormat, IntSize const&, int intrinsic_scale = 1);
[[nodiscard]] static ErrorOr<NonnullRefPtr<Bitmap>> try_create_wrapper(BitmapFormat, IntSize const&, int intrinsic_scale, size_t pitch, void*); [[nodiscard]] static ErrorOr<NonnullRefPtr<Bitmap>> try_create_wrapper(BitmapFormat, IntSize const&, int intrinsic_scale, size_t pitch, void*);
[[nodiscard]] static RefPtr<Bitmap> try_load_from_file(String const& path, int scale_factor = 1); [[nodiscard]] static ErrorOr<NonnullRefPtr<Bitmap>> try_load_from_file(String const& path, int scale_factor = 1);
[[nodiscard]] static RefPtr<Bitmap> try_load_from_fd_and_close(int fd, String const& path, int scale_factor = 1); [[nodiscard]] static ErrorOr<NonnullRefPtr<Bitmap>> try_load_from_fd_and_close(int fd, String const& path, int scale_factor = 1);
[[nodiscard]] static ErrorOr<NonnullRefPtr<Bitmap>> try_create_with_anonymous_buffer(BitmapFormat, Core::AnonymousBuffer, IntSize const&, int intrinsic_scale, Vector<RGBA32> const& palette); [[nodiscard]] static ErrorOr<NonnullRefPtr<Bitmap>> try_create_with_anonymous_buffer(BitmapFormat, Core::AnonymousBuffer, IntSize const&, int intrinsic_scale, Vector<RGBA32> const& palette);
[[nodiscard]] static RefPtr<Bitmap> try_create_from_serialized_byte_buffer(ByteBuffer&& buffer); [[nodiscard]] static RefPtr<Bitmap> try_create_from_serialized_byte_buffer(ByteBuffer&& buffer);

View file

@ -357,10 +357,10 @@ static Gfx::Bitmap const& circle_bitmap(bool checked, bool changing)
void ClassicStylePainter::paint_radio_button(Painter& painter, IntRect const& rect, Palette const&, bool is_checked, bool is_being_pressed) void ClassicStylePainter::paint_radio_button(Painter& painter, IntRect const& rect, Palette const&, bool is_checked, bool is_being_pressed)
{ {
if (!s_unfilled_circle_bitmap) { if (!s_unfilled_circle_bitmap) {
s_unfilled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/unfilled-radio-circle.png"); s_unfilled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/unfilled-radio-circle.png").release_value_but_fixme_should_propagate_errors();
s_filled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/filled-radio-circle.png"); s_filled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/filled-radio-circle.png").release_value_but_fixme_should_propagate_errors();
s_changing_filled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/changing-filled-radio-circle.png"); s_changing_filled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/changing-filled-radio-circle.png").release_value_but_fixme_should_propagate_errors();
s_changing_unfilled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/changing-unfilled-radio-circle.png"); s_changing_unfilled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/changing-unfilled-radio-circle.png").release_value_but_fixme_should_propagate_errors();
} }
auto& bitmap = circle_bitmap(is_checked, is_being_pressed); auto& bitmap = circle_bitmap(is_checked, is_being_pressed);

View file

@ -19,12 +19,12 @@ const Bitmap* Emoji::emoji_for_code_point(u32 code_point)
if (it != s_emojis.end()) if (it != s_emojis.end())
return (*it).value.ptr(); return (*it).value.ptr();
auto bitmap = Bitmap::try_load_from_file(String::formatted("/res/emoji/U+{:X}.png", code_point)); auto bitmap_or_error = Bitmap::try_load_from_file(String::formatted("/res/emoji/U+{:X}.png", code_point));
if (!bitmap) { if (bitmap_or_error.is_error()) {
s_emojis.set(code_point, nullptr); s_emojis.set(code_point, nullptr);
return nullptr; return nullptr;
} }
auto bitmap = bitmap_or_error.release_value();
s_emojis.set(code_point, bitmap); s_emojis.set(code_point, bitmap);
return bitmap.ptr(); return bitmap.ptr();
} }

View file

@ -122,12 +122,12 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy)
m_terminal.set_size(Config::read_i32("Terminal", "Window", "Width", 80), Config::read_i32("Terminal", "Window", "Height", 25)); m_terminal.set_size(Config::read_i32("Terminal", "Window", "Width", 80), Config::read_i32("Terminal", "Window", "Height", 25));
m_copy_action = GUI::Action::create("&Copy", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"), [this](auto&) { m_copy_action = GUI::Action::create("&Copy", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
copy(); copy();
}); });
m_copy_action->set_swallow_key_event_when_disabled(true); m_copy_action->set_swallow_key_event_when_disabled(true);
m_paste_action = GUI::Action::create("&Paste", { Mod_Ctrl | Mod_Shift, Key_V }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/paste.png"), [this](auto&) { m_paste_action = GUI::Action::create("&Paste", { Mod_Ctrl | Mod_Shift, Key_V }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/paste.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
paste(); paste();
}); });
m_paste_action->set_swallow_key_event_when_disabled(true); m_paste_action->set_swallow_key_event_when_disabled(true);

View file

@ -18,9 +18,9 @@ DOMTreeModel::DOMTreeModel(JsonObject dom_tree, GUI::TreeView& tree_view)
: m_tree_view(tree_view) : m_tree_view(tree_view)
, m_dom_tree(move(dom_tree)) , m_dom_tree(move(dom_tree))
{ {
m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png")); m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png").release_value_but_fixme_should_propagate_errors());
m_element_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); m_element_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
m_text_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png")); m_text_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png").release_value_but_fixme_should_propagate_errors());
map_dom_nodes_to_parent(nullptr, &m_dom_tree); map_dom_nodes_to_parent(nullptr, &m_dom_tree);
} }

View file

@ -28,7 +28,7 @@ FrameLoader::FrameLoader(BrowsingContext& browsing_context)
: m_browsing_context(browsing_context) : m_browsing_context(browsing_context)
{ {
if (!s_default_favicon_bitmap) { if (!s_default_favicon_bitmap) {
s_default_favicon_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"); s_default_favicon_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png").release_value_but_fixme_should_propagate_errors();
VERIFY(s_default_favicon_bitmap); VERIFY(s_default_favicon_bitmap);
} }
} }

View file

@ -61,7 +61,7 @@ ClockWidget::ClockWidget()
m_prev_date = navigation_container.add<GUI::Button>(); m_prev_date = navigation_container.add<GUI::Button>();
m_prev_date->set_button_style(Gfx::ButtonStyle::Coolbar); m_prev_date->set_button_style(Gfx::ButtonStyle::Coolbar);
m_prev_date->set_fixed_size(24, 24); m_prev_date->set_fixed_size(24, 24);
m_prev_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")); m_prev_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors());
m_prev_date->on_click = [&](auto) { m_prev_date->on_click = [&](auto) {
unsigned view_month = m_calendar->view_month(); unsigned view_month = m_calendar->view_month();
unsigned view_year = m_calendar->view_year(); unsigned view_year = m_calendar->view_year();
@ -95,7 +95,7 @@ ClockWidget::ClockWidget()
m_next_date = navigation_container.add<GUI::Button>(); m_next_date = navigation_container.add<GUI::Button>();
m_next_date->set_button_style(Gfx::ButtonStyle::Coolbar); m_next_date->set_button_style(Gfx::ButtonStyle::Coolbar);
m_next_date->set_fixed_size(24, 24); m_next_date->set_fixed_size(24, 24);
m_next_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")); m_next_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors());
m_next_date->on_click = [&](auto) { m_next_date->on_click = [&](auto) {
unsigned view_month = m_calendar->view_month(); unsigned view_month = m_calendar->view_month();
unsigned view_year = m_calendar->view_year(); unsigned view_year = m_calendar->view_year();
@ -145,7 +145,7 @@ ClockWidget::ClockWidget()
m_jump_to_button = settings_container.add<GUI::Button>(); m_jump_to_button = settings_container.add<GUI::Button>();
m_jump_to_button->set_button_style(Gfx::ButtonStyle::Coolbar); m_jump_to_button->set_button_style(Gfx::ButtonStyle::Coolbar);
m_jump_to_button->set_fixed_size(24, 24); m_jump_to_button->set_fixed_size(24, 24);
m_jump_to_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png")); m_jump_to_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png").release_value_but_fixme_should_propagate_errors());
m_jump_to_button->set_tooltip("Jump to today"); m_jump_to_button->set_tooltip("Jump to today");
m_jump_to_button->on_click = [this](auto) { m_jump_to_button->on_click = [this](auto) {
jump_to_current_date(); jump_to_current_date();
@ -154,7 +154,7 @@ ClockWidget::ClockWidget()
m_calendar_launcher = settings_container.add<GUI::Button>(); m_calendar_launcher = settings_container.add<GUI::Button>();
m_calendar_launcher->set_button_style(Gfx::ButtonStyle::Coolbar); m_calendar_launcher->set_button_style(Gfx::ButtonStyle::Coolbar);
m_calendar_launcher->set_fixed_size(24, 24); m_calendar_launcher->set_fixed_size(24, 24);
m_calendar_launcher->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-calendar.png")); m_calendar_launcher->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-calendar.png").release_value_but_fixme_should_propagate_errors());
m_calendar_launcher->set_tooltip("Calendar"); m_calendar_launcher->set_tooltip("Calendar");
m_calendar_launcher->on_click = [](auto) { m_calendar_launcher->on_click = [](auto) {
Core::Process::spawn("/bin/Calendar"sv); Core::Process::spawn("/bin/Calendar"sv);

View file

@ -63,7 +63,7 @@ ShutdownDialog::ShutdownDialog()
icon_wrapper.set_layout<GUI::VerticalBoxLayout>(); icon_wrapper.set_layout<GUI::VerticalBoxLayout>();
auto& icon_image = icon_wrapper.add<GUI::ImageWidget>(); auto& icon_image = icon_wrapper.add<GUI::ImageWidget>();
icon_image.set_bitmap(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/shutdown.png")); icon_image.set_bitmap(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/shutdown.png").release_value_but_fixme_should_propagate_errors());
auto& right_container = content_container.add<GUI::Widget>(); auto& right_container = content_container.add<GUI::Widget>();
right_container.set_layout<GUI::VerticalBoxLayout>(); right_container.set_layout<GUI::VerticalBoxLayout>();
@ -112,7 +112,7 @@ ShutdownDialog::ShutdownDialog()
center_on_screen(); center_on_screen();
set_resizable(false); set_resizable(false);
set_title("Exit SerenityOS"); set_title("Exit SerenityOS");
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png")); set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png").release_value_but_fixme_should_propagate_errors());
// Request WindowServer to re-update us on the current theme as we might've not been alive for the last notification. // Request WindowServer to re-update us on the current theme as we might've not been alive for the last notification.
refresh_system_theme(); refresh_system_theme();

View file

@ -78,7 +78,7 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu)
m_task_button_container->set_layout<GUI::HorizontalBoxLayout>(); m_task_button_container->set_layout<GUI::HorizontalBoxLayout>();
m_task_button_container->layout()->set_spacing(3); m_task_button_container->layout()->set_spacing(3);
m_default_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); m_default_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors();
m_applet_area_container = main_widget.add<GUI::Frame>(); m_applet_area_container = main_widget.add<GUI::Frame>();
m_applet_area_container->set_frame_thickness(1); m_applet_area_container->set_frame_thickness(1);

View file

@ -113,7 +113,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
const Vector<String> sorted_app_categories = discover_apps_and_categories(); const Vector<String> sorted_app_categories = discover_apps_and_categories();
auto system_menu = GUI::Menu::construct("\xE2\x9A\xA1"); // HIGH VOLTAGE SIGN auto system_menu = GUI::Menu::construct("\xE2\x9A\xA1"); // HIGH VOLTAGE SIGN
system_menu->add_action(GUI::Action::create("&About SerenityOS", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladyball.png"), [](auto&) { system_menu->add_action(GUI::Action::create("&About SerenityOS", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladyball.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Core::Process::spawn("/bin/About"sv); Core::Process::spawn("/bin/About"sv);
})); }));
@ -148,8 +148,9 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
auto& category_menu = parent_menu->add_submenu(child_category); auto& category_menu = parent_menu->add_submenu(child_category);
auto category_icon_path = category_icons->read_entry("16x16", category); auto category_icon_path = category_icons->read_entry("16x16", category);
if (!category_icon_path.is_empty()) { if (!category_icon_path.is_empty()) {
auto icon = Gfx::Bitmap::try_load_from_file(category_icon_path); auto icon_or_error = Gfx::Bitmap::try_load_from_file(category_icon_path);
category_menu.set_icon(icon); if (!icon_or_error.is_error())
category_menu.set_icon(icon_or_error.release_value());
} }
app_category_menus.set(category, category_menu); app_category_menus.set(category, category_menu);
}; };
@ -210,7 +211,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
g_themes_group.set_unchecking_allowed(false); g_themes_group.set_unchecking_allowed(false);
g_themes_menu = &system_menu->add_submenu("&Themes"); g_themes_menu = &system_menu->add_submenu("&Themes");
g_themes_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/themes.png")); g_themes_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/themes.png").release_value_but_fixme_should_propagate_errors());
{ {
Core::DirIterator dt("/res/themes", Core::DirIterator::SkipDots); Core::DirIterator dt("/res/themes", Core::DirIterator::SkipDots);
@ -241,15 +242,15 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
} }
} }
system_menu->add_action(GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-settings.png"), [](auto&) { system_menu->add_action(GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-settings.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Core::Process::spawn("/bin/Settings"sv); Core::Process::spawn("/bin/Settings"sv);
})); }));
system_menu->add_separator(); system_menu->add_separator();
system_menu->add_action(GUI::Action::create("&Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"), [](auto&) { system_menu->add_action(GUI::Action::create("&Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Core::Process::spawn("/bin/Help"sv); Core::Process::spawn("/bin/Help"sv);
})); }));
system_menu->add_action(GUI::Action::create("&Run...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-run.png"), [](auto&) { system_menu->add_action(GUI::Action::create("&Run...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-run.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
posix_spawn_file_actions_t spawn_actions; posix_spawn_file_actions_t spawn_actions;
posix_spawn_file_actions_init(&spawn_actions); posix_spawn_file_actions_init(&spawn_actions);
auto home_directory = Core::StandardPaths::home_directory(); auto home_directory = Core::StandardPaths::home_directory();
@ -267,7 +268,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
posix_spawn_file_actions_destroy(&spawn_actions); posix_spawn_file_actions_destroy(&spawn_actions);
})); }));
system_menu->add_separator(); system_menu->add_separator();
system_menu->add_action(GUI::Action::create("E&xit...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png"), [](auto&) { system_menu->add_action(GUI::Action::create("E&xit...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
auto command = ShutdownDialog::show(); auto command = ShutdownDialog::show();
if (command.size() == 0) if (command.size() == 0)

View file

@ -807,14 +807,18 @@ bool Compositor::set_wallpaper_mode(const String& mode)
bool Compositor::set_wallpaper(const String& path, Function<void(bool)>&& callback) bool Compositor::set_wallpaper(const String& path, Function<void(bool)>&& callback)
{ {
Threading::BackgroundAction<RefPtr<Gfx::Bitmap>>::construct( Threading::BackgroundAction<ErrorOr<NonnullRefPtr<Gfx::Bitmap>>>::construct(
[path](auto&) { [path](auto&) {
return Gfx::Bitmap::try_load_from_file(path); return Gfx::Bitmap::try_load_from_file(path);
}, },
[this, path, callback = move(callback)](RefPtr<Gfx::Bitmap> bitmap) { [this, path, callback = move(callback)](ErrorOr<NonnullRefPtr<Gfx::Bitmap>> bitmap) {
if (bitmap.is_error()) {
callback(false);
return;
}
m_wallpaper_path = path; m_wallpaper_path = path;
m_wallpaper = move(bitmap); m_wallpaper = bitmap.release_value();
invalidate_screen(); invalidate_screen();
callback(true); callback(true);
}); });

Some files were not shown because too many files have changed in this diff Show more