mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Browser: 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
9218b2f3ce
commit
3a06d5a9a1
|
@ -23,6 +23,7 @@
|
|||
#include <Applications/Browser/URLBox.h>
|
||||
#include <Applications/BrowserSettings/Defaults.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibDesktop/Launcher.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
|
@ -658,22 +659,33 @@ Tab::Tab(BrowserWindow& window)
|
|||
},
|
||||
this);
|
||||
|
||||
auto take_visible_screenshot_action = GUI::Action::create(
|
||||
"Take &Visible Screenshot"sv, g_icon_bag.filetype_image, [this](auto&) {
|
||||
view().take_screenshot(WebView::ViewImplementation::ScreenshotType::Visible)->when_rejected([this](auto const& error) {
|
||||
auto take_screenshot = [this](auto type) {
|
||||
auto& view = this->view();
|
||||
|
||||
view.take_screenshot(type)
|
||||
->when_resolved([this](auto const& path) {
|
||||
auto message = MUST(String::formatted("Screenshot saved to: {}", path));
|
||||
auto response = GUI::MessageBox::show(&this->window(), message, "Ladybird"sv, GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::OKReveal);
|
||||
|
||||
if (response == GUI::MessageBox::ExecResult::Reveal)
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(path.dirname()));
|
||||
})
|
||||
.when_rejected([this](auto const& error) {
|
||||
auto error_message = MUST(String::formatted("{}", error));
|
||||
GUI::MessageBox::show_error(&this->window(), error_message);
|
||||
});
|
||||
};
|
||||
|
||||
auto take_visible_screenshot_action = GUI::Action::create(
|
||||
"Take &Visible Screenshot"sv, g_icon_bag.filetype_image, [take_screenshot](auto&) {
|
||||
take_screenshot(WebView::ViewImplementation::ScreenshotType::Visible);
|
||||
},
|
||||
this);
|
||||
take_visible_screenshot_action->set_status_tip("Save a screenshot of the visible portion of the current tab to the Downloads directory"_string);
|
||||
|
||||
auto take_full_screenshot_action = GUI::Action::create(
|
||||
"Take &Full Screenshot"sv, g_icon_bag.filetype_image, [this](auto&) {
|
||||
view().take_screenshot(WebView::ViewImplementation::ScreenshotType::Full)->when_rejected([this](auto const& error) {
|
||||
auto error_message = MUST(String::formatted("{}", error));
|
||||
GUI::MessageBox::show_error(&this->window(), error_message);
|
||||
});
|
||||
"Take &Full Screenshot"sv, g_icon_bag.filetype_image, [take_screenshot](auto&) {
|
||||
take_screenshot(WebView::ViewImplementation::ScreenshotType::Full);
|
||||
},
|
||||
this);
|
||||
take_full_screenshot_action->set_status_tip("Save a screenshot of the entirety of the current tab to the Downloads directory"_string);
|
||||
|
|
Loading…
Reference in a new issue