summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio/HackStudioWidget.cpp
diff options
context:
space:
mode:
authorYuval <yuval.tasher@gmail.com>2022-06-29 18:20:31 +0300
committerSam Atkins <atkinssj@gmail.com>2022-07-08 11:20:05 +0100
commit4ef0433be114ef713cca956bfb9887e47a813d58 (patch)
tree95c6a8677921aff31238c406197b872725c1f012 /Userland/DevTools/HackStudio/HackStudioWidget.cpp
parent6978b53ea00dfa731a0ead82832f59069410108a (diff)
downloadserenity-4ef0433be114ef713cca956bfb9887e47a813d58.zip
HackStudio: Add the "Copy Relative Path" TreeView context menu option
This commit adds support for the option described above. The option can be seen after a right click on a TreeView item, and it puts the item's relative path in the clipboard (relative to the project's root directory).
Diffstat (limited to 'Userland/DevTools/HackStudio/HackStudioWidget.cpp')
-rw-r--r--Userland/DevTools/HackStudio/HackStudioWidget.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
index ce54329954..4f87e45914 100644
--- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp
+++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
@@ -17,7 +17,6 @@
#include "Git/DiffViewer.h"
#include "Git/GitWidget.h"
#include "HackStudio.h"
-#include "HackStudioWidget.h"
#include "Locator.h"
#include "Project.h"
#include "ProjectDeclarations.h"
@@ -473,6 +472,7 @@ NonnullRefPtr<GUI::Menu> HackStudioWidget::create_project_tree_view_context_menu
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_copy_relative_path_action = create_copy_relative_path_action();
m_new_directory_action = create_new_directory_action();
m_delete_action = create_delete_action();
@@ -493,6 +493,7 @@ NonnullRefPtr<GUI::Menu> HackStudioWidget::create_project_tree_view_context_menu
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);
+ project_tree_view_context_menu->add_action(*m_copy_relative_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);
@@ -611,6 +612,20 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_show_in_file_manager_action(
return show_in_file_manager_action;
}
+NonnullRefPtr<GUI::Action> HackStudioWidget::create_copy_relative_path_action()
+{
+ auto copy_relative_path_action = GUI::Action::create("Copy &Relative Path", [this](const GUI::Action&) {
+ auto paths = selected_file_paths();
+ VERIFY(!paths.is_empty());
+ auto paths_string = String::join("\n", paths);
+ GUI::Clipboard::the().set_plain_text(paths_string);
+ });
+ copy_relative_path_action->set_enabled(true);
+ copy_relative_path_action->set_icon(GUI::Icon::default_icon("hard-disk").bitmap_for_size(16));
+
+ return copy_relative_path_action;
+}
+
NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
{
auto delete_action = GUI::CommonActions::make_delete_action([this](const GUI::Action&) {