mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +00:00
LibWebView: Add facilities to ask the user for a download directory
If the Downloads directory exists, we will use it (note that this will respect the XDG_DOWNLOAD_DIR environment variable). Otherwise, we will ask the UI layer to retrieve a download directory from the user. This directory is not saved, so it will be re-prompted every time. Once a proper settings UI is complete, we will of course integrate with that for persistent settings.
This commit is contained in:
parent
d392c38a73
commit
8fbb39803e
Notes:
github-actions[bot]
2024-09-03 18:14:51 +00:00
Author: https://github.com/trflynn89
Commit: 8fbb39803e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1219
2 changed files with 27 additions and 0 deletions
|
@ -7,7 +7,9 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/Environment.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibCore/TimeZoneWatcher.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibImageDecoderClient/Client.h>
|
||||
#include <LibWebView/Application.h>
|
||||
#include <LibWebView/URL.h>
|
||||
|
@ -207,4 +209,22 @@ void Application::process_did_exit(Process&& process)
|
|||
}
|
||||
}
|
||||
|
||||
ErrorOr<LexicalPath> Application::path_for_downloaded_file(StringView file) const
|
||||
{
|
||||
auto downloads_directory = Core::StandardPaths::downloads_directory();
|
||||
|
||||
if (!FileSystem::is_directory(downloads_directory)) {
|
||||
auto maybe_downloads_directory = ask_user_for_download_folder();
|
||||
if (!maybe_downloads_directory.has_value())
|
||||
return Error::from_errno(ECANCELED);
|
||||
|
||||
downloads_directory = maybe_downloads_directory.release_value();
|
||||
}
|
||||
|
||||
if (!FileSystem::is_directory(downloads_directory))
|
||||
return Error::from_errno(ENOENT);
|
||||
|
||||
return LexicalPath::join(downloads_directory, file);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue