mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
UI/Qt: Implement download directory selection
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user