diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index f2d5f3ea9fb..04b4a47cd02 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -378,7 +378,10 @@ ErrorOr serenity_main(Main::Arguments arguments) auto& file_menu = window->add_menu("&File"_short_string); file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { - auto response = FileSystemAccessClient::Client::the().open_file(window); + FileSystemAccessClient::OpenFileOptions options { + .allowed_file_types = { { GUI::FileTypeFilter { "Object Files", { { "obj" } } }, GUI::FileTypeFilter::all_files() } }, + }; + auto response = FileSystemAccessClient::Client::the().open_file(window, options); if (response.is_error()) return; diff --git a/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp b/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp index 6feddc5ca47..d2fc3c215e9 100644 --- a/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp +++ b/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp @@ -92,15 +92,17 @@ ErrorOr CertificateStoreModel::add(Vector const& certificat ErrorOr CertificateStoreWidget::import_pem() { - auto fsac_result = FileSystemAccessClient::Client::the().open_file(window(), { .window_title = "Import"sv }); + FileSystemAccessClient::OpenFileOptions options { + .window_title = "Import"sv, + .allowed_file_types = Vector { + GUI::FileTypeFilter { "Certificate Files", { { "pem", "crt" } } }, + }, + }; + auto fsac_result = FileSystemAccessClient::Client::the().open_file(window(), options); if (fsac_result.is_error()) return {}; auto fsac_file = fsac_result.release_value(); - auto filename = fsac_file.filename(); - if (!(filename.ends_with_bytes(".pem"sv) || filename.ends_with_bytes(".crt"sv))) - return Error::from_string_view("File is not a .pem or .crt file."sv); - auto data = TRY(fsac_file.release_stream()->read_until_eof()); auto count = TRY(m_root_ca_model->add(TRY(DefaultRootCACertificates::parse_pem_root_certificate_authorities(data)))); diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp index 58678394400..cad31b99bd7 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -121,7 +121,11 @@ ErrorOr serenity_main(Main::Arguments arguments) // Actions auto open_action = GUI::CommonActions::make_open_action( [&](auto&) { - auto result = FileSystemAccessClient::Client::the().open_file(window, { .window_title = "Open Image"sv }); + FileSystemAccessClient::OpenFileOptions options { + .window_title = "Open Image"sv, + .allowed_file_types = Vector { GUI::FileTypeFilter::image_files(), GUI::FileTypeFilter::all_files() }, + }; + auto result = FileSystemAccessClient::Client::the().open_file(window, options); if (result.is_error()) return; diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index a7f3b789b24..d419d520338 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -210,7 +210,13 @@ ErrorOr PDFViewerWidget::initialize_menubar(GUI::Window& window) { auto file_menu = TRY(window.try_add_menu("&File"_short_string)); TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) { - auto response = FileSystemAccessClient::Client::the().open_file(&window); + FileSystemAccessClient::OpenFileOptions options { + .allowed_file_types = Vector { + GUI::FileTypeFilter { "PDF Files", { { "pdf" } } }, + GUI::FileTypeFilter::all_files(), + }, + }; + auto response = FileSystemAccessClient::Client::the().open_file(&window, options); if (!response.is_error()) open_file(response.value().filename(), response.value().release_stream()); }))); diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index e8e3168df27..1de57f7c916 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -192,7 +192,9 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) }); m_open_image_action = GUI::CommonActions::make_open_action([&](auto&) { - auto response = FileSystemAccessClient::Client::the().open_file(&window); + auto image_files = GUI::FileTypeFilter::image_files(); + image_files.extensions->append("pp"); + auto response = FileSystemAccessClient::Client::the().open_file(&window, { .allowed_file_types = Vector { image_files, GUI::FileTypeFilter::all_files() } }); if (response.is_error()) return; open_image(response.release_value()); @@ -455,7 +457,14 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) }))); TRY(m_edit_menu->try_add_action(GUI::Action::create( "&Load Color Palette...", g_icon_bag.load_color_palette, [&](auto&) { - auto response = FileSystemAccessClient::Client::the().open_file(&window, { .window_title = "Load Color Palette"sv }); + FileSystemAccessClient::OpenFileOptions options { + .window_title = "Load Color Palette"sv, + .allowed_file_types = Vector { + { "Palette Files", { { "palette" } } }, + GUI::FileTypeFilter::all_files(), + }, + }; + auto response = FileSystemAccessClient::Client::the().open_file(&window, options); if (response.is_error()) return; diff --git a/Userland/Applications/Presenter/PresenterWidget.cpp b/Userland/Applications/Presenter/PresenterWidget.cpp index 5780d324476..cfae188d73e 100644 --- a/Userland/Applications/Presenter/PresenterWidget.cpp +++ b/Userland/Applications/Presenter/PresenterWidget.cpp @@ -57,7 +57,10 @@ ErrorOr PresenterWidget::initialize_menubar() // Set up the menu bar. auto file_menu = TRY(window->try_add_menu("&File"_short_string)); auto open_action = GUI::CommonActions::make_open_action([this](auto&) { - auto response = FileSystemAccessClient::Client::the().open_file(this->window()); + FileSystemAccessClient::OpenFileOptions options { + .allowed_file_types = { { GUI::FileTypeFilter { "Presentation Files", { { "presenter" } } }, GUI::FileTypeFilter::all_files() } }, + }; + auto response = FileSystemAccessClient::Client::the().open_file(this->window(), options); if (response.is_error()) return; this->set_file(response.value().filename()); diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index 9b1037c21b4..f83843c4165 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -128,14 +128,26 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector MainWidget::initialize_menubar(GUI::Window& window) TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) { if (request_close() == GUI::Window::CloseRequestDecision::StayOpen) return; - auto response = FileSystemAccessClient::Client::the().open_file(&window, { .window_title = "Select Theme"sv, .path = "/res/themes"sv }); + FileSystemAccessClient::OpenFileOptions options { + .window_title = "Select Theme"sv, + .path = "/res/themes"sv, + .allowed_file_types = Vector { { "Theme Files", { { "ini" } } }, GUI::FileTypeFilter::all_files() }, + }; + auto response = FileSystemAccessClient::Client::the().open_file(&window, options); if (response.is_error()) return; auto load_from_file_result = load_from_file(response.value().filename(), response.value().release_stream()); diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp index 69960606d43..c74ec4b2a0e 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp @@ -384,7 +384,10 @@ ErrorOr VideoPlayerWidget::initialize_menubar(GUI::Window& window) // File menu auto file_menu = TRY(window.try_add_menu("&File"_short_string)); TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) { - auto response = FileSystemAccessClient::Client::the().open_file(&window); + FileSystemAccessClient::OpenFileOptions options { + .allowed_file_types = { { GUI::FileTypeFilter { "Video Files", { { "mkv", "webm" } } }, GUI::FileTypeFilter::all_files() } }, + }; + auto response = FileSystemAccessClient::Client::the().open_file(&window, options); if (response.is_error()) return; diff --git a/Userland/Games/Chess/main.cpp b/Userland/Games/Chess/main.cpp index 7c1e385c3de..3078169ed1b 100644 --- a/Userland/Games/Chess/main.cpp +++ b/Userland/Games/Chess/main.cpp @@ -99,7 +99,13 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(game_menu->try_add_separator()); TRY(game_menu->try_add_action(GUI::Action::create("&Import PGN...", { Mod_Ctrl, Key_O }, [&](auto&) { - auto result = FileSystemAccessClient::Client::the().open_file(window); + FileSystemAccessClient::OpenFileOptions options { + .allowed_file_types = Vector { + GUI::FileTypeFilter { "PGN Files", { { "pgn" } } }, + GUI::FileTypeFilter::all_files(), + } + }; + auto result = FileSystemAccessClient::Client::the().open_file(window, options); if (result.is_error()) return;