mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
HackStudio: Add the "Copy Full 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 full path in the clipboard.
This commit is contained in:
parent
4ef0433be1
commit
bd74db157a
Notes:
sideshowbarker
2024-07-17 20:19:08 +09:00
Author: https://github.com/ZikiFlicky Commit: https://github.com/SerenityOS/serenity/commit/bd74db157a Pull-request: https://github.com/SerenityOS/serenity/pull/14428 Reviewed-by: https://github.com/AtkinsSJ
2 changed files with 21 additions and 0 deletions
|
@ -473,6 +473,7 @@ NonnullRefPtr<GUI::Menu> 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<GUI::Menu> 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<GUI::Action> HackStudioWidget::create_copy_relative_path_action()
|
|||
return copy_relative_path_action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<GUI::Action> 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<String> 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<GUI::Action> HackStudioWidget::create_delete_action()
|
||||
{
|
||||
auto delete_action = GUI::CommonActions::make_delete_action([this](const GUI::Action&) {
|
||||
|
|
|
@ -113,6 +113,7 @@ private:
|
|||
NonnullRefPtr<GUI::Action> create_save_as_action();
|
||||
NonnullRefPtr<GUI::Action> create_show_in_file_manager_action();
|
||||
NonnullRefPtr<GUI::Action> create_copy_relative_path_action();
|
||||
NonnullRefPtr<GUI::Action> create_copy_full_path_action();
|
||||
NonnullRefPtr<GUI::Action> create_add_editor_tab_widget_action();
|
||||
NonnullRefPtr<GUI::Action> create_add_editor_action();
|
||||
NonnullRefPtr<GUI::Action> create_add_terminal_action();
|
||||
|
@ -221,6 +222,7 @@ private:
|
|||
RefPtr<GUI::Action> m_open_selected_in_new_tab_action;
|
||||
RefPtr<GUI::Action> m_show_in_file_manager_action;
|
||||
RefPtr<GUI::Action> m_copy_relative_path_action;
|
||||
RefPtr<GUI::Action> m_copy_full_path_action;
|
||||
RefPtr<GUI::Action> m_delete_action;
|
||||
RefPtr<GUI::Action> m_tree_view_rename_action;
|
||||
RefPtr<GUI::Action> m_new_project_action;
|
||||
|
|
Loading…
Add table
Reference in a new issue