summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Nilsson <brainbomb@gmail.com>2021-08-03 17:02:10 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-29 20:04:20 +0200
commit578318ca0f389f58e283e531ef83e5794b97517f (patch)
treeb3f15f95c53b061cd1d401ead976be9b1b891954
parent3b9e8ec597fa0260a60f1436e9158e5f18ef3483 (diff)
downloadserenity-578318ca0f389f58e283e531ef83e5794b97517f.zip
Browser: Use CommonActions where possible and various fixes
This replaces some actions with CommonActions and also adds '...' to menu items that require user input.
-rw-r--r--Userland/Applications/Browser/BookmarksBarWidget.cpp4
-rw-r--r--Userland/Applications/Browser/BrowserWindow.cpp12
-rw-r--r--Userland/Applications/Browser/Tab.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Action.h1
-rw-r--r--Userland/Libraries/LibGUI/CommonActions.cpp7
5 files changed, 17 insertions, 11 deletions
diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp
index da12d7e753..60552fff6e 100644
--- a/Userland/Applications/Browser/BookmarksBarWidget.cpp
+++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp
@@ -135,10 +135,10 @@ BookmarksBarWidget::BookmarksBarWidget(const String& bookmarks_file, bool enable
on_bookmark_click(m_context_menu_url, Mod_Ctrl);
}));
m_context_menu->add_separator();
- m_context_menu->add_action(GUI::Action::create("&Edit", [this](auto&) {
+ m_context_menu->add_action(GUI::Action::create("&Edit...", [this](auto&) {
edit_bookmark(m_context_menu_url);
}));
- m_context_menu->add_action(GUI::Action::create("&Delete", [this](auto&) {
+ m_context_menu->add_action(GUI::CommonActions::make_delete_action([this](auto&) {
remove_bookmark(m_context_menu_url);
}));
diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp
index 08c184ff63..6e3d463b70 100644
--- a/Userland/Applications/Browser/BrowserWindow.cpp
+++ b/Userland/Applications/Browser/BrowserWindow.cpp
@@ -125,12 +125,10 @@ void BrowserWindow::build_menus()
auto& file_menu = add_menu("&File");
file_menu.add_action(WindowActions::the().create_new_tab_action());
- auto close_tab_action = GUI::Action::create(
- "&Close Tab", { Mod_Ctrl, Key_W }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png"), [this](auto&) {
- active_tab().on_tab_close_request(active_tab());
- },
+ auto close_tab_action = GUI::CommonActions::make_close_tab_action([this](auto&) {
+ active_tab().on_tab_close_request(active_tab());
+ },
this);
- close_tab_action->set_status_tip("Close current tab");
file_menu.add_action(close_tab_action);
file_menu.add_separator();
@@ -220,7 +218,7 @@ void BrowserWindow::build_menus()
auto& settings_menu = add_menu("&Settings");
m_change_homepage_action = GUI::Action::create(
- "Set Homepage URL", [this](auto&) {
+ "Set Homepage URL...", [this](auto&) {
auto homepage_url = Config::read_string("Browser", "Preferences", "Home", "about:blank");
if (GUI::InputBox::show(this, homepage_url, "Enter URL", "Change homepage URL") == GUI::InputBox::ExecOK) {
if (URL(homepage_url).is_valid()) {
@@ -237,7 +235,7 @@ void BrowserWindow::build_menus()
m_search_engine_actions.set_exclusive(true);
auto& search_engine_menu = settings_menu.add_submenu("&Search Engine");
-
+ search_engine_menu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"));
bool search_engine_set = false;
auto add_search_engine = [&](auto& name, auto& url_format) {
auto action = GUI::Action::create_checkable(
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index 02d7733f9b..46db749e8b 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -324,10 +324,10 @@ Tab::Tab(BrowserWindow& window)
};
m_tab_context_menu = GUI::Menu::construct();
- m_tab_context_menu->add_action(GUI::Action::create("&Reload Tab", [this](auto&) {
+ m_tab_context_menu->add_action(GUI::CommonActions::make_reload_action([this](auto&) {
this->window().reload_action().activate();
}));
- m_tab_context_menu->add_action(GUI::Action::create("&Close Tab", [this](auto&) {
+ m_tab_context_menu->add_action(GUI::CommonActions::make_close_tab_action([this](auto&) {
on_tab_close_request(*this);
}));
m_tab_context_menu->add_action(GUI::Action::create("&Duplicate Tab", [this](auto&) {
diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h
index 8a47216100..dd4ea7af81 100644
--- a/Userland/Libraries/LibGUI/Action.h
+++ b/Userland/Libraries/LibGUI/Action.h
@@ -40,6 +40,7 @@ NonnullRefPtr<Action> make_help_action(Function<void(Action&)>, Core::Object* pa
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)>, Core::Object* parent = nullptr);
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)>, Core::Object* parent = nullptr);
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent = nullptr);
+NonnullRefPtr<Action> make_close_tab_action(Function<void(Action&)> callback, Core::Object* parent = nullptr);
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)>, Core::Object* parent = nullptr);
NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)>, Core::Object* parent = nullptr);
NonnullRefPtr<Action> make_rename_action(Function<void(Action&)>, Core::Object* parent = nullptr);
diff --git a/Userland/Libraries/LibGUI/CommonActions.cpp b/Userland/Libraries/LibGUI/CommonActions.cpp
index 259cb5b3a7..484ede03ca 100644
--- a/Userland/Libraries/LibGUI/CommonActions.cpp
+++ b/Userland/Libraries/LibGUI/CommonActions.cpp
@@ -136,6 +136,13 @@ NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core
return Action::create("Go &Home", { Mod_Alt, Key_Home }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent);
}
+NonnullRefPtr<Action> make_close_tab_action(Function<void(Action&)> callback, Core::Object* parent)
+{
+ auto action = Action::create("&Close Tab", { Mod_Ctrl, Key_W }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png"), move(callback), parent);
+ action->set_status_tip("Close current tab");
+ return action;
+}
+
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::Object* parent)
{
return Action::create("&Reload", { Mod_Ctrl, Key_R }, Key_F5, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"), move(callback), parent);