mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird/AppKit: Show an informational dialog after taking a screenshot
The dialog displays where the screenshot is saved and presents an option to open its containing folder.
This commit is contained in:
parent
8801fed54e
commit
7db8b206a8
Notes:
sideshowbarker
2024-07-16 23:08:48 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/7db8b206a8 Pull-request: https://github.com/SerenityOS/serenity/pull/22619 Reviewed-by: https://github.com/AtkinsSJ ✅
@ -798,16 +798,43 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
|
|||||||
|
|
||||||
- (void)takeVisibleScreenshot:(id)sender
|
- (void)takeVisibleScreenshot:(id)sender
|
||||||
{
|
{
|
||||||
m_web_view_bridge->take_screenshot(WebView::ViewImplementation::ScreenshotType::Visible)->when_rejected([](auto const& error) {
|
[self takeScreenshot:WebView::ViewImplementation::ScreenshotType::Visible];
|
||||||
(void)error; // FIXME: Display the error.
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)takeFullScreenshot:(id)sender
|
- (void)takeFullScreenshot:(id)sender
|
||||||
{
|
{
|
||||||
m_web_view_bridge->take_screenshot(WebView::ViewImplementation::ScreenshotType::Full)->when_rejected([](auto const& error) {
|
[self takeScreenshot:WebView::ViewImplementation::ScreenshotType::Full];
|
||||||
(void)error; // FIXME: Display the error.
|
}
|
||||||
});
|
|
||||||
|
- (void)takeScreenshot:(WebView::ViewImplementation::ScreenshotType)type
|
||||||
|
{
|
||||||
|
m_web_view_bridge->take_screenshot(type)
|
||||||
|
->when_resolved([self](auto const& path) {
|
||||||
|
auto message = MUST(String::formatted("Screenshot saved to: {}", path));
|
||||||
|
|
||||||
|
auto* dialog = [[NSAlert alloc] init];
|
||||||
|
[dialog setMessageText:Ladybird::string_to_ns_string(message)];
|
||||||
|
[[dialog addButtonWithTitle:@"OK"] setTag:NSModalResponseOK];
|
||||||
|
[[dialog addButtonWithTitle:@"Open folder"] setTag:NSModalResponseContinue];
|
||||||
|
|
||||||
|
__block auto* ns_path = Ladybird::string_to_ns_string(path.string());
|
||||||
|
|
||||||
|
[dialog beginSheetModalForWindow:[self window]
|
||||||
|
completionHandler:^(NSModalResponse response) {
|
||||||
|
if (response == NSModalResponseContinue) {
|
||||||
|
[[NSWorkspace sharedWorkspace] selectFile:ns_path inFileViewerRootedAtPath:@""];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
})
|
||||||
|
.when_rejected([self](auto const& error) {
|
||||||
|
auto error_message = MUST(String::formatted("{}", error));
|
||||||
|
|
||||||
|
auto* dialog = [[NSAlert alloc] init];
|
||||||
|
[dialog setMessageText:Ladybird::string_to_ns_string(error_message)];
|
||||||
|
|
||||||
|
[dialog beginSheetModalForWindow:[self window]
|
||||||
|
completionHandler:nil];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)openLink:(id)sender
|
- (void)openLink:(id)sender
|
||||||
|
Loading…
Reference in New Issue
Block a user