diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index 2701ed106e..9d6148d970 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -739,7 +739,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) file_menu->add_action(*m_save_action); file_menu->add_action(*m_save_as_action); file_menu->add_separator(); - TRY(file_menu->add_recent_files_list([this](auto& action) { + file_menu->add_recent_files_list([this](auto& action) { if (!request_close()) return; auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(this->window(), action.text()); @@ -748,7 +748,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto file = response.release_value(); if (auto result = open_file(file.filename(), file.release_stream()); result.is_error()) show_error(result.release_error(), "Opening"sv, file.filename()); - })); + }); file_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) { if (!request_close()) return; diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index b03e68292a..a510bc181a 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -418,7 +418,7 @@ ErrorOr HexEditorWidget::initialize_menubar(GUI::Window& window) file_menu->add_action(*m_save_action); file_menu->add_action(*m_save_as_action); file_menu->add_separator(); - TRY(file_menu->add_recent_files_list([&](auto& action) { + file_menu->add_recent_files_list([&](auto& action) { auto path = action.text(); auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, path); if (response.is_error()) @@ -426,7 +426,7 @@ ErrorOr HexEditorWidget::initialize_menubar(GUI::Window& window) auto file = response.release_value(); open_file(file.filename(), file.release_stream()); - })); + }); file_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) { if (!request_close()) return; diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp index e64b131e9d..b1eb08ed9e 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -311,7 +311,7 @@ ErrorOr serenity_main(Main::Arguments arguments) file_menu->add_action(delete_action); file_menu->add_separator(); - TRY(file_menu->add_recent_files_list([&](auto& action) { + file_menu->add_recent_files_list([&](auto& action) { auto path = action.text(); auto result = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path); if (result.is_error()) @@ -319,7 +319,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto value = result.release_value(); widget->open_file(value.filename(), value.stream()); - })); + }); file_menu->add_action(quit_action); diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index 5825d7ea8e..3318b713de 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -221,11 +221,11 @@ ErrorOr PDFViewerWidget::initialize_menubar(GUI::Window& window) open_file(response.value().filename(), response.value().release_stream()); })); file_menu->add_separator(); - TRY(file_menu->add_recent_files_list([&](auto& action) { + file_menu->add_recent_files_list([&](auto& action) { auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text()); if (!response.is_error()) open_file(response.value().filename(), response.value().release_stream()); - })); + }); file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the()->quit(); })); diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index 63b1487bf5..832f6e65ed 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -271,13 +271,13 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) file_menu->add_separator(); - TRY(file_menu->add_recent_files_list([&](auto& action) { + file_menu->add_recent_files_list([&](auto& action) { auto path = action.text(); auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, path); if (response.is_error()) return; open_image(response.release_value()); - })); + }); m_close_image_action = GUI::Action::create("&Close Image", { Mod_Ctrl, Key_W }, g_icon_bag.close_image, [&](auto&) { auto* active_widget = m_tab_widget->active_widget(); diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index 3be7595334..1be70c4e7b 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -726,7 +726,7 @@ ErrorOr SpreadsheetWidget::initialize_menubar(GUI::Window& window) file_menu->add_separator(); file_menu->add_action(*m_import_action); file_menu->add_separator(); - TRY(file_menu->add_recent_files_list([&](auto& action) { + file_menu->add_recent_files_list([&](auto& action) { if (!request_close()) return; @@ -734,7 +734,7 @@ ErrorOr SpreadsheetWidget::initialize_menubar(GUI::Window& window) if (response.is_error()) return; load_file(response.value().filename(), response.value().stream()); - })); + }); file_menu->add_action(*m_quit_action); auto edit_menu = TRY(window.try_add_menu("&Edit"_string)); diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index 19037371fb..d93c14d7b7 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -374,7 +374,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) file_menu->add_action(*m_open_folder_action); file_menu->add_separator(); - TRY(file_menu->add_recent_files_list([&](auto& action) { + file_menu->add_recent_files_list([&](auto& action) { if (editor().document().is_modified()) { auto save_document_first_result = GUI::MessageBox::ask_about_unsaved_changes(&window, m_path, editor().document().undo_stack().last_unmodified_timestamp()); if (save_document_first_result == GUI::Dialog::ExecResult::Yes) @@ -389,7 +389,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) if (auto result = read_file(response.value().filename(), response.value().stream()); result.is_error()) GUI::MessageBox::show(&window, "Unable to open file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error); - })); + }); file_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) { if (!request_close()) return; diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp index b8076a3c2c..dc3eba4a28 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.cpp +++ b/Userland/Applications/ThemeEditor/MainWidget.cpp @@ -287,7 +287,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) })); file_menu->add_separator(); - TRY(file_menu->add_recent_files_list([&](auto& action) { + file_menu->add_recent_files_list([&](auto& action) { if (request_close() == GUI::Window::CloseRequestDecision::StayOpen) return; auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text()); @@ -298,7 +298,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Can't open file named {}: {}", response.value().filename(), load_from_file_result.error())); return; } - })); + }); file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { if (request_close() == GUI::Window::CloseRequestDecision::Close) diff --git a/Userland/DevTools/GMLPlayground/MainWidget.cpp b/Userland/DevTools/GMLPlayground/MainWidget.cpp index 89bd82c52a..66511c6a00 100644 --- a/Userland/DevTools/GMLPlayground/MainWidget.cpp +++ b/Userland/DevTools/GMLPlayground/MainWidget.cpp @@ -192,14 +192,14 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) file_menu->add_action(*m_save_as_action); file_menu->add_separator(); - TRY(file_menu->add_recent_files_list([&](auto& action) { + file_menu->add_recent_files_list([&](auto& action) { if (request_close() == GUI::Window::CloseRequestDecision::StayOpen) return; auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text()); if (response.is_error()) return; load_file(response.release_value()); - })); + }); file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { if (window.on_close_request() == GUI::Window::CloseRequestDecision::Close) diff --git a/Userland/Libraries/LibGUI/Menu.cpp b/Userland/Libraries/LibGUI/Menu.cpp index 1da7faa664..ead7461148 100644 --- a/Userland/Libraries/LibGUI/Menu.cpp +++ b/Userland/Libraries/LibGUI/Menu.cpp @@ -224,7 +224,7 @@ void Menu::realize_menu_item(MenuItem& item, int item_id) } } -ErrorOr Menu::add_recent_files_list(Function callback) +void Menu::add_recent_files_list(Function callback) { m_recent_files_callback = move(callback); @@ -245,7 +245,6 @@ ErrorOr Menu::add_recent_files_list(Function callback) } add_separator(); - return {}; } } diff --git a/Userland/Libraries/LibGUI/Menu.h b/Userland/Libraries/LibGUI/Menu.h index f9950e5e51..684396763c 100644 --- a/Userland/Libraries/LibGUI/Menu.h +++ b/Userland/Libraries/LibGUI/Menu.h @@ -46,7 +46,7 @@ public: [[nodiscard]] NonnullRefPtr add_submenu(String name); void remove_all_actions(); - ErrorOr add_recent_files_list(Function); + void add_recent_files_list(Function); void popup(Gfx::IntPoint screen_position, RefPtr const& default_action = nullptr, Gfx::IntRect const& button_rect = {}); void dismiss();