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