UI/Qt: Implement download directory selection

This commit is contained in:
Timothy Flynn 2024-08-28 15:32:30 -04:00 committed by Tim Flynn
parent 8fbb39803e
commit 4147d771a6
Notes: github-actions[bot] 2024-09-03 18:14:46 +00:00
3 changed files with 15 additions and 0 deletions

View file

@ -12,6 +12,7 @@
#include <Ladybird/Utilities.h>
#include <LibCore/ArgsParser.h>
#include <LibWebView/URL.h>
#include <QFileDialog>
#include <QFileOpenEvent>
namespace Ladybird {
@ -126,4 +127,13 @@ BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, Web
return *window;
}
Optional<ByteString> Application::ask_user_for_download_folder() const
{
auto path = QFileDialog::getExistingDirectory(nullptr, "Select download directory", QDir::homePath());
if (path.isNull())
return {};
return ak_byte_string_from_qstring(path);
}
}

View file

@ -46,6 +46,8 @@ private:
virtual void create_platform_arguments(Core::ArgsParser&) override;
virtual void create_platform_options(WebView::ChromeOptions&, WebView::WebContentOptions&) override;
virtual Optional<ByteString> ask_user_for_download_folder() const override;
bool m_enable_qt_networking { false };
TaskManagerWindow* m_task_manager_window { nullptr };

View file

@ -481,6 +481,9 @@ Tab::Tab(BrowserWindow* window, RefPtr<WebView::WebContentClient> parent_client,
}
})
.when_rejected([this](auto const& error) {
if (error.is_errno() && error.code() == ECANCELED)
return;
auto error_message = MUST(String::formatted("{}", error));
QMessageBox::warning(this, "Ladybird", qstring_from_ak_string(error_message));
});