mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 11:07:46 +00:00
LibFSAC+Userland: Pass options for FSAC::open_file() using a struct
It was rather inconvenient having to specify all arguments if you wanted to modify only the last one.
This commit is contained in:
parent
5c07aeb78e
commit
27011cf55d
10 changed files with 34 additions and 16 deletions
|
@ -92,7 +92,7 @@ ErrorOr<size_t> CertificateStoreModel::add(Vector<Certificate> const& certificat
|
|||
|
||||
ErrorOr<void> CertificateStoreWidget::import_pem()
|
||||
{
|
||||
auto fsac_result = FileSystemAccessClient::Client::the().open_file(window(), "Import");
|
||||
auto fsac_result = FileSystemAccessClient::Client::the().open_file(window(), { .window_title = "Import"sv });
|
||||
if (fsac_result.is_error())
|
||||
return {};
|
||||
|
||||
|
|
|
@ -101,7 +101,12 @@ ErrorOr<void> BackgroundSettingsWidget::create_frame()
|
|||
|
||||
auto& button = *find_descendant_of_type_named<GUI::Button>("wallpaper_open_button");
|
||||
button.on_click = [this](auto) {
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(window(), "Select Wallpaper"sv, "/res/wallpapers"sv, Core::File::OpenMode::Read, { { GUI::FileTypeFilter::image_files(), GUI::FileTypeFilter::all_files() } });
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.window_title = "Select Wallpaper"sv,
|
||||
.path = "/res/wallpapers"sv,
|
||||
.allowed_file_types = { { GUI::FileTypeFilter::image_files(), GUI::FileTypeFilter::all_files() } }
|
||||
};
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(window(), options);
|
||||
if (response.is_error())
|
||||
return;
|
||||
m_wallpaper_view->selection().clear();
|
||||
|
|
|
@ -133,9 +133,12 @@ ErrorOr<void> MainWidget::create_actions()
|
|||
m_open_action = GUI::CommonActions::make_open_action([this](auto&) {
|
||||
if (!request_close())
|
||||
return;
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(window(), "Open", "/res/fonts"sv, Core::File::OpenMode::Read,
|
||||
{ { GUI::FileTypeFilter { "Bitmap Font Files", { { "font" } } },
|
||||
GUI::FileTypeFilter::all_files() } });
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.window_title = "Open"sv,
|
||||
.path = "/res/fonts"sv,
|
||||
.allowed_file_types = { { GUI::FileTypeFilter { "Bitmap Font Files", { { "font" } } }, GUI::FileTypeFilter::all_files() } },
|
||||
};
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(window(), options);
|
||||
if (response.is_error())
|
||||
return;
|
||||
auto file = response.release_value();
|
||||
|
|
|
@ -121,7 +121,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
if (!request_close())
|
||||
return;
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(window(), {}, Core::StandardPaths::home_directory(), Core::File::OpenMode::ReadWrite);
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(window(), { .requested_access = Core::File::OpenMode::ReadWrite });
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
// Actions
|
||||
auto open_action = GUI::CommonActions::make_open_action(
|
||||
[&](auto&) {
|
||||
auto result = FileSystemAccessClient::Client::the().open_file(window, "Open Image");
|
||||
auto result = FileSystemAccessClient::Client::the().open_file(window, { .window_title = "Open Image"sv });
|
||||
if (result.is_error())
|
||||
return;
|
||||
|
||||
|
|
|
@ -455,7 +455,7 @@ ErrorOr<void> 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, "Load Color Palette");
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(&window, { .window_title = "Load Color Palette"sv });
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ ErrorOr<void> 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, "Select Theme", "/res/themes"sv);
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(&window, { .window_title = "Select Theme"sv, .path = "/res/themes"sv });
|
||||
if (response.is_error())
|
||||
return;
|
||||
auto load_from_file_result = load_from_file(response.value().filename(), response.value().release_stream());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue