1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

[Windows, FileDialog] Prepend drive letter to the absolute paths without drive letter.

This commit is contained in:
bruvzg
2024-12-19 09:47:46 +02:00
parent fafc07335b
commit b9a00feb66
2 changed files with 19 additions and 2 deletions

View File

@@ -410,7 +410,14 @@ void EditorFileDialog::update_dir() {
} }
void EditorFileDialog::_dir_submitted(const String &p_dir) { void EditorFileDialog::_dir_submitted(const String &p_dir) {
dir_access->change_dir(p_dir); String new_dir = p_dir;
#ifdef WINDOWS_ENABLED
if (drives->is_visible() && !new_dir.is_network_share_path() && new_dir.is_absolute_path() && new_dir.find(":/") == -1 && new_dir.find(":\\") == -1) {
// Non network path without X:/ prefix on Windows, add drive letter.
new_dir = drives->get_item_text(drives->get_selected()).path_join(new_dir);
}
#endif
dir_access->change_dir(new_dir);
invalidate(); invalidate();
update_dir(); update_dir();
_push_history(); _push_history();

View File

@@ -398,7 +398,17 @@ void FileDialog::update_dir() {
} }
void FileDialog::_dir_submitted(String p_dir) { void FileDialog::_dir_submitted(String p_dir) {
_change_dir(root_prefix.path_join(p_dir)); String new_dir = p_dir;
#ifdef WINDOWS_ENABLED
if (root_prefix.is_empty() && drives->is_visible() && !new_dir.is_network_share_path() && new_dir.is_absolute_path() && new_dir.find(":/") == -1 && new_dir.find(":\\") == -1) {
// Non network path without X:/ prefix on Windows, add drive letter.
new_dir = drives->get_item_text(drives->get_selected()).path_join(new_dir);
}
#endif
if (!root_prefix.is_empty()) {
new_dir = root_prefix.path_join(new_dir);
}
_change_dir(new_dir);
file->set_text(""); file->set_text("");
_push_history(); _push_history();
} }