mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibWebView+UI: Add a context menu item to download images
This introduces a simple FileDownloader to download files in the UI process from RequestServer. We use this to download the context menu image - this download is likely to hit the disk cache.
This commit is contained in:
Notes:
github-actions[bot]
2026-02-06 10:33:03 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/f322e8a29c5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7735 Reviewed-by: https://github.com/gmta
@@ -891,6 +891,13 @@ void ViewImplementation::initialize_context_menus()
|
||||
m_open_image_action = Action::create("Open Image"sv, ActionID::OpenImage, [this]() {
|
||||
load(m_context_menu_url);
|
||||
});
|
||||
m_save_image_action = Action::create("Save Image As..."sv, ActionID::SaveImage, [this]() {
|
||||
auto download_path = Application::the().path_for_downloaded_file(m_context_menu_url.basename());
|
||||
if (download_path.is_error())
|
||||
return;
|
||||
|
||||
Application::the().file_downloader().download_file(m_context_menu_url, download_path.release_value());
|
||||
});
|
||||
m_copy_image_action = Action::create("Copy Image"sv, ActionID::CopyImage, [this]() {
|
||||
if (!m_image_context_menu_bitmap.has_value())
|
||||
return;
|
||||
@@ -958,6 +965,8 @@ void ViewImplementation::initialize_context_menus()
|
||||
m_image_context_menu->add_action(*m_open_image_action);
|
||||
m_image_context_menu->add_action(*m_open_in_new_tab_action);
|
||||
m_image_context_menu->add_separator();
|
||||
m_image_context_menu->add_action(*m_save_image_action);
|
||||
m_image_context_menu->add_separator();
|
||||
m_image_context_menu->add_action(*m_copy_image_action);
|
||||
m_image_context_menu->add_action(*m_copy_url_action);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user