diff options
author | huttongrabiel <huttonthomas@icloud.com> | 2023-03-14 21:58:05 -0700 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2023-04-09 18:19:57 -0600 |
commit | ad5abc9a8fba93e1725571e3d9be26441292f0bb (patch) | |
tree | 0a3f5a16dcdd86f2525780d61ba6dd728852e13f /Userland | |
parent | 150ffc73367077efb352dabea609df608af4f2e6 (diff) | |
download | serenity-ad5abc9a8fba93e1725571e3d9be26441292f0bb.zip |
DisplaySettings: Use FileSystemAccessServer instead of FilePicker
Make a call to the FileSystemAccessServer instead of using FilePicker to
select a new wallpaper in BackgroundSettings.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp | 14 | ||||
-rw-r--r-- | Userland/Applications/DisplaySettings/CMakeLists.txt | 2 |
2 files changed, 6 insertions, 10 deletions
diff --git a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp index 1ceada02c9..71a3b19363 100644 --- a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp @@ -7,11 +7,13 @@ */ #include "BackgroundSettingsWidget.h" +#include <AK/LexicalPath.h> #include <AK/StringBuilder.h> #include <Applications/DisplaySettings/BackgroundSettingsGML.h> #include <LibConfig/Client.h> #include <LibCore/ConfigFile.h> #include <LibDesktop/Launcher.h> +#include <LibFileSystemAccessClient/Client.h> #include <LibGUI/Application.h> #include <LibGUI/BoxLayout.h> #include <LibGUI/Button.h> @@ -19,7 +21,6 @@ #include <LibGUI/ComboBox.h> #include <LibGUI/ConnectionToWindowServer.h> #include <LibGUI/Desktop.h> -#include <LibGUI/FilePicker.h> #include <LibGUI/FileSystemModel.h> #include <LibGUI/FileTypeFilter.h> #include <LibGUI/IconView.h> @@ -100,16 +101,11 @@ ErrorOr<void> BackgroundSettingsWidget::create_frame() auto& button = *find_descendant_of_type_named<GUI::Button>("wallpaper_open_button"); button.on_click = [this](auto) { - auto path_or_empty = GUI::FilePicker::get_open_filepath(window(), "Select wallpaper from file system", "/res/wallpapers"sv, false, GUI::Dialog::ScreenPosition::CenterWithinParent, { { GUI::FileTypeFilter::image_files(), GUI::FileTypeFilter::all_files() } }); - if (!path_or_empty.has_value()) + 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() } }); + if (response.is_error()) return; - auto path = String::from_deprecated_string(path_or_empty.value()); - if (path.is_error()) { - GUI::MessageBox::show_error(window(), "Unable to set wallpaper"sv); - return; - } m_wallpaper_view->selection().clear(); - m_monitor_widget->set_wallpaper(path.release_value()); + m_monitor_widget->set_wallpaper(response.release_value().filename()); m_background_settings_changed = true; set_modified(true); }; diff --git a/Userland/Applications/DisplaySettings/CMakeLists.txt b/Userland/Applications/DisplaySettings/CMakeLists.txt index 09e55bd1ac..61ed59e9d6 100644 --- a/Userland/Applications/DisplaySettings/CMakeLists.txt +++ b/Userland/Applications/DisplaySettings/CMakeLists.txt @@ -33,4 +33,4 @@ set(GENERATED_SOURCES ) serenity_app(DisplaySettings ICON app-display-settings) -target_link_libraries(DisplaySettings PRIVATE LibCore LibDesktop LibGfx LibGUI LibConfig LibIPC LibMain LibEDID LibThreading) +target_link_libraries(DisplaySettings PRIVATE LibCore LibDesktop LibGfx LibGUI LibConfig LibIPC LibMain LibEDID LibThreading LibFileSystemAccessClient) |