mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +00:00
Browser: Use OpenInNewTab parameter in on_bookmark_click handler
This patch makes the function signature of the on_bookmark_click handler more readable by replacing `Mod_None` with `OpenInNewTab::No` and `Mod_Ctrl` with `OpenInNewTab::Yes`.
This commit is contained in:
parent
f9212ac02e
commit
5c1f1209fc
3 changed files with 12 additions and 7 deletions
|
@ -124,7 +124,7 @@ BookmarksBarWidget::BookmarksBarWidget(String const& bookmarks_file, bool enable
|
|||
auto default_action = GUI::Action::create(
|
||||
"&Open", [this](auto&) {
|
||||
if (on_bookmark_click)
|
||||
on_bookmark_click(m_context_menu_url, Mod_None);
|
||||
on_bookmark_click(m_context_menu_url, OpenInNewTab::No);
|
||||
},
|
||||
this);
|
||||
m_context_menu_default_action = default_action;
|
||||
|
@ -132,7 +132,7 @@ BookmarksBarWidget::BookmarksBarWidget(String const& bookmarks_file, bool enable
|
|||
m_context_menu->add_action(GUI::Action::create(
|
||||
"Open in New &Tab", [this](auto&) {
|
||||
if (on_bookmark_click)
|
||||
on_bookmark_click(m_context_menu_url, Mod_Ctrl);
|
||||
on_bookmark_click(m_context_menu_url, OpenInNewTab::Yes);
|
||||
},
|
||||
this));
|
||||
m_context_menu->add_separator();
|
||||
|
@ -201,9 +201,9 @@ void BookmarksBarWidget::model_did_update(unsigned)
|
|||
button.set_focus_policy(GUI::FocusPolicy::TabFocus);
|
||||
button.set_tooltip(url);
|
||||
|
||||
button.on_click = [title, url, this](auto modifiers) {
|
||||
button.on_click = [title, url, this](auto) {
|
||||
if (on_bookmark_click)
|
||||
on_bookmark_click(url, modifiers);
|
||||
on_bookmark_click(url, OpenInNewTab::No);
|
||||
};
|
||||
|
||||
button.on_context_menu_request = [this, url](auto& context_menu_event) {
|
||||
|
|
|
@ -26,7 +26,12 @@ public:
|
|||
GUI::Model* model() { return m_model.ptr(); }
|
||||
const GUI::Model* model() const { return m_model.ptr(); }
|
||||
|
||||
Function<void(String const& url, unsigned modifiers)> on_bookmark_click;
|
||||
enum class OpenInNewTab {
|
||||
Yes,
|
||||
No
|
||||
};
|
||||
|
||||
Function<void(String const& url, OpenInNewTab)> on_bookmark_click;
|
||||
Function<void(String const&, String const&)> on_bookmark_hover;
|
||||
|
||||
bool contains_bookmark(String const& url);
|
||||
|
|
|
@ -484,8 +484,8 @@ void Tab::update_bookmark_button(String const& url)
|
|||
|
||||
void Tab::did_become_active()
|
||||
{
|
||||
BookmarksBarWidget::the().on_bookmark_click = [this](auto& url, unsigned modifiers) {
|
||||
if (modifiers & Mod_Ctrl)
|
||||
BookmarksBarWidget::the().on_bookmark_click = [this](auto& url, auto open_in_new_tab) {
|
||||
if (open_in_new_tab == BookmarksBarWidget::OpenInNewTab::Yes)
|
||||
on_tab_open_request(url);
|
||||
else
|
||||
load(url);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue