mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
UI/AppKit: Implement download directory selection
This commit is contained in:
parent
4147d771a6
commit
bf2dad5d38
Notes:
github-actions[bot]
2024-09-03 18:14:39 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/bf2dad5d38b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1219
2 changed files with 19 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <LibWebView/Application.h>
|
||||
#include <LibWebView/WebContentClient.h>
|
||||
#include <UI/LadybirdWebViewBridge.h>
|
||||
#include <Utilities/Conversions.h>
|
||||
|
||||
#import <Application/Application.h>
|
||||
|
||||
|
@ -24,6 +25,21 @@ namespace Ladybird {
|
|||
|
||||
class ApplicationBridge : public WebView::Application {
|
||||
WEB_VIEW_APPLICATION(ApplicationBridge)
|
||||
|
||||
private:
|
||||
virtual Optional<ByteString> ask_user_for_download_folder() const override
|
||||
{
|
||||
auto* panel = [NSOpenPanel openPanel];
|
||||
[panel setAllowsMultipleSelection:NO];
|
||||
[panel setCanChooseDirectories:YES];
|
||||
[panel setCanChooseFiles:NO];
|
||||
[panel setMessage:@"Select download directory"];
|
||||
|
||||
if ([panel runModal] != NSModalResponseOK)
|
||||
return {};
|
||||
|
||||
return Ladybird::ns_string_to_byte_string([[panel URL] path]);
|
||||
}
|
||||
};
|
||||
|
||||
ApplicationBridge::ApplicationBridge(Badge<WebView::Application>, Main::Arguments&)
|
||||
|
|
|
@ -1201,6 +1201,9 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
|
|||
}];
|
||||
})
|
||||
.when_rejected([self](auto const& error) {
|
||||
if (error.is_errno() && error.code() == ECANCELED)
|
||||
return;
|
||||
|
||||
auto error_message = MUST(String::formatted("{}", error));
|
||||
|
||||
auto* dialog = [[NSAlert alloc] init];
|
||||
|
|
Loading…
Reference in a new issue