diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 4f87e45914f..80f14a890c0 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -473,6 +473,7 @@ NonnullRefPtr HackStudioWidget::create_project_tree_view_context_menu 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_copy_relative_path_action = create_copy_relative_path_action(); + m_copy_full_path_action = create_copy_full_path_action(); m_new_directory_action = create_new_directory_action(); m_delete_action = create_delete_action(); @@ -494,6 +495,7 @@ NonnullRefPtr HackStudioWidget::create_project_tree_view_context_menu 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); project_tree_view_context_menu->add_action(*m_copy_relative_path_action); + project_tree_view_context_menu->add_action(*m_copy_full_path_action); // TODO: Cut, copy, duplicate with new name... project_tree_view_context_menu->add_separator(); project_tree_view_context_menu->add_action(*m_tree_view_rename_action); @@ -626,6 +628,23 @@ NonnullRefPtr HackStudioWidget::create_copy_relative_path_action() return copy_relative_path_action; } +NonnullRefPtr HackStudioWidget::create_copy_full_path_action() +{ + auto copy_full_path_action = GUI::Action::create("Copy &Full Path", [this](const GUI::Action&) { + auto paths = selected_file_paths(); + VERIFY(!paths.is_empty()); + Vector full_paths; + for (auto& path : paths) + full_paths.append(get_absolute_path(path)); + auto paths_string = String::join("\n", full_paths); + GUI::Clipboard::the().set_plain_text(paths_string); + }); + copy_full_path_action->set_enabled(true); + copy_full_path_action->set_icon(GUI::Icon::default_icon("hard-disk").bitmap_for_size(16)); + + return copy_full_path_action; +} + NonnullRefPtr HackStudioWidget::create_delete_action() { auto delete_action = GUI::CommonActions::make_delete_action([this](const GUI::Action&) { diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index 406dd7553a6..e99d5ec2873 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -113,6 +113,7 @@ private: NonnullRefPtr create_save_as_action(); NonnullRefPtr create_show_in_file_manager_action(); NonnullRefPtr create_copy_relative_path_action(); + NonnullRefPtr create_copy_full_path_action(); NonnullRefPtr create_add_editor_tab_widget_action(); NonnullRefPtr create_add_editor_action(); NonnullRefPtr create_add_terminal_action(); @@ -221,6 +222,7 @@ private: RefPtr m_open_selected_in_new_tab_action; RefPtr m_show_in_file_manager_action; RefPtr m_copy_relative_path_action; + RefPtr m_copy_full_path_action; RefPtr m_delete_action; RefPtr m_tree_view_rename_action; RefPtr m_new_project_action;