mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:42:43 +00:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									68bc742d9e
								
							
						
					
					
						commit
						3f230a638d
					
				
					 2 changed files with 18 additions and 0 deletions
				
			
		|  | @ -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&) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 hhsdev
						hhsdev