mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-26 03:08:59 +00:00
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: 4147d771a6
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 <Ladybird/Utilities.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibWebView/URL.h>
|
#include <LibWebView/URL.h>
|
||||||
|
#include <QFileDialog>
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
|
|
||||||
namespace Ladybird {
|
namespace Ladybird {
|
||||||
|
@ -126,4 +127,13 @@ BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, Web
|
||||||
return *window;
|
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_arguments(Core::ArgsParser&) override;
|
||||||
virtual void create_platform_options(WebView::ChromeOptions&, WebView::WebContentOptions&) 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 };
|
bool m_enable_qt_networking { false };
|
||||||
|
|
||||||
TaskManagerWindow* m_task_manager_window { nullptr };
|
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) {
|
.when_rejected([this](auto const& error) {
|
||||||
|
if (error.is_errno() && error.code() == ECANCELED)
|
||||||
|
return;
|
||||||
|
|
||||||
auto error_message = MUST(String::formatted("{}", error));
|
auto error_message = MUST(String::formatted("{}", error));
|
||||||
QMessageBox::warning(this, "Ladybird", qstring_from_ak_string(error_message));
|
QMessageBox::warning(this, "Ladybird", qstring_from_ak_string(error_message));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue