Skip to content

Commit 3d16ea8

Browse files
committed
Add New File Shortcuts in FileSystem Dock
It currently takes several clicks to create a file in the filesystem dock. This change adds the option to create shortcuts for creating files, greatly reducing the number of inputs required to do so.
1 parent 1f7630f commit 3d16ea8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

editor/docks/filesystem_dock.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,6 +2660,16 @@ int FileSystemDock::_get_menu_option_from_key(const Ref<InputEventKey> &p_key) {
26602660
return FILE_MENU_COPY_UID;
26612661
} else if (ED_IS_SHORTCUT("filesystem_dock/delete", p_key)) {
26622662
return FILE_MENU_REMOVE;
2663+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_folder", p_key)) {
2664+
return FILE_MENU_NEW_FOLDER;
2665+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_scene", p_key)) {
2666+
return FILE_MENU_NEW_SCENE;
2667+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_script", p_key)) {
2668+
return FILE_MENU_NEW_SCRIPT;
2669+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_resource", p_key)) {
2670+
return FILE_MENU_NEW_RESOURCE;
2671+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_textfile", p_key)) {
2672+
return FILE_MENU_NEW_TEXTFILE;
26632673
} else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_key)) {
26642674
return FILE_MENU_RENAME;
26652675
} else if (ED_IS_SHORTCUT("filesystem_dock/show_in_explorer", p_key)) {
@@ -3325,10 +3335,15 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect
33253335
p_popup->set_item_icon(p_popup->get_item_index(FILE_MENU_NEW), get_editor_theme_icon(SNAME("Add")));
33263336

33273337
new_menu->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("Folder..."), FILE_MENU_NEW_FOLDER);
3338+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_folder"));
33283339
new_menu->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTRC("Scene..."), FILE_MENU_NEW_SCENE);
3340+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_scene"));
33293341
new_menu->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTRC("Script..."), FILE_MENU_NEW_SCRIPT);
3342+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_script"));
33303343
new_menu->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTRC("Resource..."), FILE_MENU_NEW_RESOURCE);
3344+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_resource"));
33313345
new_menu->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTRC("TextFile..."), FILE_MENU_NEW_TEXTFILE);
3346+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_textfile"));
33323347

33333348
const PackedStringArray folder_path = { p_paths[0].get_base_dir() };
33343349
EditorContextMenuPluginManager::get_singleton()->add_options_from_plugins(new_menu, EditorContextMenuPlugin::CONTEXT_SLOT_FILESYSTEM_CREATE, folder_path);
@@ -3549,10 +3564,16 @@ void FileSystemDock::_tree_empty_click(const Vector2 &p_pos, MouseButton p_butto
35493564
tree_popup->clear();
35503565
tree_popup->reset_size();
35513566
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("New Folder..."), FILE_MENU_NEW_FOLDER);
3567+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_folder"));
35523568
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTRC("New Scene..."), FILE_MENU_NEW_SCENE);
3569+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_scene"));
35533570
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTRC("New Script..."), FILE_MENU_NEW_SCRIPT);
3571+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_script"));
35543572
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTRC("New Resource..."), FILE_MENU_NEW_RESOURCE);
3573+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_resource"));
35553574
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTRC("New TextFile..."), FILE_MENU_NEW_TEXTFILE);
3575+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_textfile"));
3576+
35563577
// To keep consistency with options added to "Create New..." menu (for plugin which has slot as CONTEXT_SLOT_FILESYSTEM_CREATE).
35573578
EditorContextMenuPluginManager::get_singleton()->add_options_from_plugins(tree_popup, EditorContextMenuPlugin::CONTEXT_SLOT_FILESYSTEM_CREATE, Vector<String>());
35583579
#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
@@ -3626,10 +3647,16 @@ void FileSystemDock::_file_list_empty_clicked(const Vector2 &p_pos, MouseButton
36263647
file_list_popup->reset_size();
36273648

36283649
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("New Folder..."), FILE_MENU_NEW_FOLDER);
3650+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_folder"));
36293651
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTRC("New Scene..."), FILE_MENU_NEW_SCENE);
3652+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_scene"));
36303653
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTRC("New Script..."), FILE_MENU_NEW_SCRIPT);
3654+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_script"));
36313655
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTRC("New Resource..."), FILE_MENU_NEW_RESOURCE);
3656+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_resource"));
36323657
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTRC("New TextFile..."), FILE_MENU_NEW_TEXTFILE);
3658+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_textfile"));
3659+
36333660
// To keep consistency with options added to "Create New..." menu (for plugin which has slot as CONTEXT_SLOT_FILESYSTEM_CREATE).
36343661
EditorContextMenuPluginManager::get_singleton()->add_options_from_plugins(file_list_popup, EditorContextMenuPlugin::CONTEXT_SLOT_FILESYSTEM_CREATE, Vector<String>());
36353662
file_list_popup->add_separator();
@@ -4147,6 +4174,11 @@ FileSystemDock::FileSystemDock() {
41474174
ED_SHORTCUT("filesystem_dock/copy_uid", TTRC("Copy UID"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT | KeyModifierMask::SHIFT | Key::C);
41484175
ED_SHORTCUT("filesystem_dock/duplicate", TTRC("Duplicate..."), KeyModifierMask::CMD_OR_CTRL | Key::D);
41494176
ED_SHORTCUT("filesystem_dock/delete", TTRC("Delete"), Key::KEY_DELETE);
4177+
ED_SHORTCUT("filesystem_dock/new_folder", TTRC("New Folder..."), Key::NONE);
4178+
ED_SHORTCUT("filesystem_dock/new_scene", TTRC("New Scene..."), Key::NONE);
4179+
ED_SHORTCUT("filesystem_dock/new_script", TTRC("New Script..."), Key::NONE);
4180+
ED_SHORTCUT("filesystem_dock/new_resource", TTRC("New Resource..."), Key::NONE);
4181+
ED_SHORTCUT("filesystem_dock/new_textfile", TTRC("New TextFile..."), Key::NONE);
41504182
ED_SHORTCUT("filesystem_dock/rename", TTRC("Rename..."), Key::F2);
41514183
ED_SHORTCUT_OVERRIDE("filesystem_dock/rename", "macos", Key::ENTER);
41524184
#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)

0 commit comments

Comments
 (0)