diff options
author | hhsdev <heinhtetsoe.dev@gmail.com> | 2022-05-26 04:56:08 +0630 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-06-16 12:55:14 +0100 |
commit | 3f230a638d45ae16dacab03e232411eed9e4be2e (patch) | |
tree | f2595d2879110fbd2d972d5c1bcd70bd18968194 /Userland/DevTools/HackStudio | |
parent | 68bc742d9ef58b2a3db3f0c61ea375a34014ee97 (diff) | |
download | serenity-3f230a638d45ae16dacab03e232411eed9e4be2e.zip |
HackStudio: Add "Open in New Tab" context menu entry
This action creates a new editor tab and opens the selected file in the
newly created tab.
Diffstat (limited to 'Userland/DevTools/HackStudio')
-rw-r--r-- | Userland/DevTools/HackStudio/HackStudioWidget.cpp | 16 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/HackStudioWidget.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index c1dfe48626..d63ba895e8 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -471,6 +471,7 @@ NonnullRefPtr<GUI::Menu> HackStudioWidget::create_project_tree_view_context_menu m_new_plain_file_action = create_new_file_action("Plain &File", "/res/icons/16x16/new.png", ""); m_open_selected_action = create_open_selected_action(); + m_open_selected_in_new_tab_action = create_open_selected_in_new_tab_action(); m_show_in_file_manager_action = create_show_in_file_manager_action(); m_new_directory_action = create_new_directory_action(); @@ -490,6 +491,7 @@ NonnullRefPtr<GUI::Menu> HackStudioWidget::create_project_tree_view_context_menu new_file_submenu.add_action(*m_new_directory_action); project_tree_view_context_menu->add_action(*m_open_selected_action); + project_tree_view_context_menu->add_action(*m_open_selected_in_new_tab_action); project_tree_view_context_menu->add_action(*m_show_in_file_manager_action); // TODO: Cut, copy, duplicate with new name... project_tree_view_context_menu->add_separator(); @@ -582,6 +584,20 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_selected_action() return open_selected_action; } +NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_selected_in_new_tab_action() +{ + auto open_selected_in_new_tab_action = GUI::Action::create("Open in New &Tab", [this](const GUI::Action&) { + auto files = selected_file_paths(); + for (auto& file : files) { + add_new_editor(*m_current_editor_tab_widget); + open_file(file); + } + }); + open_selected_in_new_tab_action->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors()); + open_selected_in_new_tab_action->set_enabled(true); + return open_selected_in_new_tab_action; +} + NonnullRefPtr<GUI::Action> HackStudioWidget::create_show_in_file_manager_action() { auto show_in_file_manager_action = GUI::Action::create("Show in File &Manager", [this](const GUI::Action&) { diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index face53b6e7..a8bed831c6 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -100,6 +100,7 @@ private: NonnullRefPtr<GUI::Action> create_new_file_action(String const& label, String const& icon, String const& extension); NonnullRefPtr<GUI::Action> create_new_directory_action(); NonnullRefPtr<GUI::Action> create_open_selected_action(); + NonnullRefPtr<GUI::Action> create_open_selected_in_new_tab_action(); NonnullRefPtr<GUI::Action> create_delete_action(); NonnullRefPtr<GUI::Action> create_new_project_action(); NonnullRefPtr<GUI::Action> create_switch_to_next_editor_tab_widget_action(); @@ -216,6 +217,7 @@ private: RefPtr<GUI::Action> m_new_directory_action; RefPtr<GUI::Action> m_open_selected_action; + RefPtr<GUI::Action> m_open_selected_in_new_tab_action; RefPtr<GUI::Action> m_show_in_file_manager_action; RefPtr<GUI::Action> m_delete_action; RefPtr<GUI::Action> m_tree_view_rename_action; |