summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2020-08-29 10:56:35 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-30 09:47:49 +0200
commita5f7b7e3e788e27d2b6d6f2543e4239fd9a1a07e (patch)
tree5eab0797e21c58b1f89e71c418352e43d07ad0e8 /Applications
parente59c415ae34d428a9bbe95830656c8af6d93edf2 (diff)
downloadserenity-a5f7b7e3e788e27d2b6d6f2543e4239fd9a1a07e.zip
Browser: Mark default action in context menu of bookmarks
Diffstat (limited to 'Applications')
-rw-r--r--Applications/Browser/BookmarksBarWidget.cpp14
-rw-r--r--Applications/Browser/BookmarksBarWidget.h1
2 files changed, 11 insertions, 4 deletions
diff --git a/Applications/Browser/BookmarksBarWidget.cpp b/Applications/Browser/BookmarksBarWidget.cpp
index edb1636297..9953fa9b67 100644
--- a/Applications/Browser/BookmarksBarWidget.cpp
+++ b/Applications/Browser/BookmarksBarWidget.cpp
@@ -71,13 +71,19 @@ BookmarksBarWidget::BookmarksBarWidget(const String& bookmarks_file, bool enable
m_separator = GUI::Widget::construct();
m_context_menu = GUI::Menu::construct();
- m_context_menu->add_action(GUI::Action::create("Delete", [this](auto&) {
- remove_bookmark(m_context_menu_url);
- }));
+ auto default_action = GUI::Action::create("Open", [this](auto&) {
+ if (on_bookmark_click)
+ on_bookmark_click(m_context_menu_url, Mod_None);
+ });
+ m_context_menu_default_action = default_action;
+ m_context_menu->add_action(default_action);
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);
}));
+ m_context_menu->add_action(GUI::Action::create("Delete", [this](auto&) {
+ remove_bookmark(m_context_menu_url);
+ }));
Vector<GUI::JsonArrayModel::FieldSpec> fields;
fields.empend("title", "Title", Gfx::TextAlignment::CenterLeft);
@@ -141,7 +147,7 @@ void BookmarksBarWidget::model_did_update(unsigned)
button.on_context_menu_request = [this, url](auto& context_menu_event) {
m_context_menu_url = url;
- m_context_menu->popup(context_menu_event.screen_position());
+ m_context_menu->popup(context_menu_event.screen_position(), m_context_menu_default_action);
};
width += rect.width();
diff --git a/Applications/Browser/BookmarksBarWidget.h b/Applications/Browser/BookmarksBarWidget.h
index ba9772fa73..2eeed8fec5 100644
--- a/Applications/Browser/BookmarksBarWidget.h
+++ b/Applications/Browser/BookmarksBarWidget.h
@@ -70,6 +70,7 @@ private:
RefPtr<GUI::Menu> m_additional_menu;
RefPtr<GUI::Menu> m_context_menu;
+ RefPtr<GUI::Action> m_context_menu_default_action;
String m_context_menu_url;
NonnullRefPtrVector<GUI::Button> m_bookmarks;