Merge pull request #68489 from KoBeWi/open_in_extraterrestrial_program
Add "Open in External Program" option
This commit is contained in:
commit
c781537742
@ -439,6 +439,18 @@
|
|||||||
<member name="filesystem/directories/default_project_path" type="String" setter="" getter="">
|
<member name="filesystem/directories/default_project_path" type="String" setter="" getter="">
|
||||||
The folder where new projects should be created by default when clicking the project manager's [b]New Project[/b] button. This can be set to the same value as [member filesystem/directories/autoscan_project_path] for convenience.
|
The folder where new projects should be created by default when clicking the project manager's [b]New Project[/b] button. This can be set to the same value as [member filesystem/directories/autoscan_project_path] for convenience.
|
||||||
</member>
|
</member>
|
||||||
|
<member name="filesystem/external_programs/3d_model_editor" type="String" setter="" getter="">
|
||||||
|
The program that opens 3D model scene files when clicking "Open in External Program" option in Filesystem Dock. If not specified, the file will be opened in the system's default program.
|
||||||
|
</member>
|
||||||
|
<member name="filesystem/external_programs/audio_editor" type="String" setter="" getter="">
|
||||||
|
The program that opens audio files when clicking "Open in External Program" option in Filesystem Dock. If not specified, the file will be opened in the system's default program.
|
||||||
|
</member>
|
||||||
|
<member name="filesystem/external_programs/raster_image_editor" type="String" setter="" getter="">
|
||||||
|
The program that opens raster image files when clicking "Open in External Program" option in Filesystem Dock. If not specified, the file will be opened in the system's default program.
|
||||||
|
</member>
|
||||||
|
<member name="filesystem/external_programs/vector_image_editor" type="String" setter="" getter="">
|
||||||
|
The program that opens vector image files when clicking "Open in External Program" option in Filesystem Dock. If not specified, the file will be opened in the system's default program.
|
||||||
|
</member>
|
||||||
<member name="filesystem/file_dialog/display_mode" type="int" setter="" getter="">
|
<member name="filesystem/file_dialog/display_mode" type="int" setter="" getter="">
|
||||||
The display mode to use in the editor's file dialogs.
|
The display mode to use in the editor's file dialogs.
|
||||||
- [b]Thumbnails[/b] takes more space, but displays dynamic resource thumbnails, making resources easier to preview without having to open them.
|
- [b]Thumbnails[/b] takes more space, but displays dynamic resource thumbnails, making resources easier to preview without having to open them.
|
||||||
|
@ -473,6 +473,12 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||||||
|
|
||||||
/* Filesystem */
|
/* Filesystem */
|
||||||
|
|
||||||
|
// External Programs
|
||||||
|
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/external_programs/raster_image_editor", "", "")
|
||||||
|
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/external_programs/vector_image_editor", "", "")
|
||||||
|
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/external_programs/audio_editor", "", "")
|
||||||
|
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/external_programs/3d_model_editor", "", "")
|
||||||
|
|
||||||
// Directories
|
// Directories
|
||||||
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/directories/autoscan_project_path", "", "")
|
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/directories/autoscan_project_path", "", "")
|
||||||
const String fs_dir_default_project_path = OS::get_singleton()->has_environment("HOME") ? OS::get_singleton()->get_environment("HOME") : OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS);
|
const String fs_dir_default_project_path = OS::get_singleton()->has_environment("HOME") ? OS::get_singleton()->get_environment("HOME") : OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS);
|
||||||
|
@ -1819,6 +1819,43 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
|
|||||||
OS::get_singleton()->shell_open(String("file://") + dir);
|
OS::get_singleton()->shell_open(String("file://") + dir);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case FILE_OPEN_EXTERNAL: {
|
||||||
|
String fpath = path;
|
||||||
|
if (path == "Favorites") {
|
||||||
|
fpath = p_selected[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
String file = ProjectSettings::get_singleton()->globalize_path(fpath);
|
||||||
|
|
||||||
|
String resource_type = ResourceLoader::get_resource_type(fpath);
|
||||||
|
String external_program;
|
||||||
|
|
||||||
|
if (resource_type == "CompressedTexture2D" || resource_type == "Image") {
|
||||||
|
if (file.get_extension() == "svg" || file.get_extension() == "svgz") {
|
||||||
|
external_program = EDITOR_GET("filesystem/external_programs/vector_image_editor");
|
||||||
|
} else {
|
||||||
|
external_program = EDITOR_GET("filesystem/external_programs/raster_image_editor");
|
||||||
|
}
|
||||||
|
} else if (ClassDB::is_parent_class(resource_type, "AudioStream")) {
|
||||||
|
external_program = EDITOR_GET("filesystem/external_programs/audio_editor");
|
||||||
|
} else if (resource_type == "PackedScene") {
|
||||||
|
// Ignore non-model scenes.
|
||||||
|
if (file.get_extension() != "tscn" && file.get_extension() != "scn" && file.get_extension() != "res") {
|
||||||
|
external_program = EDITOR_GET("filesystem/external_programs/3d_model_editor");
|
||||||
|
}
|
||||||
|
} else if (ClassDB::is_parent_class(resource_type, "Script")) {
|
||||||
|
external_program = EDITOR_GET("text_editor/external/exec_path");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (external_program.is_empty()) {
|
||||||
|
OS::get_singleton()->shell_open(file);
|
||||||
|
} else {
|
||||||
|
List<String> args;
|
||||||
|
args.push_back(file);
|
||||||
|
OS::get_singleton()->create_process(external_program, args);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
case FILE_OPEN: {
|
case FILE_OPEN: {
|
||||||
// Open folders.
|
// Open folders.
|
||||||
TreeItem *selected = tree->get_root();
|
TreeItem *selected = tree->get_root();
|
||||||
@ -2606,9 +2643,13 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
|
|||||||
}
|
}
|
||||||
|
|
||||||
String fpath = p_paths[0];
|
String fpath = p_paths[0];
|
||||||
String item_text = fpath.ends_with("/") ? TTR("Open in File Manager") : TTR("Show in File Manager");
|
bool is_directory = fpath.ends_with("/");
|
||||||
|
String item_text = is_directory ? TTR("Open in File Manager") : TTR("Show in File Manager");
|
||||||
p_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER);
|
p_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER);
|
||||||
p_popup->set_item_text(p_popup->get_item_index(FILE_SHOW_IN_EXPLORER), item_text);
|
p_popup->set_item_text(p_popup->get_item_index(FILE_SHOW_IN_EXPLORER), item_text);
|
||||||
|
if (!is_directory) {
|
||||||
|
p_popup->add_icon_item(get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), TTR("Open in External Program"), FILE_OPEN_EXTERNAL);
|
||||||
|
}
|
||||||
path = fpath;
|
path = fpath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2714,6 +2755,7 @@ void FileSystemDock::_file_list_empty_clicked(const Vector2 &p_pos, MouseButton
|
|||||||
file_list_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE);
|
file_list_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE);
|
||||||
file_list_popup->add_separator();
|
file_list_popup->add_separator();
|
||||||
file_list_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER);
|
file_list_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER);
|
||||||
|
|
||||||
file_list_popup->set_position(files->get_screen_position() + p_pos);
|
file_list_popup->set_position(files->get_screen_position() + p_pos);
|
||||||
file_list_popup->reset_size();
|
file_list_popup->reset_size();
|
||||||
file_list_popup->popup();
|
file_list_popup->popup();
|
||||||
|
@ -94,6 +94,7 @@ private:
|
|||||||
FILE_NEW_SCRIPT,
|
FILE_NEW_SCRIPT,
|
||||||
FILE_NEW_SCENE,
|
FILE_NEW_SCENE,
|
||||||
FILE_SHOW_IN_EXPLORER,
|
FILE_SHOW_IN_EXPLORER,
|
||||||
|
FILE_OPEN_EXTERNAL,
|
||||||
FILE_COPY_PATH,
|
FILE_COPY_PATH,
|
||||||
FILE_COPY_UID,
|
FILE_COPY_UID,
|
||||||
FILE_NEW_RESOURCE,
|
FILE_NEW_RESOURCE,
|
||||||
|
Loading…
Reference in New Issue
Block a user