UI/Qt: Implement download directory selection
This commit is contained in:
parent
8fbb39803e
commit
4147d771a6
Notes:
github-actions[bot]
2024-09-03 18:14:46 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/4147d771a6a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1219
3 changed files with 15 additions and 0 deletions
|
@ -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));
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue