summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Ryan <rob@affclicks.com>2021-08-15 15:52:27 +1000
committerAndreas Kling <kling@serenityos.org>2021-08-18 10:39:13 +0200
commitdd0244a97dd71501ede69ec1ed1ff2eaee320f28 (patch)
tree94e5d52e2d4db66b2a52ff0df86112037c98f738
parent34a64ed25b00028370fdb96cd9a01fa3a3d50fd4 (diff)
downloadserenity-dd0244a97dd71501ede69ec1ed1ff2eaee320f28.zip
Browser: Add Ctrl-D keyboard shortcut for bookmarking the current page
-rw-r--r--Userland/Applications/Browser/Tab.cpp25
-rw-r--r--Userland/Applications/Browser/Tab.h1
2 files changed, 19 insertions, 7 deletions
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index ee548706f1..5bd66626f4 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -173,15 +173,15 @@ Tab::Tab(BrowserWindow& window, Type type)
m_bookmark_button->set_fixed_size(22, 22);
m_bookmark_button->on_click = [this](auto) {
- auto url = this->url().to_string();
- if (BookmarksBarWidget::the().contains_bookmark(url)) {
- BookmarksBarWidget::the().remove_bookmark(url);
- } else {
- BookmarksBarWidget::the().add_bookmark(url, m_title);
- }
- update_bookmark_button(url);
+ bookmark_current_url();
};
+ auto bookmark_action = GUI::Action::create(
+ "Bookmark current URL", { Mod_Ctrl, Key_D }, [this](auto&) {
+ bookmark_current_url();
+ },
+ this);
+
hooks().on_load_start = [this](auto& url) {
m_location_box->set_icon(nullptr);
m_location_box->set_text(url.to_string());
@@ -410,6 +410,17 @@ void Tab::update_actions()
window.go_forward_action().set_enabled(m_history.can_go_forward());
}
+void Tab::bookmark_current_url()
+{
+ auto url = this->url().to_string();
+ if (BookmarksBarWidget::the().contains_bookmark(url)) {
+ BookmarksBarWidget::the().remove_bookmark(url);
+ } else {
+ BookmarksBarWidget::the().add_bookmark(url, m_title);
+ }
+ update_bookmark_button(url);
+}
+
void Tab::update_bookmark_button(const String& url)
{
if (BookmarksBarWidget::the().contains_bookmark(url)) {
diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h
index 49c4a9ecf9..80052b168c 100644
--- a/Userland/Applications/Browser/Tab.h
+++ b/Userland/Applications/Browser/Tab.h
@@ -77,6 +77,7 @@ private:
Web::WebViewHooks& hooks();
void update_actions();
+ void bookmark_current_url();
void update_bookmark_button(const String& url);
void start_download(const URL& url);
void view_source(const URL& url, const String& source);