mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
Ladybird: Add a context menu for audio elements
This commit is contained in:
parent
14ca04de25
commit
b3bbdb1e2c
Notes:
sideshowbarker
2024-07-16 22:26:05 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/b3bbdb1e2c Pull-request: https://github.com/SerenityOS/serenity/pull/19423
4 changed files with 36 additions and 0 deletions
|
@ -395,6 +395,21 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
|
|||
view().toggle_media_loop_state();
|
||||
});
|
||||
|
||||
auto* copy_audio_url_action = new QAction("Copy Audio &URL", this);
|
||||
copy_audio_url_action->setIcon(QIcon(QString("%1/res/icons/16x16/edit-copy.png").arg(s_serenity_resource_root.characters())));
|
||||
QObject::connect(copy_audio_url_action, &QAction::triggered, this, [this]() {
|
||||
copy_link_url(m_media_context_menu_url);
|
||||
});
|
||||
|
||||
m_audio_context_menu = make<QMenu>("Audio context menu", this);
|
||||
m_audio_context_menu->addAction(m_media_context_menu_play_pause_action);
|
||||
m_audio_context_menu->addAction(m_media_context_menu_controls_action);
|
||||
m_audio_context_menu->addAction(m_media_context_menu_loop_action);
|
||||
m_audio_context_menu->addSeparator();
|
||||
m_audio_context_menu->addAction(copy_audio_url_action);
|
||||
m_audio_context_menu->addSeparator();
|
||||
m_audio_context_menu->addAction(&m_window->inspect_dom_node_action());
|
||||
|
||||
auto* open_video_action = new QAction("&Open Video", this);
|
||||
open_video_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-video.png").arg(s_serenity_resource_root.characters())));
|
||||
QObject::connect(open_video_action, &QAction::triggered, this, [this]() {
|
||||
|
@ -443,6 +458,8 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
|
|||
|
||||
if (menu.is_video)
|
||||
m_video_context_menu->exec(screen_position);
|
||||
else
|
||||
m_audio_context_menu->exec(screen_position);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ private:
|
|||
Gfx::ShareableBitmap m_image_context_menu_bitmap;
|
||||
URL m_image_context_menu_url;
|
||||
|
||||
OwnPtr<QMenu> m_audio_context_menu;
|
||||
OwnPtr<QMenu> m_video_context_menu;
|
||||
OwnPtr<QIcon> m_media_context_menu_play_icon;
|
||||
OwnPtr<QIcon> m_media_context_menu_pause_icon;
|
||||
|
|
|
@ -384,6 +384,21 @@ Tab::Tab(BrowserWindow& window)
|
|||
view().toggle_media_loop_state();
|
||||
});
|
||||
|
||||
m_audio_context_menu = GUI::Menu::construct();
|
||||
m_audio_context_menu->add_action(*m_media_context_menu_play_pause_action);
|
||||
m_audio_context_menu->add_action(*m_media_context_menu_controls_action);
|
||||
m_audio_context_menu->add_action(*m_media_context_menu_loop_action);
|
||||
m_audio_context_menu->add_separator();
|
||||
m_audio_context_menu->add_action(GUI::Action::create("Copy Audio &URL", g_icon_bag.copy, [this](auto&) {
|
||||
GUI::Clipboard::the().set_plain_text(m_media_context_menu_url.to_deprecated_string());
|
||||
}));
|
||||
m_audio_context_menu->add_separator();
|
||||
m_audio_context_menu->add_action(GUI::Action::create("&Download", g_icon_bag.download, [this](auto&) {
|
||||
start_download(m_media_context_menu_url);
|
||||
}));
|
||||
m_audio_context_menu->add_separator();
|
||||
m_audio_context_menu->add_action(window.inspect_dom_node_action());
|
||||
|
||||
m_video_context_menu = GUI::Menu::construct();
|
||||
m_video_context_menu->add_action(*m_media_context_menu_play_pause_action);
|
||||
m_video_context_menu->add_action(*m_media_context_menu_controls_action);
|
||||
|
@ -424,6 +439,8 @@ Tab::Tab(BrowserWindow& window)
|
|||
|
||||
if (menu.is_video)
|
||||
m_video_context_menu->popup(screen_position);
|
||||
else
|
||||
m_audio_context_menu->popup(screen_position);
|
||||
};
|
||||
|
||||
view().on_link_middle_click = [this](auto& href, auto&, auto) {
|
||||
|
|
|
@ -143,6 +143,7 @@ private:
|
|||
Gfx::ShareableBitmap m_image_context_menu_bitmap;
|
||||
URL m_image_context_menu_url;
|
||||
|
||||
RefPtr<GUI::Menu> m_audio_context_menu;
|
||||
RefPtr<GUI::Menu> m_video_context_menu;
|
||||
RefPtr<GUI::Action> m_media_context_menu_play_pause_action;
|
||||
RefPtr<GUI::Action> m_media_context_menu_controls_action;
|
||||
|
|
Loading…
Reference in a new issue