Browser: Add context menu icons

This adds two new icons for browser context menu items "Close Other
Tabs" and "Download".

This adds existing icons where they were missing in context menu items.
This commit is contained in:
electrikmilk 2022-09-07 23:18:19 -04:00 committed by Linus Groh
parent 6193fdb477
commit 6675865582
Notes: sideshowbarker 2024-07-17 07:21:52 +09:00
6 changed files with 25 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

View file

@ -124,7 +124,7 @@ BookmarksBarWidget::BookmarksBarWidget(String const& bookmarks_file, bool enable
m_context_menu = GUI::Menu::construct(); m_context_menu = GUI::Menu::construct();
auto default_action = GUI::Action::create( auto default_action = GUI::Action::create(
"&Open", [this](auto&) { "&Open", g_icon_bag.go_to, [this](auto&) {
if (on_bookmark_click) if (on_bookmark_click)
on_bookmark_click(m_context_menu_url, OpenInNewTab::No); on_bookmark_click(m_context_menu_url, OpenInNewTab::No);
}, },
@ -132,14 +132,14 @@ BookmarksBarWidget::BookmarksBarWidget(String const& bookmarks_file, bool enable
m_context_menu_default_action = default_action; m_context_menu_default_action = default_action;
m_context_menu->add_action(default_action); m_context_menu->add_action(default_action);
m_context_menu->add_action(GUI::Action::create( m_context_menu->add_action(GUI::Action::create(
"Open in New &Tab", [this](auto&) { "Open in New &Tab", g_icon_bag.new_tab, [this](auto&) {
if (on_bookmark_click) if (on_bookmark_click)
on_bookmark_click(m_context_menu_url, OpenInNewTab::Yes); on_bookmark_click(m_context_menu_url, OpenInNewTab::Yes);
}, },
this)); this));
m_context_menu->add_separator(); m_context_menu->add_separator();
m_context_menu->add_action(GUI::Action::create( m_context_menu->add_action(GUI::Action::create(
"&Edit...", [this](auto&) { "&Edit...", g_icon_bag.rename, [this](auto&) {
edit_bookmark(m_context_menu_url); edit_bookmark(m_context_menu_url);
}, },
this)); this));

View file

@ -15,6 +15,7 @@ ErrorOr<IconBag> IconBag::try_create()
icon_bag.filetype_html = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"sv)); icon_bag.filetype_html = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"sv));
icon_bag.filetype_text = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-text.png"sv)); icon_bag.filetype_text = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-text.png"sv));
icon_bag.filetype_javascript = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png"sv)); icon_bag.filetype_javascript = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png"sv));
icon_bag.filetype_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-image.png"sv));
icon_bag.bookmark_contour = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png"sv)); icon_bag.bookmark_contour = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png"sv));
icon_bag.bookmark_filled = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-filled.png"sv)); icon_bag.bookmark_filled = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-filled.png"sv));
icon_bag.inspector_object = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv)); icon_bag.inspector_object = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv));
@ -24,6 +25,7 @@ ErrorOr<IconBag> IconBag::try_create()
icon_bag.delete_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv)); icon_bag.delete_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv));
icon_bag.new_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"sv)); icon_bag.new_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"sv));
icon_bag.duplicate_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/duplicate-tab.png"sv)); icon_bag.duplicate_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/duplicate-tab.png"sv));
icon_bag.close_other_tabs = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-other-tabs.png"sv));
icon_bag.code = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/code.png"sv)); icon_bag.code = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/code.png"sv));
icon_bag.dom_tree = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/dom-tree.png"sv)); icon_bag.dom_tree = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/dom-tree.png"sv));
icon_bag.layout = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png"sv)); icon_bag.layout = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png"sv));
@ -36,6 +38,10 @@ ErrorOr<IconBag> IconBag::try_create()
icon_bag.trash_can = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/trash-can.png"sv)); icon_bag.trash_can = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/trash-can.png"sv));
icon_bag.clear_cache = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/clear-cache.png"sv)); icon_bag.clear_cache = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/clear-cache.png"sv));
icon_bag.spoof = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/spoof.png"sv)); icon_bag.spoof = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/spoof.png"sv));
icon_bag.go_to = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv));
icon_bag.download = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/download.png"sv));
icon_bag.copy = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv));
icon_bag.rename = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/rename.png"sv));
return icon_bag; return icon_bag;
} }

View file

@ -16,6 +16,7 @@ struct IconBag final {
RefPtr<Gfx::Bitmap> filetype_html { nullptr }; RefPtr<Gfx::Bitmap> filetype_html { nullptr };
RefPtr<Gfx::Bitmap> filetype_text { nullptr }; RefPtr<Gfx::Bitmap> filetype_text { nullptr };
RefPtr<Gfx::Bitmap> filetype_javascript { nullptr }; RefPtr<Gfx::Bitmap> filetype_javascript { nullptr };
RefPtr<Gfx::Bitmap> filetype_image { nullptr };
RefPtr<Gfx::Bitmap> bookmark_contour { nullptr }; RefPtr<Gfx::Bitmap> bookmark_contour { nullptr };
RefPtr<Gfx::Bitmap> bookmark_filled { nullptr }; RefPtr<Gfx::Bitmap> bookmark_filled { nullptr };
RefPtr<Gfx::Bitmap> inspector_object { nullptr }; RefPtr<Gfx::Bitmap> inspector_object { nullptr };
@ -25,6 +26,7 @@ struct IconBag final {
RefPtr<Gfx::Bitmap> delete_icon { nullptr }; RefPtr<Gfx::Bitmap> delete_icon { nullptr };
RefPtr<Gfx::Bitmap> new_tab { nullptr }; RefPtr<Gfx::Bitmap> new_tab { nullptr };
RefPtr<Gfx::Bitmap> duplicate_tab { nullptr }; RefPtr<Gfx::Bitmap> duplicate_tab { nullptr };
RefPtr<Gfx::Bitmap> close_other_tabs { nullptr };
RefPtr<Gfx::Bitmap> code { nullptr }; RefPtr<Gfx::Bitmap> code { nullptr };
RefPtr<Gfx::Bitmap> dom_tree { nullptr }; RefPtr<Gfx::Bitmap> dom_tree { nullptr };
RefPtr<Gfx::Bitmap> layout { nullptr }; RefPtr<Gfx::Bitmap> layout { nullptr };
@ -37,5 +39,9 @@ struct IconBag final {
RefPtr<Gfx::Bitmap> trash_can { nullptr }; RefPtr<Gfx::Bitmap> trash_can { nullptr };
RefPtr<Gfx::Bitmap> clear_cache { nullptr }; RefPtr<Gfx::Bitmap> clear_cache { nullptr };
RefPtr<Gfx::Bitmap> spoof { nullptr }; RefPtr<Gfx::Bitmap> spoof { nullptr };
RefPtr<Gfx::Bitmap> go_to { nullptr };
RefPtr<Gfx::Bitmap> download { nullptr };
RefPtr<Gfx::Bitmap> copy { nullptr };
RefPtr<Gfx::Bitmap> rename { nullptr };
}; };
} }

View file

@ -247,20 +247,20 @@ Tab::Tab(BrowserWindow& window)
}; };
m_link_context_menu = GUI::Menu::construct(); m_link_context_menu = GUI::Menu::construct();
auto link_default_action = GUI::Action::create("&Open", [this](auto&) { auto link_default_action = GUI::Action::create("&Open", g_icon_bag.go_to, [this](auto&) {
view().on_link_click(m_link_context_menu_url, "", 0); view().on_link_click(m_link_context_menu_url, "", 0);
}); });
m_link_context_menu->add_action(link_default_action); m_link_context_menu->add_action(link_default_action);
m_link_context_menu_default_action = link_default_action; m_link_context_menu_default_action = link_default_action;
m_link_context_menu->add_action(GUI::Action::create("Open in New &Tab", [this](auto&) { m_link_context_menu->add_action(GUI::Action::create("Open in New &Tab", g_icon_bag.new_tab, [this](auto&) {
view().on_link_click(m_link_context_menu_url, "_blank", 0); view().on_link_click(m_link_context_menu_url, "_blank", 0);
})); }));
m_link_context_menu->add_separator(); m_link_context_menu->add_separator();
m_link_context_menu->add_action(GUI::Action::create("&Copy URL", [this](auto&) { m_link_context_menu->add_action(GUI::Action::create("&Copy URL", g_icon_bag.copy, [this](auto&) {
GUI::Clipboard::the().set_plain_text(m_link_context_menu_url.to_string()); GUI::Clipboard::the().set_plain_text(m_link_context_menu_url.to_string());
})); }));
m_link_context_menu->add_separator(); m_link_context_menu->add_separator();
m_link_context_menu->add_action(GUI::Action::create("&Download", [this](auto&) { m_link_context_menu->add_action(GUI::Action::create("&Download", g_icon_bag.download, [this](auto&) {
start_download(m_link_context_menu_url); start_download(m_link_context_menu_url);
})); }));
m_link_context_menu->add_separator(); m_link_context_menu->add_separator();
@ -272,22 +272,22 @@ Tab::Tab(BrowserWindow& window)
}; };
m_image_context_menu = GUI::Menu::construct(); m_image_context_menu = GUI::Menu::construct();
m_image_context_menu->add_action(GUI::Action::create("&Open Image", [this](auto&) { m_image_context_menu->add_action(GUI::Action::create("&Open Image", g_icon_bag.filetype_image, [this](auto&) {
view().on_link_click(m_image_context_menu_url, "", 0); view().on_link_click(m_image_context_menu_url, "", 0);
})); }));
m_image_context_menu->add_action(GUI::Action::create("Open Image in New &Tab", [this](auto&) { m_image_context_menu->add_action(GUI::Action::create("Open Image in New &Tab", g_icon_bag.new_tab, [this](auto&) {
view().on_link_click(m_image_context_menu_url, "_blank", 0); view().on_link_click(m_image_context_menu_url, "_blank", 0);
})); }));
m_image_context_menu->add_separator(); m_image_context_menu->add_separator();
m_image_context_menu->add_action(GUI::Action::create("&Copy Image", [this](auto&) { m_image_context_menu->add_action(GUI::Action::create("&Copy Image", g_icon_bag.copy, [this](auto&) {
if (m_image_context_menu_bitmap.is_valid()) if (m_image_context_menu_bitmap.is_valid())
GUI::Clipboard::the().set_bitmap(*m_image_context_menu_bitmap.bitmap()); GUI::Clipboard::the().set_bitmap(*m_image_context_menu_bitmap.bitmap());
})); }));
m_image_context_menu->add_action(GUI::Action::create("Copy Image &URL", [this](auto&) { m_image_context_menu->add_action(GUI::Action::create("Copy Image &URL", g_icon_bag.copy, [this](auto&) {
GUI::Clipboard::the().set_plain_text(m_image_context_menu_url.to_string()); GUI::Clipboard::the().set_plain_text(m_image_context_menu_url.to_string());
})); }));
m_image_context_menu->add_separator(); m_image_context_menu->add_separator();
m_image_context_menu->add_action(GUI::Action::create("&Download", [this](auto&) { m_image_context_menu->add_action(GUI::Action::create("&Download", g_icon_bag.download, [this](auto&) {
start_download(m_image_context_menu_url); start_download(m_image_context_menu_url);
})); }));
m_image_context_menu->add_separator(); m_image_context_menu->add_separator();
@ -386,7 +386,7 @@ Tab::Tab(BrowserWindow& window)
m_tab_context_menu->add_action(GUI::Action::create("&Duplicate Tab", g_icon_bag.duplicate_tab, [this](auto&) { m_tab_context_menu->add_action(GUI::Action::create("&Duplicate Tab", g_icon_bag.duplicate_tab, [this](auto&) {
on_tab_open_request(url()); on_tab_open_request(url());
})); }));
m_tab_context_menu->add_action(GUI::Action::create("Close &Other Tabs", [this](auto&) { m_tab_context_menu->add_action(GUI::Action::create("Close &Other Tabs", g_icon_bag.close_other_tabs, [this](auto&) {
on_tab_close_other_request(*this); on_tab_close_other_request(*this);
})); }));