Ladybird: Load all icons uses Core::Resource URIs

This commit is contained in:
Timothy Flynn 2023-11-05 07:45:43 -05:00 committed by Andreas Kling
parent aa9387c76c
commit 1b30b510b9
7 changed files with 97 additions and 58 deletions

View file

@ -8,6 +8,7 @@
#include <AK/String.h>
#include <AK/URL.h>
#include <Ladybird/Utilities.h>
#include <LibCore/Resource.h>
#include <LibGfx/ImageFormats/PNGWriter.h>
#include <LibGfx/ShareableBitmap.h>
@ -50,8 +51,8 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800;
static dispatch_once_t token;
dispatch_once(&token, ^{
auto default_favicon_path = MUST(String::formatted("{}/res/icons/16x16/app-browser.png", s_serenity_resource_root));
auto* ns_default_favicon_path = Ladybird::string_to_ns_string(default_favicon_path);
auto default_favicon_path = MUST(Core::Resource::load_from_uri("resource://icons/16x16/app-browser.png"sv));
auto* ns_default_favicon_path = Ladybird::string_to_ns_string(default_favicon_path->filesystem_path());
default_favicon = [[NSImage alloc] initWithContentsOfFile:ns_default_favicon_path];
});

View file

@ -118,6 +118,7 @@ if (ENABLE_QT)
Qt/ConsoleWidget.cpp
Qt/EventLoopImplementationQt.cpp
Qt/EventLoopImplementationQtEventTarget.cpp
Qt/Icon.cpp
Qt/InspectorWidget.cpp
Qt/LocationEdit.cpp
Qt/Settings.cpp

View file

@ -9,6 +9,7 @@
#include "BrowserWindow.h"
#include "ConsoleWidget.h"
#include "Icon.h"
#include "Settings.h"
#include "SettingsDialog.h"
#include "StringUtils.h"
@ -60,17 +61,17 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
auto* menu = menuBar()->addMenu("&File");
auto* new_tab_action = new QAction("New &Tab", this);
new_tab_action->setIcon(QIcon(QString("%1/res/icons/16x16/new-tab.png").arg(s_serenity_resource_root.characters())));
new_tab_action->setIcon(load_icon_from_uri("resource://icons/16x16/new-tab.png"sv));
new_tab_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::AddTab));
menu->addAction(new_tab_action);
auto* close_current_tab_action = new QAction("&Close Current Tab", this);
close_current_tab_action->setIcon(QIcon(QString("%1/res/icons/16x16/close-tab.png").arg(s_serenity_resource_root.characters())));
close_current_tab_action->setIcon(load_icon_from_uri("resource://icons/16x16/close-tab.png"sv));
close_current_tab_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Close));
menu->addAction(close_current_tab_action);
auto* open_file_action = new QAction("&Open File...", this);
open_file_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-folder-open.png").arg(s_serenity_resource_root.characters())));
open_file_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-folder-open.png"sv));
open_file_action->setShortcut(QKeySequence(QKeySequence::StandardKey::Open));
menu->addAction(open_file_action);
@ -83,13 +84,13 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
auto* edit_menu = menuBar()->addMenu("&Edit");
m_copy_selection_action = make<QAction>("&Copy", this);
m_copy_selection_action->setIcon(QIcon(QString("%1/res/icons/16x16/edit-copy.png").arg(s_serenity_resource_root.characters())));
m_copy_selection_action->setIcon(load_icon_from_uri("resource://icons/16x16/edit-copy.png"sv));
m_copy_selection_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Copy));
edit_menu->addAction(m_copy_selection_action);
QObject::connect(m_copy_selection_action, &QAction::triggered, this, &BrowserWindow::copy_selected_text);
m_select_all_action = make<QAction>("Select &All", this);
m_select_all_action->setIcon(QIcon(QString("%1/res/icons/16x16/select-all.png").arg(s_serenity_resource_root.characters())));
m_select_all_action->setIcon(load_icon_from_uri("resource://icons/16x16/select-all.png"sv));
m_select_all_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::SelectAll));
edit_menu->addAction(m_select_all_action);
QObject::connect(m_select_all_action, &QAction::triggered, this, &BrowserWindow::select_all);
@ -97,7 +98,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
edit_menu->addSeparator();
auto* settings_action = new QAction("&Settings", this);
settings_action->setIcon(QIcon(QString("%1/res/icons/16x16/settings.png").arg(s_serenity_resource_root.characters())));
settings_action->setIcon(load_icon_from_uri("resource://icons/16x16/settings.png"sv));
settings_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Preferences));
edit_menu->addAction(settings_action);
@ -118,7 +119,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
m_zoom_menu = view_menu->addMenu("&Zoom");
auto* zoom_in_action = new QAction("Zoom &In", this);
zoom_in_action->setIcon(QIcon(QString("%1/res/icons/16x16/zoom-in.png").arg(s_serenity_resource_root.characters())));
zoom_in_action->setIcon(load_icon_from_uri("resource://icons/16x16/zoom-in.png"sv));
auto zoom_in_shortcuts = QKeySequence::keyBindings(QKeySequence::StandardKey::ZoomIn);
zoom_in_shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Equal));
zoom_in_action->setShortcuts(zoom_in_shortcuts);
@ -126,13 +127,13 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
QObject::connect(zoom_in_action, &QAction::triggered, this, &BrowserWindow::zoom_in);
auto* zoom_out_action = new QAction("Zoom &Out", this);
zoom_out_action->setIcon(QIcon(QString("%1/res/icons/16x16/zoom-out.png").arg(s_serenity_resource_root.characters())));
zoom_out_action->setIcon(load_icon_from_uri("resource://icons/16x16/zoom-out.png"sv));
zoom_out_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::ZoomOut));
m_zoom_menu->addAction(zoom_out_action);
QObject::connect(zoom_out_action, &QAction::triggered, this, &BrowserWindow::zoom_out);
auto* reset_zoom_action = new QAction("&Reset Zoom", this);
reset_zoom_action->setIcon(QIcon(QString("%1/res/icons/16x16/zoom-reset.png").arg(s_serenity_resource_root.characters())));
reset_zoom_action->setIcon(load_icon_from_uri("resource://icons/16x16/zoom-reset.png"sv));
reset_zoom_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0));
m_zoom_menu->addAction(reset_zoom_action);
QObject::connect(reset_zoom_action, &QAction::triggered, this, &BrowserWindow::reset_zoom);
@ -166,7 +167,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
auto* inspect_menu = menuBar()->addMenu("&Inspect");
m_view_source_action = make<QAction>("View &Source", this);
m_view_source_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-html.png").arg(s_serenity_resource_root.characters())));
m_view_source_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-html.png"sv));
m_view_source_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U));
inspect_menu->addAction(m_view_source_action);
QObject::connect(m_view_source_action, &QAction::triggered, this, [this] {
@ -176,7 +177,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
});
auto* js_console_action = new QAction("Show &JS Console", this);
js_console_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-javascript.png").arg(s_serenity_resource_root.characters())));
js_console_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-javascript.png"sv));
js_console_action->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_J));
inspect_menu->addAction(js_console_action);
QObject::connect(js_console_action, &QAction::triggered, this, [this] {
@ -186,7 +187,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
});
auto* inspector_action = new QAction("Open &Inspector", this);
inspector_action->setIcon(QIcon(QString("%1/res/icons/browser/dom-tree.png").arg(s_serenity_resource_root.characters())));
inspector_action->setIcon(load_icon_from_uri("resource://icons/browser/dom-tree.png"sv));
inspector_action->setShortcut(QKeySequence("Ctrl+Shift+I"));
inspect_menu->addAction(inspector_action);
QObject::connect(inspector_action, &QAction::triggered, this, [this] {
@ -204,42 +205,42 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
});
auto* dump_dom_tree_action = new QAction("Dump &DOM Tree", this);
dump_dom_tree_action->setIcon(QIcon(QString("%1/res/icons/browser/dom-tree.png").arg(s_serenity_resource_root.characters())));
dump_dom_tree_action->setIcon(load_icon_from_uri("resource://icons/browser/dom-tree.png"sv));
debug_menu->addAction(dump_dom_tree_action);
QObject::connect(dump_dom_tree_action, &QAction::triggered, this, [this] {
debug_request("dump-dom-tree");
});
auto* dump_layout_tree_action = new QAction("Dump &Layout Tree", this);
dump_layout_tree_action->setIcon(QIcon(QString("%1/res/icons/16x16/layout.png").arg(s_serenity_resource_root.characters())));
dump_layout_tree_action->setIcon(load_icon_from_uri("resource://icons/16x16/layout.png"sv));
debug_menu->addAction(dump_layout_tree_action);
QObject::connect(dump_layout_tree_action, &QAction::triggered, this, [this] {
debug_request("dump-layout-tree");
});
auto* dump_paint_tree_action = new QAction("Dump &Paint Tree", this);
dump_paint_tree_action->setIcon(QIcon(QString("%1/res/icons/16x16/layout.png").arg(s_serenity_resource_root.characters())));
dump_paint_tree_action->setIcon(load_icon_from_uri("resource://icons/16x16/layout.png"sv));
debug_menu->addAction(dump_paint_tree_action);
QObject::connect(dump_paint_tree_action, &QAction::triggered, this, [this] {
debug_request("dump-paint-tree");
});
auto* dump_stacking_context_tree_action = new QAction("Dump S&tacking Context Tree", this);
dump_stacking_context_tree_action->setIcon(QIcon(QString("%1/res/icons/16x16/layers.png").arg(s_serenity_resource_root.characters())));
dump_stacking_context_tree_action->setIcon(load_icon_from_uri("resource://icons/16x16/layers.png"sv));
debug_menu->addAction(dump_stacking_context_tree_action);
QObject::connect(dump_stacking_context_tree_action, &QAction::triggered, this, [this] {
debug_request("dump-stacking-context-tree");
});
auto* dump_style_sheets_action = new QAction("Dump &Style Sheets", this);
dump_style_sheets_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-css.png").arg(s_serenity_resource_root.characters())));
dump_style_sheets_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-css.png"sv));
debug_menu->addAction(dump_style_sheets_action);
QObject::connect(dump_style_sheets_action, &QAction::triggered, this, [this] {
debug_request("dump-style-sheets");
});
auto* dump_styles_action = new QAction("Dump &All Resolved Styles", this);
dump_styles_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-css.png").arg(s_serenity_resource_root.characters())));
dump_styles_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-css.png"sv));
debug_menu->addAction(dump_styles_action);
QObject::connect(dump_styles_action, &QAction::triggered, this, [this] {
debug_request("dump-all-resolved-styles");
@ -247,21 +248,21 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
auto* dump_history_action = new QAction("Dump &History", this);
dump_history_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_H));
dump_history_action->setIcon(QIcon(QString("%1/res/icons/16x16/history.png").arg(s_serenity_resource_root.characters())));
dump_history_action->setIcon(load_icon_from_uri("resource://icons/16x16/history.png"sv));
debug_menu->addAction(dump_history_action);
QObject::connect(dump_history_action, &QAction::triggered, this, [this] {
debug_request("dump-history");
});
auto* dump_cookies_action = new QAction("Dump C&ookies", this);
dump_cookies_action->setIcon(QIcon(QString("%1/res/icons/browser/cookie.png").arg(s_serenity_resource_root.characters())));
dump_cookies_action->setIcon(load_icon_from_uri("resource://icons/browser/cookie.png"sv));
debug_menu->addAction(dump_cookies_action);
QObject::connect(dump_cookies_action, &QAction::triggered, this, [this] {
m_cookie_jar.dump_cookies();
});
auto* dump_local_storage_action = new QAction("Dump Loc&al Storage", this);
dump_local_storage_action->setIcon(QIcon(QString("%1/res/icons/browser/local-storage.png").arg(s_serenity_resource_root.characters())));
dump_local_storage_action->setIcon(load_icon_from_uri("resource://icons/browser/local-storage.png"sv));
debug_menu->addAction(dump_local_storage_action);
QObject::connect(dump_local_storage_action, &QAction::triggered, this, [this] {
debug_request("dump-local-storage");
@ -281,7 +282,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
auto* collect_garbage_action = new QAction("Collect &Garbage", this);
collect_garbage_action->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_G));
collect_garbage_action->setIcon(QIcon(QString("%1/res/icons/16x16/trash-can.png").arg(s_serenity_resource_root.characters())));
collect_garbage_action->setIcon(load_icon_from_uri("resource://icons/16x16/trash-can.png"sv));
debug_menu->addAction(collect_garbage_action);
QObject::connect(collect_garbage_action, &QAction::triggered, this, [this] {
debug_request("collect-garbage");
@ -295,14 +296,14 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
auto* clear_cache_action = new QAction("Clear &Cache", this);
clear_cache_action->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_C));
clear_cache_action->setIcon(QIcon(QString("%1/res/icons/browser/clear-cache.png").arg(s_serenity_resource_root.characters())));
clear_cache_action->setIcon(load_icon_from_uri("resource://icons/browser/clear-cache.png"sv));
debug_menu->addAction(clear_cache_action);
QObject::connect(clear_cache_action, &QAction::triggered, this, [this] {
debug_request("clear-cache");
});
auto* spoof_user_agent_menu = debug_menu->addMenu("Spoof &User Agent");
spoof_user_agent_menu->setIcon(QIcon(QString("%1/res/icons/16x16/spoof.png").arg(s_serenity_resource_root.characters())));
spoof_user_agent_menu->setIcon(load_icon_from_uri("resource://icons/16x16/spoof.png"sv));
auto* user_agent_group = new QActionGroup(this);

21
Ladybird/Qt/Icon.cpp Normal file
View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Icon.h"
#include "StringUtils.h"
#include <LibCore/Resource.h>
namespace Ladybird {
QIcon load_icon_from_uri(StringView uri)
{
auto resource = MUST(Core::Resource::load_from_uri(uri));
auto path = qstring_from_ak_string(resource->filesystem_path());
return QIcon { path };
}
}

16
Ladybird/Qt/Icon.h Normal file
View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/StringView.h>
#include <QIcon>
namespace Ladybird {
QIcon load_icon_from_uri(StringView);
}

View file

@ -7,6 +7,7 @@
#include "BrowserWindow.h"
#include "ConsoleWidget.h"
#include "Icon.h"
#include "InspectorWidget.h"
#include "Settings.h"
#include "StringUtils.h"
@ -33,8 +34,6 @@
#include <QPoint>
#include <QResizeEvent>
extern DeprecatedString s_serenity_resource_root;
namespace Ladybird {
static QIcon create_tvg_icon_with_theme_colors(QString name, QPalette const& palette)
@ -291,14 +290,14 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
};
auto* search_selected_text_action = new QAction("&Search for <query>", this);
search_selected_text_action->setIcon(QIcon(QString("%1/res/icons/16x16/find.png").arg(s_serenity_resource_root.characters())));
search_selected_text_action->setIcon(load_icon_from_uri("resource://icons/16x16/find.png"sv));
QObject::connect(search_selected_text_action, &QAction::triggered, this, [this]() {
auto url = MUST(String::formatted(Settings::the()->search_engine().query_url, URL::percent_encode(*m_page_context_menu_search_text)));
m_window->new_tab(qstring_from_ak_string(url), Web::HTML::ActivateTab::Yes);
});
auto* take_visible_screenshot_action = new QAction("Take &Visible Screenshot", this);
take_visible_screenshot_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-image.png").arg(s_serenity_resource_root.characters())));
take_visible_screenshot_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-image.png"sv));
QObject::connect(take_visible_screenshot_action, &QAction::triggered, this, [this]() {
if (auto result = view().take_screenshot(WebView::ViewImplementation::ScreenshotType::Visible); result.is_error()) {
auto error = String::formatted("{}", result.error()).release_value_but_fixme_should_propagate_errors();
@ -307,7 +306,7 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
});
auto* take_full_screenshot_action = new QAction("Take &Full Screenshot", this);
take_full_screenshot_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-image.png").arg(s_serenity_resource_root.characters())));
take_full_screenshot_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-image.png"sv));
QObject::connect(take_full_screenshot_action, &QAction::triggered, this, [this]() {
if (auto result = view().take_screenshot(WebView::ViewImplementation::ScreenshotType::Full); result.is_error()) {
auto error = String::formatted("{}", result.error()).release_value_but_fixme_should_propagate_errors();
@ -350,19 +349,19 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
};
auto* open_link_action = new QAction("&Open", this);
open_link_action->setIcon(QIcon(QString("%1/res/icons/16x16/go-forward.png").arg(s_serenity_resource_root.characters())));
open_link_action->setIcon(load_icon_from_uri("resource://icons/16x16/go-forward.png"sv));
QObject::connect(open_link_action, &QAction::triggered, this, [this]() {
open_link(m_link_context_menu_url);
});
auto* open_link_in_new_tab_action = new QAction("&Open in New &Tab", this);
open_link_in_new_tab_action->setIcon(QIcon(QString("%1/res/icons/16x16/new-tab.png").arg(s_serenity_resource_root.characters())));
open_link_in_new_tab_action->setIcon(load_icon_from_uri("resource://icons/16x16/new-tab.png"sv));
QObject::connect(open_link_in_new_tab_action, &QAction::triggered, this, [this]() {
open_link_in_new_tab(m_link_context_menu_url);
});
auto* copy_url_action = new QAction("Copy &URL", this);
copy_url_action->setIcon(QIcon(QString("%1/res/icons/16x16/edit-copy.png").arg(s_serenity_resource_root.characters())));
copy_url_action->setIcon(load_icon_from_uri("resource://icons/16x16/edit-copy.png"sv));
QObject::connect(copy_url_action, &QAction::triggered, this, [this]() {
copy_link_url(m_link_context_menu_url);
});
@ -383,19 +382,19 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
};
auto* open_image_action = new QAction("&Open Image", this);
open_image_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-image.png").arg(s_serenity_resource_root.characters())));
open_image_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-image.png"sv));
QObject::connect(open_image_action, &QAction::triggered, this, [this]() {
open_link(m_image_context_menu_url);
});
auto* open_image_in_new_tab_action = new QAction("&Open Image in New &Tab", this);
open_image_in_new_tab_action->setIcon(QIcon(QString("%1/res/icons/16x16/new-tab.png").arg(s_serenity_resource_root.characters())));
open_image_in_new_tab_action->setIcon(load_icon_from_uri("resource://icons/16x16/new-tab.png"sv));
QObject::connect(open_image_in_new_tab_action, &QAction::triggered, this, [this]() {
open_link_in_new_tab(m_image_context_menu_url);
});
auto* copy_image_action = new QAction("&Copy Image", this);
copy_image_action->setIcon(QIcon(QString("%1/res/icons/16x16/edit-copy.png").arg(s_serenity_resource_root.characters())));
copy_image_action->setIcon(load_icon_from_uri("resource://icons/16x16/edit-copy.png"sv));
QObject::connect(copy_image_action, &QAction::triggered, this, [this]() {
auto* bitmap = m_image_context_menu_bitmap.bitmap();
if (bitmap == nullptr)
@ -414,7 +413,7 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
});
auto* copy_image_url_action = new QAction("Copy Image &URL", this);
copy_image_url_action->setIcon(QIcon(QString("%1/res/icons/16x16/edit-copy.png").arg(s_serenity_resource_root.characters())));
copy_image_url_action->setIcon(load_icon_from_uri("resource://icons/16x16/edit-copy.png"sv));
QObject::connect(copy_image_url_action, &QAction::triggered, this, [this]() {
copy_link_url(m_image_context_menu_url);
});
@ -436,19 +435,19 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
m_image_context_menu->exec(screen_position);
};
m_media_context_menu_play_icon = make<QIcon>(QString("%1/res/icons/16x16/play.png").arg(s_serenity_resource_root.characters()));
m_media_context_menu_pause_icon = make<QIcon>(QString("%1/res/icons/16x16/pause.png").arg(s_serenity_resource_root.characters()));
m_media_context_menu_mute_icon = make<QIcon>(QString("%1/res/icons/16x16/audio-volume-muted.png").arg(s_serenity_resource_root.characters()));
m_media_context_menu_unmute_icon = make<QIcon>(QString("%1/res/icons/16x16/audio-volume-high.png").arg(s_serenity_resource_root.characters()));
m_media_context_menu_play_icon = load_icon_from_uri("resource://icons/16x16/play.png"sv);
m_media_context_menu_pause_icon = load_icon_from_uri("resource://icons/16x16/pause.png"sv);
m_media_context_menu_mute_icon = load_icon_from_uri("resource://icons/16x16/audio-volume-muted.png"sv);
m_media_context_menu_unmute_icon = load_icon_from_uri("resource://icons/16x16/audio-volume-high.png"sv);
m_media_context_menu_play_pause_action = make<QAction>("&Play", this);
m_media_context_menu_play_pause_action->setIcon(*m_media_context_menu_play_icon);
m_media_context_menu_play_pause_action->setIcon(m_media_context_menu_play_icon);
QObject::connect(m_media_context_menu_play_pause_action, &QAction::triggered, this, [this]() {
view().toggle_media_play_state();
});
m_media_context_menu_mute_unmute_action = make<QAction>("&Mute", this);
m_media_context_menu_mute_unmute_action->setIcon(*m_media_context_menu_mute_icon);
m_media_context_menu_mute_unmute_action->setIcon(m_media_context_menu_mute_icon);
QObject::connect(m_media_context_menu_mute_unmute_action, &QAction::triggered, this, [this]() {
view().toggle_media_mute_state();
});
@ -466,19 +465,19 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
});
auto* open_audio_action = new QAction("&Open Audio", this);
open_audio_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-sound.png").arg(s_serenity_resource_root.characters())));
open_audio_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-sound.png"sv));
QObject::connect(open_audio_action, &QAction::triggered, this, [this]() {
open_link(m_media_context_menu_url);
});
auto* open_audio_in_new_tab_action = new QAction("Open Audio in New &Tab", this);
open_audio_in_new_tab_action->setIcon(QIcon(QString("%1/res/icons/16x16/new-tab.png").arg(s_serenity_resource_root.characters())));
open_audio_in_new_tab_action->setIcon(load_icon_from_uri("resource://icons/16x16/new-tab.png"sv));
QObject::connect(open_audio_in_new_tab_action, &QAction::triggered, this, [this]() {
open_link_in_new_tab(m_media_context_menu_url);
});
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())));
copy_audio_url_action->setIcon(load_icon_from_uri("resource://icons/16x16/edit-copy.png"sv));
QObject::connect(copy_audio_url_action, &QAction::triggered, this, [this]() {
copy_link_url(m_media_context_menu_url);
});
@ -497,19 +496,19 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
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())));
open_video_action->setIcon(load_icon_from_uri("resource://icons/16x16/filetype-video.png"sv));
QObject::connect(open_video_action, &QAction::triggered, this, [this]() {
open_link(m_media_context_menu_url);
});
auto* open_video_in_new_tab_action = new QAction("Open Video in New &Tab", this);
open_video_in_new_tab_action->setIcon(QIcon(QString("%1/res/icons/16x16/new-tab.png").arg(s_serenity_resource_root.characters())));
open_video_in_new_tab_action->setIcon(load_icon_from_uri("resource://icons/16x16/new-tab.png"sv));
QObject::connect(open_video_in_new_tab_action, &QAction::triggered, this, [this]() {
open_link_in_new_tab(m_media_context_menu_url);
});
auto* copy_video_url_action = new QAction("Copy Video &URL", this);
copy_video_url_action->setIcon(QIcon(QString("%1/res/icons/16x16/edit-copy.png").arg(s_serenity_resource_root.characters())));
copy_video_url_action->setIcon(load_icon_from_uri("resource://icons/16x16/edit-copy.png"sv));
QObject::connect(copy_video_url_action, &QAction::triggered, this, [this]() {
copy_link_url(m_media_context_menu_url);
});
@ -531,18 +530,18 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
m_media_context_menu_url = menu.media_url;
if (menu.is_playing) {
m_media_context_menu_play_pause_action->setIcon(*m_media_context_menu_pause_icon);
m_media_context_menu_play_pause_action->setIcon(m_media_context_menu_pause_icon);
m_media_context_menu_play_pause_action->setText("&Pause");
} else {
m_media_context_menu_play_pause_action->setIcon(*m_media_context_menu_play_icon);
m_media_context_menu_play_pause_action->setIcon(m_media_context_menu_play_icon);
m_media_context_menu_play_pause_action->setText("&Play");
}
if (menu.is_muted) {
m_media_context_menu_mute_unmute_action->setIcon(*m_media_context_menu_unmute_icon);
m_media_context_menu_mute_unmute_action->setIcon(m_media_context_menu_unmute_icon);
m_media_context_menu_mute_unmute_action->setText("Un&mute");
} else {
m_media_context_menu_mute_unmute_action->setIcon(*m_media_context_menu_mute_icon);
m_media_context_menu_mute_unmute_action->setIcon(m_media_context_menu_mute_icon);
m_media_context_menu_mute_unmute_action->setText("&Mute");
}

View file

@ -98,10 +98,10 @@ private:
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;
OwnPtr<QIcon> m_media_context_menu_mute_icon;
OwnPtr<QIcon> m_media_context_menu_unmute_icon;
QIcon m_media_context_menu_play_icon;
QIcon m_media_context_menu_pause_icon;
QIcon m_media_context_menu_mute_icon;
QIcon m_media_context_menu_unmute_icon;
OwnPtr<QAction> m_media_context_menu_play_pause_action;
OwnPtr<QAction> m_media_context_menu_mute_unmute_action;
OwnPtr<QAction> m_media_context_menu_controls_action;