2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2017-01-16 08:04:19 +01:00
|
|
|
/* filesystem_dock.cpp */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2018-01-01 14:40:08 +01:00
|
|
|
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 02:10:30 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
#include "filesystem_dock.h"
|
2017-01-16 08:04:19 +01:00
|
|
|
|
2018-01-05 20:45:54 +01:00
|
|
|
#include "core/os/keyboard.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "editor_node.h"
|
|
|
|
#include "editor_settings.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "io/resource_loader.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "os/dir_access.h"
|
|
|
|
#include "os/file_access.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "os/os.h"
|
2017-07-30 22:53:40 +02:00
|
|
|
#include "project_settings.h"
|
2016-05-16 01:25:51 +02:00
|
|
|
#include "scene/main/viewport.h"
|
2016-07-06 19:04:21 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *item = tree->create_item(p_parent);
|
2017-03-05 16:44:50 +01:00
|
|
|
String dname = p_dir->get_name();
|
|
|
|
if (dname == "")
|
|
|
|
dname = "res://";
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
item->set_text(0, dname);
|
|
|
|
item->set_icon(0, get_icon("Folder", "EditorIcons"));
|
|
|
|
item->set_selectable(0, true);
|
2015-08-24 01:15:56 +02:00
|
|
|
String lpath = p_dir->get_path();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (lpath != "res://" && lpath.ends_with("/")) {
|
|
|
|
lpath = lpath.substr(0, lpath.length() - 1);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
item->set_metadata(0, lpath);
|
|
|
|
if (lpath == path) {
|
2015-08-24 01:15:56 +02:00
|
|
|
item->select(0);
|
|
|
|
}
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if ((path.begins_with(lpath) && path != lpath)) {
|
|
|
|
item->set_collapsed(false);
|
|
|
|
} else {
|
|
|
|
bool is_collapsed = true;
|
|
|
|
for (int i = 0; i < uncollapsed_paths.size(); i++) {
|
|
|
|
if (lpath == uncollapsed_paths[i]) {
|
|
|
|
is_collapsed = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
item->set_collapsed(is_collapsed);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < p_dir->get_subdir_count(); i++)
|
2017-09-03 22:35:18 +02:00
|
|
|
_create_tree(item, p_dir->get_subdir(i), uncollapsed_paths);
|
2016-07-08 09:15:31 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-01 02:53:31 +01:00
|
|
|
void FileSystemDock::_update_tree(bool keep_collapse_state, bool p_uncollapse_root) {
|
2017-09-03 22:35:18 +02:00
|
|
|
|
|
|
|
Vector<String> uncollapsed_paths;
|
|
|
|
if (keep_collapse_state) {
|
|
|
|
TreeItem *root = tree->get_root();
|
|
|
|
if (root) {
|
|
|
|
TreeItem *resTree = root->get_children()->get_next();
|
|
|
|
|
|
|
|
Vector<TreeItem *> needs_check;
|
|
|
|
needs_check.push_back(resTree);
|
|
|
|
|
|
|
|
while (needs_check.size()) {
|
|
|
|
if (!needs_check[0]->is_collapsed()) {
|
|
|
|
uncollapsed_paths.push_back(needs_check[0]->get_metadata(0));
|
|
|
|
TreeItem *child = needs_check[0]->get_children();
|
|
|
|
while (child) {
|
|
|
|
needs_check.push_back(child);
|
|
|
|
child = child->get_next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
needs_check.remove(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
tree->clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
updating_tree = true;
|
2017-09-03 22:35:18 +02:00
|
|
|
|
2015-08-24 01:15:56 +02:00
|
|
|
TreeItem *root = tree->create_item();
|
|
|
|
TreeItem *favorites = tree->create_item(root);
|
2017-03-05 16:44:50 +01:00
|
|
|
favorites->set_icon(0, get_icon("Favorites", "EditorIcons"));
|
|
|
|
favorites->set_text(0, TTR("Favorites:"));
|
|
|
|
favorites->set_selectable(0, false);
|
2017-09-03 22:35:18 +02:00
|
|
|
|
|
|
|
Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorite_dirs();
|
|
|
|
String res_path = "res://";
|
|
|
|
Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons");
|
|
|
|
for (int i = 0; i < favorite_paths.size(); i++) {
|
|
|
|
String fave = favorite_paths[i];
|
|
|
|
if (!fave.begins_with(res_path))
|
2015-08-24 01:15:56 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
TreeItem *ti = tree->create_item(favorites);
|
2017-09-03 22:35:18 +02:00
|
|
|
if (fave == res_path)
|
2017-03-05 16:44:50 +01:00
|
|
|
ti->set_text(0, "/");
|
2015-08-24 01:15:56 +02:00
|
|
|
else
|
2017-09-03 22:35:18 +02:00
|
|
|
ti->set_text(0, fave.get_file());
|
|
|
|
ti->set_icon(0, folder_icon);
|
2017-03-05 16:44:50 +01:00
|
|
|
ti->set_selectable(0, true);
|
2017-09-03 22:35:18 +02:00
|
|
|
ti->set_metadata(0, fave);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2018-02-01 02:53:31 +01:00
|
|
|
if (p_uncollapse_root) {
|
|
|
|
uncollapsed_paths.push_back("res://");
|
|
|
|
}
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
_create_tree(root, EditorFileSystem::get_singleton()->get_filesystem(), uncollapsed_paths);
|
2017-12-16 14:52:51 +01:00
|
|
|
tree->ensure_cursor_is_visible();
|
2017-03-05 16:44:50 +01:00
|
|
|
updating_tree = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_notification(int p_what) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
switch (p_what) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
case NOTIFICATION_RESIZED: {
|
|
|
|
|
2017-08-07 05:44:34 +02:00
|
|
|
bool new_mode = get_size().height < get_viewport_rect().size.height / 2;
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (new_mode != low_height_mode) {
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
low_height_mode = new_mode;
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (low_height_mode) {
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-12-21 20:16:04 +01:00
|
|
|
tree->hide();
|
2016-05-16 01:25:51 +02:00
|
|
|
tree->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-09-03 22:35:18 +02:00
|
|
|
button_tree->show();
|
2016-05-16 01:25:51 +02:00
|
|
|
} else {
|
|
|
|
|
|
|
|
tree->set_v_size_flags(SIZE_FILL);
|
2018-01-31 20:47:23 +01:00
|
|
|
button_tree->hide();
|
2017-09-03 22:35:18 +02:00
|
|
|
if (!tree->is_visible()) {
|
|
|
|
tree->show();
|
|
|
|
button_favorite->show();
|
|
|
|
_update_tree(true);
|
|
|
|
}
|
2017-12-21 20:16:04 +01:00
|
|
|
tree->ensure_cursor_is_visible();
|
2017-09-03 22:35:18 +02:00
|
|
|
|
|
|
|
if (!file_list_vb->is_visible()) {
|
|
|
|
file_list_vb->show();
|
|
|
|
_update_files(true);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
2014-11-06 01:20:42 +01:00
|
|
|
case NOTIFICATION_ENTER_TREE: {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-08-24 01:15:56 +02:00
|
|
|
if (initialized)
|
|
|
|
return;
|
2017-03-05 16:44:50 +01:00
|
|
|
initialized = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_fs_changed");
|
|
|
|
EditorResourcePreview::get_singleton()->connect("preview_invalidated", this, "_preview_invalidated");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
String ei = "EditorIcons";
|
|
|
|
button_reload->set_icon(get_icon("Reload", ei));
|
|
|
|
button_favorite->set_icon(get_icon("Favorites", ei));
|
|
|
|
//button_instance->set_icon(get_icon("Add", ei));
|
|
|
|
//button_open->set_icon(get_icon("Folder", ei));
|
|
|
|
button_tree->set_icon(get_icon("Filesystem", ei));
|
2017-09-12 19:30:16 +02:00
|
|
|
_update_file_display_toggle_button();
|
2017-03-05 16:44:50 +01:00
|
|
|
button_display_mode->connect("pressed", this, "_change_file_display");
|
2017-09-03 22:35:18 +02:00
|
|
|
//file_options->set_icon( get_icon("Tools","ei"));
|
2017-03-05 16:44:50 +01:00
|
|
|
files->connect("item_activated", this, "_select_file");
|
|
|
|
button_hist_next->connect("pressed", this, "_fw_history");
|
|
|
|
button_hist_prev->connect("pressed", this, "_bw_history");
|
2017-09-03 22:35:18 +02:00
|
|
|
search_box->add_icon_override("right_icon", get_icon("Search", ei));
|
2017-03-05 16:44:50 +01:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
button_hist_next->set_icon(get_icon("Forward", ei));
|
|
|
|
button_hist_prev->set_icon(get_icon("Back", ei));
|
2017-03-05 16:44:50 +01:00
|
|
|
file_options->connect("id_pressed", this, "_file_option");
|
|
|
|
folder_options->connect("id_pressed", this, "_folder_option");
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
button_tree->connect("pressed", this, "_go_to_tree", varray(), CONNECT_DEFERRED);
|
|
|
|
current_path->connect("text_entered", this, "navigate_to_path");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-08-24 01:15:56 +02:00
|
|
|
if (EditorFileSystem::get_singleton()->is_scanning()) {
|
2017-01-21 13:07:29 +01:00
|
|
|
_set_scanning_mode();
|
2017-09-03 22:35:18 +02:00
|
|
|
} else {
|
2018-02-01 02:53:31 +01:00
|
|
|
_update_tree(false, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2015-08-24 01:15:56 +02:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_PROCESS: {
|
|
|
|
if (EditorFileSystem::get_singleton()->is_scanning()) {
|
2017-03-05 16:44:50 +01:00
|
|
|
scanning_progress->set_value(EditorFileSystem::get_singleton()->get_scanning_progress() * 100);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
} break;
|
2014-11-06 01:20:42 +01:00
|
|
|
case NOTIFICATION_EXIT_TREE: {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_DRAG_BEGIN: {
|
|
|
|
|
|
|
|
Dictionary dd = get_viewport()->gui_get_drag_data();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (tree->is_visible_in_tree() && dd.has("type")) {
|
|
|
|
if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
|
2016-05-24 04:24:17 +02:00
|
|
|
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
|
2017-09-03 22:35:18 +02:00
|
|
|
} else if ((String(dd["type"]) == "favorite")) {
|
2016-05-24 04:24:17 +02:00
|
|
|
tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
|
|
|
|
}
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
2016-05-24 04:24:17 +02:00
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_DRAG_END: {
|
|
|
|
|
|
|
|
tree->set_drop_mode_flags(0);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
} break;
|
2015-12-15 17:39:13 +01:00
|
|
|
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
String ei = "EditorIcons";
|
2017-01-05 23:41:36 +01:00
|
|
|
int new_mode = int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode"));
|
2015-12-15 17:39:13 +01:00
|
|
|
|
2017-08-30 01:03:13 +02:00
|
|
|
//_update_icons
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
button_reload->set_icon(get_icon("Reload", ei));
|
|
|
|
button_favorite->set_icon(get_icon("Favorites", ei));
|
|
|
|
button_tree->set_icon(get_icon("Filesystem", ei));
|
|
|
|
button_hist_next->set_icon(get_icon("Forward", ei));
|
|
|
|
button_hist_prev->set_icon(get_icon("Back", ei));
|
2017-08-30 01:03:13 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
search_box->add_icon_override("right_icon", get_icon("Search", ei));
|
2017-08-30 01:03:13 +02:00
|
|
|
|
2016-08-16 18:25:42 +02:00
|
|
|
if (new_mode != display_mode) {
|
|
|
|
set_display_mode(new_mode);
|
|
|
|
} else {
|
2017-09-03 22:35:18 +02:00
|
|
|
_update_file_display_toggle_button();
|
2016-08-16 18:25:42 +02:00
|
|
|
_update_files(true);
|
|
|
|
}
|
2017-08-30 01:03:13 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
_update_tree(true);
|
2015-12-15 17:39:13 +01:00
|
|
|
} break;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_dir_selected() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
TreeItem *sel = tree->get_selected();
|
|
|
|
if (!sel)
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
2017-09-03 22:35:18 +02:00
|
|
|
path = sel->get_metadata(0);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool found = false;
|
2015-08-24 01:15:56 +02:00
|
|
|
Vector<String> favorites = EditorSettings::get_singleton()->get_favorite_dirs();
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < favorites.size(); i++) {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (favorites[i] == path) {
|
2017-03-05 16:44:50 +01:00
|
|
|
found = true;
|
2015-08-24 01:15:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
button_favorite->set_pressed(found);
|
2017-09-03 22:35:18 +02:00
|
|
|
current_path->set_text(path);
|
|
|
|
_push_to_history();
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (!low_height_mode) {
|
|
|
|
_update_files(false);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_favorites_pressed() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
|
|
|
TreeItem *sel = tree->get_selected();
|
|
|
|
if (!sel)
|
2017-03-05 16:44:50 +01:00
|
|
|
return;
|
2017-09-03 22:35:18 +02:00
|
|
|
path = sel->get_metadata(0);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
|
|
|
int idx = -1;
|
|
|
|
Vector<String> favorites = EditorSettings::get_singleton()->get_favorite_dirs();
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < favorites.size(); i++) {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (favorites[i] == path) {
|
2017-03-05 16:44:50 +01:00
|
|
|
idx = i;
|
2015-08-24 01:15:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (idx == -1) {
|
|
|
|
favorites.push_back(path);
|
|
|
|
} else {
|
2015-08-24 01:15:56 +02:00
|
|
|
favorites.remove(idx);
|
|
|
|
}
|
2017-09-03 22:35:18 +02:00
|
|
|
EditorSettings::get_singleton()->set_favorite_dirs(favorites);
|
|
|
|
_update_tree(true);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
String FileSystemDock::get_selected_path() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *sel = tree->get_selected();
|
|
|
|
if (!sel)
|
|
|
|
return "";
|
2017-09-03 22:35:18 +02:00
|
|
|
|
|
|
|
return sel->get_metadata(0);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
String FileSystemDock::get_current_path() const {
|
2016-05-27 19:18:40 +02:00
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::navigate_to_path(const String &p_path) {
|
2017-01-14 18:14:46 +01:00
|
|
|
// If the path is a file, do not only go to the directory in the tree, also select the file in the file list.
|
2017-03-05 16:44:50 +01:00
|
|
|
String file_name = "";
|
|
|
|
DirAccess *dirAccess = DirAccess::open("res://");
|
2017-01-14 18:14:46 +01:00
|
|
|
if (dirAccess->file_exists(p_path)) {
|
2017-09-03 22:35:18 +02:00
|
|
|
path = p_path.get_base_dir();
|
2017-03-05 16:44:50 +01:00
|
|
|
file_name = p_path.get_file();
|
2017-01-14 18:14:46 +01:00
|
|
|
} else if (dirAccess->dir_exists(p_path)) {
|
2017-09-03 22:35:18 +02:00
|
|
|
path = p_path;
|
2017-01-14 18:14:46 +01:00
|
|
|
} else {
|
2017-11-13 12:16:03 +01:00
|
|
|
ERR_EXPLAIN(vformat(TTR("Cannot navigate to '%s' as it has not been found in the file system!"), p_path));
|
2017-01-14 18:14:46 +01:00
|
|
|
ERR_FAIL();
|
|
|
|
}
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
current_path->set_text(path);
|
|
|
|
_push_to_history();
|
2017-01-14 18:14:46 +01:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (!low_height_mode) {
|
|
|
|
_update_tree(true);
|
|
|
|
_update_files(false);
|
|
|
|
} else {
|
2017-12-21 20:16:04 +01:00
|
|
|
_go_to_file_list();
|
2017-09-03 22:35:18 +02:00
|
|
|
}
|
2017-01-14 18:14:46 +01:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (!file_name.empty()) {
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2017-01-14 18:14:46 +01:00
|
|
|
if (files->get_item_text(i) == file_name) {
|
2017-03-05 16:44:50 +01:00
|
|
|
files->select(i, true);
|
2017-01-14 18:14:46 +01:00
|
|
|
files->ensure_current_is_visible();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata) {
|
2015-09-08 03:55:47 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if ((file_list_vb->is_visible_in_tree() || path == p_path.get_base_dir()) && p_preview.is_valid()) {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Array uarr = p_udata;
|
|
|
|
int idx = uarr[0];
|
|
|
|
String file = uarr[1];
|
2017-09-03 22:35:18 +02:00
|
|
|
if (idx < files->get_item_count() && files->get_item_text(idx) == file && files->get_item_metadata(idx) == p_path)
|
|
|
|
files->set_item_icon(idx, p_preview);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-12 19:30:16 +02:00
|
|
|
void FileSystemDock::_update_file_display_toggle_button() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2016-08-16 18:25:42 +02:00
|
|
|
if (button_display_mode->is_pressed()) {
|
|
|
|
display_mode = DISPLAY_LIST;
|
2017-03-05 16:44:50 +01:00
|
|
|
button_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons"));
|
2017-09-12 19:30:16 +02:00
|
|
|
button_display_mode->set_tooltip(TTR("View items as a grid of thumbnails"));
|
2015-08-24 01:15:56 +02:00
|
|
|
} else {
|
2016-08-16 18:25:42 +02:00
|
|
|
display_mode = DISPLAY_THUMBNAILS;
|
2017-03-05 16:44:50 +01:00
|
|
|
button_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
|
2017-09-12 19:30:16 +02:00
|
|
|
button_display_mode->set_tooltip(TTR("View items as a list"));
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
2017-09-12 19:30:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FileSystemDock::_change_file_display() {
|
|
|
|
|
|
|
|
_update_file_display_toggle_button();
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-01-05 23:41:36 +01:00
|
|
|
EditorSettings::get_singleton()->set("docks/filesystem/display_mode", display_mode);
|
2016-08-16 18:25:42 +02:00
|
|
|
|
2015-08-24 01:15:56 +02:00
|
|
|
_update_files(true);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> *matches, int p_max_items) {
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (matches->size() > p_max_items)
|
2016-05-16 01:25:51 +02:00
|
|
|
return;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < p_path->get_subdir_count(); i++) {
|
|
|
|
_search(p_path->get_subdir(i), matches, p_max_items);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
|
|
|
|
2017-12-27 16:49:19 +01:00
|
|
|
String match = search_box->get_text().to_lower();
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < p_path->get_file_count(); i++) {
|
2016-05-16 01:25:51 +02:00
|
|
|
String file = p_path->get_file(i);
|
|
|
|
|
2017-12-27 16:49:19 +01:00
|
|
|
if (file.to_lower().find(match) != -1) {
|
2016-05-16 01:25:51 +02:00
|
|
|
|
|
|
|
FileInfo fi;
|
2017-03-05 16:44:50 +01:00
|
|
|
fi.name = file;
|
|
|
|
fi.type = p_path->get_file_type(i);
|
|
|
|
fi.path = p_path->get_file_path(i);
|
2017-08-30 01:17:34 +02:00
|
|
|
fi.import_broken = !p_path->get_file_import_is_valid(i);
|
2017-03-05 16:44:50 +01:00
|
|
|
fi.import_status = 0;
|
2016-05-27 19:18:40 +02:00
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
matches->push_back(fi);
|
2017-03-05 16:44:50 +01:00
|
|
|
if (matches->size() > p_max_items)
|
2016-05-16 01:25:51 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_update_files(bool p_keep_selection) {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
|
|
|
Set<String> cselection;
|
|
|
|
|
|
|
|
if (p_keep_selection) {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
|
|
|
if (files->is_selected(i))
|
|
|
|
cselection.insert(files->get_item_text(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
files->clear();
|
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
current_path->set_text(path);
|
|
|
|
|
2017-01-14 15:07:57 +01:00
|
|
|
EditorFileSystemDirectory *efd = EditorFileSystem::get_singleton()->get_filesystem_path(path);
|
2015-08-24 01:15:56 +02:00
|
|
|
if (!efd)
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
String ei = "EditorIcons";
|
2017-01-05 23:41:36 +01:00
|
|
|
int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size");
|
2017-03-05 16:44:50 +01:00
|
|
|
thumbnail_size *= EDSCALE;
|
2015-08-24 01:15:56 +02:00
|
|
|
Ref<Texture> folder_thumbnail;
|
|
|
|
Ref<Texture> file_thumbnail;
|
2017-08-30 01:17:34 +02:00
|
|
|
Ref<Texture> file_thumbnail_broken;
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-12 19:23:16 +02:00
|
|
|
bool always_show_folders = EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders");
|
|
|
|
|
2016-08-16 18:25:42 +02:00
|
|
|
bool use_thumbnails = (display_mode == DISPLAY_THUMBNAILS);
|
2017-09-03 22:35:18 +02:00
|
|
|
bool use_folders = search_box->get_text().length() == 0 && (low_height_mode || always_show_folders);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (use_thumbnails) {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
|
|
|
files->set_max_columns(0);
|
|
|
|
files->set_icon_mode(ItemList::ICON_MODE_TOP);
|
2017-03-05 16:44:50 +01:00
|
|
|
files->set_fixed_column_width(thumbnail_size * 3 / 2);
|
2015-08-24 01:15:56 +02:00
|
|
|
files->set_max_text_lines(2);
|
2017-03-05 16:44:50 +01:00
|
|
|
files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-08 09:32:43 +02:00
|
|
|
if (thumbnail_size < 64) {
|
2017-09-03 22:35:18 +02:00
|
|
|
folder_thumbnail = get_icon("FolderMediumThumb", ei);
|
|
|
|
file_thumbnail = get_icon("FileMediumThumb", ei);
|
|
|
|
file_thumbnail_broken = get_icon("FileDeadMediumThumb", ei);
|
2017-09-08 09:32:43 +02:00
|
|
|
} else {
|
2017-09-03 22:35:18 +02:00
|
|
|
folder_thumbnail = get_icon("FolderBigThumb", ei);
|
|
|
|
file_thumbnail = get_icon("FileBigThumb", ei);
|
|
|
|
file_thumbnail_broken = get_icon("FileDeadBigThumb", ei);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
files->set_icon_mode(ItemList::ICON_MODE_LEFT);
|
|
|
|
files->set_max_columns(1);
|
|
|
|
files->set_max_text_lines(1);
|
|
|
|
files->set_fixed_column_width(0);
|
2016-06-12 21:51:27 +02:00
|
|
|
files->set_fixed_icon_size(Size2());
|
2014-10-15 00:44:41 +02:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
if (use_folders) {
|
2017-09-03 22:35:18 +02:00
|
|
|
Ref<Texture> folderIcon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (path != "res://") {
|
2018-02-01 16:54:07 +01:00
|
|
|
files->add_item("..", folderIcon, true);
|
2016-05-16 01:25:51 +02:00
|
|
|
|
|
|
|
String bd = path.get_base_dir();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (bd != "res://" && !bd.ends_with("/"))
|
|
|
|
bd += "/";
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
files->set_item_metadata(files->get_item_count() - 1, bd);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < efd->get_subdir_count(); i++) {
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String dname = efd->get_subdir(i)->get_name();
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
files->add_item(dname, folderIcon, true);
|
2017-03-05 16:44:50 +01:00
|
|
|
files->set_item_metadata(files->get_item_count() - 1, path.plus_file(dname) + "/");
|
2016-05-16 01:25:51 +02:00
|
|
|
|
|
|
|
if (cselection.has(dname))
|
2017-03-05 16:44:50 +01:00
|
|
|
files->select(files->get_item_count() - 1, false);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
List<FileInfo> filelist;
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (search_box->get_text().length() > 0) {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
_search(EditorFileSystem::get_singleton()->get_filesystem(), &filelist, 128);
|
2016-05-16 01:25:51 +02:00
|
|
|
filelist.sort();
|
|
|
|
} else {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < efd->get_file_count(); i++) {
|
2016-05-16 01:25:51 +02:00
|
|
|
|
|
|
|
FileInfo fi;
|
2017-03-05 16:44:50 +01:00
|
|
|
fi.name = efd->get_file(i);
|
|
|
|
fi.path = path.plus_file(fi.name);
|
|
|
|
fi.type = efd->get_file_type(i);
|
2017-08-30 01:17:34 +02:00
|
|
|
fi.import_broken = !efd->get_file_import_is_valid(i);
|
2017-03-05 16:44:50 +01:00
|
|
|
fi.import_status = 0;
|
2016-05-16 01:25:51 +02:00
|
|
|
|
|
|
|
filelist.push_back(fi);
|
|
|
|
}
|
2018-04-08 12:18:01 +02:00
|
|
|
filelist.sort();
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
String oi = "Object";
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<FileInfo>::Element *E = filelist.front(); E; E = E->next()) {
|
2017-09-03 22:35:18 +02:00
|
|
|
FileInfo *finfo = &(E->get());
|
|
|
|
String fname = finfo->name;
|
|
|
|
String fpath = finfo->path;
|
|
|
|
String ftype = finfo->type;
|
2015-08-24 01:15:56 +02:00
|
|
|
|
|
|
|
Ref<Texture> type_icon;
|
2017-09-03 22:35:18 +02:00
|
|
|
Ref<Texture> big_icon;
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String tooltip = fname;
|
2016-05-27 19:18:40 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (!finfo->import_broken) {
|
|
|
|
type_icon = (has_icon(ftype, ei)) ? get_icon(ftype, ei) : get_icon(oi, ei);
|
|
|
|
big_icon = file_thumbnail;
|
2017-08-30 01:17:34 +02:00
|
|
|
} else {
|
2017-09-03 22:35:18 +02:00
|
|
|
type_icon = get_icon("ImportFail", ei);
|
2017-08-30 01:17:34 +02:00
|
|
|
big_icon = file_thumbnail_broken;
|
2018-01-06 14:32:21 +01:00
|
|
|
tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually.");
|
2016-05-27 19:18:40 +02:00
|
|
|
}
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
int item_index;
|
2015-08-24 01:15:56 +02:00
|
|
|
if (use_thumbnails) {
|
2017-08-30 01:17:34 +02:00
|
|
|
files->add_item(fname, big_icon, true);
|
2017-09-03 22:35:18 +02:00
|
|
|
item_index = files->get_item_count() - 1;
|
|
|
|
files->set_item_metadata(item_index, fpath);
|
|
|
|
files->set_item_tag_icon(item_index, type_icon);
|
|
|
|
if (!finfo->import_broken) {
|
|
|
|
Array udata;
|
|
|
|
udata.resize(2);
|
|
|
|
udata[0] = item_index;
|
|
|
|
udata[1] = fname;
|
|
|
|
EditorResourcePreview::get_singleton()->queue_resource_preview(fpath, this, "_thumbnail_done", udata);
|
2017-08-30 01:17:34 +02:00
|
|
|
}
|
2015-08-24 01:15:56 +02:00
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
files->add_item(fname, type_icon, true);
|
2017-09-03 22:35:18 +02:00
|
|
|
item_index = files->get_item_count() - 1;
|
|
|
|
files->set_item_metadata(item_index, fpath);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cselection.has(fname))
|
2017-09-03 22:35:18 +02:00
|
|
|
files->select(item_index, false);
|
2016-05-27 19:18:40 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (finfo->sources.size()) {
|
|
|
|
for (int j = 0; j < finfo->sources.size(); j++) {
|
|
|
|
tooltip += "\nSource: " + finfo->sources[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
files->set_item_tooltip(item_index, tooltip);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_select_file(int p_idx) {
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(p_idx);
|
|
|
|
if (fpath.ends_with("/")) {
|
|
|
|
if (fpath != "res://") {
|
|
|
|
fpath = fpath.substr(0, fpath.length() - 1);
|
2017-10-09 15:59:48 +02:00
|
|
|
}
|
2017-12-16 15:53:44 +01:00
|
|
|
navigate_to_path(fpath);
|
2017-10-09 15:59:48 +02:00
|
|
|
} else {
|
2017-11-01 12:31:13 +01:00
|
|
|
if (ResourceLoader::get_resource_type(fpath) == "PackedScene") {
|
|
|
|
editor->open_request(fpath);
|
2017-10-09 15:59:48 +02:00
|
|
|
} else {
|
2017-11-01 12:31:13 +01:00
|
|
|
editor->load_resource(fpath);
|
2017-10-09 15:59:48 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_go_to_tree() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (low_height_mode) {
|
|
|
|
tree->show();
|
|
|
|
button_favorite->show();
|
|
|
|
file_list_vb->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
_update_tree(true);
|
2015-08-24 01:15:56 +02:00
|
|
|
tree->grab_focus();
|
|
|
|
tree->ensure_cursor_is_visible();
|
2016-05-16 01:25:51 +02:00
|
|
|
//button_open->hide();
|
|
|
|
//file_options->hide();
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::_preview_invalidated(const String &p_path) {
|
2016-07-03 18:15:15 +02:00
|
|
|
|
2017-08-03 18:55:48 +02:00
|
|
|
if (display_mode == DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) {
|
2016-07-03 18:15:15 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-07-03 18:15:15 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (files->get_item_metadata(i) == p_path) {
|
2016-07-03 18:15:15 +02:00
|
|
|
//re-request preview
|
|
|
|
Array udata;
|
|
|
|
udata.resize(2);
|
2017-03-05 16:44:50 +01:00
|
|
|
udata[0] = i;
|
|
|
|
udata[1] = files->get_item_text(i);
|
|
|
|
EditorResourcePreview::get_singleton()->queue_resource_preview(p_path, this, "_thumbnail_done", udata);
|
2016-07-03 18:15:15 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_fs_changed() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
button_hist_prev->set_disabled(history_pos == 0);
|
2017-09-03 22:35:18 +02:00
|
|
|
button_hist_next->set_disabled(history_pos == history.size() - 1);
|
2015-08-24 01:15:56 +02:00
|
|
|
scanning_vb->hide();
|
2016-05-16 01:25:51 +02:00
|
|
|
split_box->show();
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-01-13 14:45:50 +01:00
|
|
|
if (tree->is_visible()) {
|
2017-09-03 22:35:18 +02:00
|
|
|
_update_tree(true);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
|
|
|
|
2017-01-13 14:45:50 +01:00
|
|
|
if (file_list_vb->is_visible()) {
|
2015-08-24 01:15:56 +02:00
|
|
|
_update_files(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
set_process(false);
|
|
|
|
}
|
|
|
|
|
2017-01-21 13:07:29 +01:00
|
|
|
void FileSystemDock::_set_scanning_mode() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
|
|
|
button_hist_prev->set_disabled(true);
|
|
|
|
button_hist_next->set_disabled(true);
|
2017-09-03 22:35:18 +02:00
|
|
|
split_box->hide();
|
2015-08-24 01:15:56 +02:00
|
|
|
scanning_vb->show();
|
|
|
|
set_process(true);
|
|
|
|
if (EditorFileSystem::get_singleton()->is_scanning()) {
|
2017-03-05 16:44:50 +01:00
|
|
|
scanning_progress->set_value(EditorFileSystem::get_singleton()->get_scanning_progress() * 100);
|
2015-08-24 01:15:56 +02:00
|
|
|
} else {
|
2017-01-04 05:16:14 +01:00
|
|
|
scanning_progress->set_value(0);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_fw_history() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (history_pos < history.size() - 1)
|
2015-08-24 01:15:56 +02:00
|
|
|
history_pos++;
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
_update_history();
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_bw_history() {
|
2017-03-05 16:44:50 +01:00
|
|
|
if (history_pos > 0)
|
2015-08-24 01:15:56 +02:00
|
|
|
history_pos--;
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
_update_history();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileSystemDock::_update_history() {
|
2017-03-05 16:44:50 +01:00
|
|
|
path = history[history_pos];
|
2017-09-03 22:35:18 +02:00
|
|
|
current_path->set_text(path);
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-01-13 14:45:50 +01:00
|
|
|
if (tree->is_visible()) {
|
2017-09-03 22:35:18 +02:00
|
|
|
_update_tree(true);
|
2015-08-24 01:15:56 +02:00
|
|
|
tree->grab_focus();
|
|
|
|
tree->ensure_cursor_is_visible();
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
|
|
|
|
2017-01-13 14:45:50 +01:00
|
|
|
if (file_list_vb->is_visible()) {
|
2015-08-24 01:15:56 +02:00
|
|
|
_update_files(false);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
button_hist_prev->set_disabled(history_pos == 0);
|
2017-09-03 22:35:18 +02:00
|
|
|
button_hist_next->set_disabled(history_pos == history.size() - 1);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_push_to_history() {
|
2017-03-05 16:44:50 +01:00
|
|
|
if (history[history_pos] != path) {
|
2017-09-03 22:35:18 +02:00
|
|
|
history.resize(history_pos + 1);
|
2015-08-24 01:15:56 +02:00
|
|
|
history.push_back(path);
|
|
|
|
history_pos++;
|
2017-09-03 22:35:18 +02:00
|
|
|
|
|
|
|
if (history.size() > history_max_size) {
|
|
|
|
history.remove(0);
|
|
|
|
history_pos = history_max_size - 1;
|
|
|
|
}
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
button_hist_prev->set_disabled(history_pos == 0);
|
2017-09-03 22:35:18 +02:00
|
|
|
button_hist_next->set_disabled(history_pos == history.size() - 1);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2018-03-01 00:14:12 +01:00
|
|
|
void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const {
|
2017-10-01 23:59:27 +02:00
|
|
|
if (efsd == NULL)
|
|
|
|
return;
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < efsd->get_subdir_count(); i++) {
|
2018-03-01 00:14:12 +01:00
|
|
|
folders.push_back(efsd->get_subdir(i)->get_path());
|
|
|
|
_get_all_items_in_dir(efsd->get_subdir(i), files, folders);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < efsd->get_file_count(); i++) {
|
2015-08-24 01:15:56 +02:00
|
|
|
files.push_back(efsd->get_file_path(i));
|
|
|
|
}
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const Map<String, String> &renames, Vector<String> &to_remaps) const {
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < efsd->get_subdir_count(); i++) {
|
|
|
|
_find_remaps(efsd->get_subdir(i), renames, to_remaps);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < efsd->get_file_count(); i++) {
|
|
|
|
Vector<String> deps = efsd->get_file_deps(i);
|
|
|
|
for (int j = 0; j < deps.size(); j++) {
|
2015-08-24 01:15:56 +02:00
|
|
|
if (renames.has(deps[j])) {
|
|
|
|
to_remaps.push_back(efsd->get_file_path(i));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-01 00:14:12 +01:00
|
|
|
void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_new_path,
|
|
|
|
Map<String, String> &p_file_renames, Map<String, String> &p_folder_renames) const {
|
2017-10-01 23:59:27 +02:00
|
|
|
//Ensure folder paths end with "/"
|
|
|
|
String old_path = (p_item.is_file || p_item.path.ends_with("/")) ? p_item.path : (p_item.path + "/");
|
|
|
|
String new_path = (p_item.is_file || p_new_path.ends_with("/")) ? p_new_path : (p_new_path + "/");
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
if (new_path == old_path) {
|
2015-08-24 01:15:56 +02:00
|
|
|
return;
|
2017-10-01 23:59:27 +02:00
|
|
|
} else if (old_path == "res://") {
|
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Cannot move/rename resources root."));
|
|
|
|
return;
|
|
|
|
} else if (!p_item.is_file && new_path.begins_with(old_path)) {
|
|
|
|
//This check doesn't erroneously catch renaming to a longer name as folder paths always end with "/"
|
2018-01-04 20:00:39 +01:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Cannot move a folder into itself.") + "\n" + old_path + "\n");
|
2015-08-24 01:15:56 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
//Build a list of files which will have new paths as a result of this operation
|
2018-03-01 00:14:12 +01:00
|
|
|
Vector<String> file_changed_paths;
|
|
|
|
Vector<String> folder_changed_paths;
|
2017-10-01 23:59:27 +02:00
|
|
|
if (p_item.is_file) {
|
2018-03-01 00:14:12 +01:00
|
|
|
file_changed_paths.push_back(old_path);
|
2017-10-01 23:59:27 +02:00
|
|
|
} else {
|
2018-03-01 00:14:12 +01:00
|
|
|
folder_changed_paths.push_back(old_path);
|
|
|
|
_get_all_items_in_dir(EditorFileSystem::get_singleton()->get_filesystem_path(old_path), file_changed_paths, folder_changed_paths);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
2017-10-01 23:59:27 +02:00
|
|
|
print_line("Moving " + old_path + " -> " + new_path);
|
|
|
|
Error err = da->rename(old_path, new_path);
|
|
|
|
if (err == OK) {
|
|
|
|
//Move/Rename any corresponding import settings too
|
|
|
|
if (p_item.is_file && FileAccess::exists(old_path + ".import")) {
|
|
|
|
err = da->rename(old_path + ".import", new_path + ".import");
|
|
|
|
if (err != OK) {
|
2018-01-04 20:00:39 +01:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Error moving:") + "\n" + old_path + ".import\n");
|
2017-10-01 23:59:27 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-11-29 01:48:09 +01:00
|
|
|
// update scene if it is open
|
2018-03-01 00:14:12 +01:00
|
|
|
for (int i = 0; i < file_changed_paths.size(); ++i) {
|
|
|
|
String new_item_path = p_item.is_file ? new_path : file_changed_paths[i].replace_first(old_path, new_path);
|
|
|
|
if (ResourceLoader::get_resource_type(new_item_path) == "PackedScene" && editor->is_scene_open(file_changed_paths[i])) {
|
2017-11-29 01:48:09 +01:00
|
|
|
EditorData *ed = &editor->get_editor_data();
|
|
|
|
for (int j = 0; j < ed->get_edited_scene_count(); j++) {
|
2018-03-01 00:14:12 +01:00
|
|
|
if (ed->get_scene_path(j) == file_changed_paths[i]) {
|
2017-11-29 01:48:09 +01:00
|
|
|
ed->get_edited_scene_root(j)->set_filename(new_item_path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
//Only treat as a changed dependency if it was successfully moved
|
2018-03-01 00:14:12 +01:00
|
|
|
for (int i = 0; i < file_changed_paths.size(); ++i) {
|
|
|
|
p_file_renames[file_changed_paths[i]] = file_changed_paths[i].replace_first(old_path, new_path);
|
|
|
|
print_line(" Remap: " + file_changed_paths[i] + " -> " + p_file_renames[file_changed_paths[i]]);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < folder_changed_paths.size(); ++i) {
|
|
|
|
p_folder_renames[folder_changed_paths[i]] = folder_changed_paths[i].replace_first(old_path, new_path);
|
2017-10-01 23:59:27 +02:00
|
|
|
}
|
|
|
|
} else {
|
2018-01-04 20:00:39 +01:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Error moving:") + "\n" + old_path + "\n");
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
memdelete(da);
|
|
|
|
}
|
|
|
|
|
2017-12-01 12:13:50 +01:00
|
|
|
void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const {
|
|
|
|
//Ensure folder paths end with "/"
|
|
|
|
String old_path = (p_item.is_file || p_item.path.ends_with("/")) ? p_item.path : (p_item.path + "/");
|
|
|
|
String new_path = (p_item.is_file || p_new_path.ends_with("/")) ? p_new_path : (p_new_path + "/");
|
|
|
|
|
|
|
|
if (new_path == old_path) {
|
|
|
|
return;
|
|
|
|
} else if (old_path == "res://") {
|
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Cannot move/rename resources root."));
|
|
|
|
return;
|
|
|
|
} else if (!p_item.is_file && new_path.begins_with(old_path)) {
|
|
|
|
//This check doesn't erroneously catch renaming to a longer name as folder paths always end with "/"
|
2018-01-04 20:00:39 +01:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Cannot move a folder into itself.") + "\n" + old_path + "\n");
|
2017-12-01 12:13:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
|
|
|
print_line("Duplicating " + old_path + " -> " + new_path);
|
2017-12-31 18:10:03 +01:00
|
|
|
Error err = p_item.is_file ? da->copy(old_path, new_path) : da->copy_dir(old_path, new_path);
|
2017-12-01 12:13:50 +01:00
|
|
|
if (err == OK) {
|
|
|
|
//Move/Rename any corresponding import settings too
|
|
|
|
if (p_item.is_file && FileAccess::exists(old_path + ".import")) {
|
|
|
|
err = da->copy(old_path + ".import", new_path + ".import");
|
|
|
|
if (err != OK) {
|
2018-01-04 20:00:39 +01:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + ".import\n");
|
2017-12-01 12:13:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2018-01-04 20:00:39 +01:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + "\n");
|
2017-12-01 12:13:50 +01:00
|
|
|
}
|
|
|
|
memdelete(da);
|
|
|
|
}
|
|
|
|
|
2017-12-26 20:32:12 +01:00
|
|
|
void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> &p_renames) const {
|
|
|
|
|
|
|
|
//Rename all resources loaded, be it subresources or actual resources
|
|
|
|
List<Ref<Resource> > cached;
|
|
|
|
ResourceCache::get_cached_resources(&cached);
|
|
|
|
|
|
|
|
for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) {
|
|
|
|
|
|
|
|
Ref<Resource> r = E->get();
|
|
|
|
|
|
|
|
String base_path = r->get_path();
|
|
|
|
String extra_path;
|
|
|
|
int sep_pos = r->get_path().find("::");
|
|
|
|
if (sep_pos >= 0) {
|
|
|
|
extra_path = base_path.substr(sep_pos, base_path.length());
|
|
|
|
base_path = base_path.substr(0, sep_pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_renames.has(base_path)) {
|
|
|
|
base_path = p_renames[base_path];
|
|
|
|
}
|
|
|
|
|
|
|
|
r->set_path(base_path + extra_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < EditorNode::get_editor_data().get_edited_scene_count(); i++) {
|
|
|
|
|
|
|
|
String path;
|
|
|
|
if (i == EditorNode::get_editor_data().get_edited_scene()) {
|
|
|
|
if (!get_tree()->get_edited_scene_root())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
path = get_tree()->get_edited_scene_root()->get_filename();
|
|
|
|
} else {
|
|
|
|
|
|
|
|
path = EditorNode::get_editor_data().get_scene_path(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_renames.has(path)) {
|
|
|
|
path = p_renames[path];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == EditorNode::get_editor_data().get_edited_scene()) {
|
|
|
|
|
|
|
|
get_tree()->get_edited_scene_root()->set_filename(path);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
EditorNode::get_editor_data().set_scene_path(i, path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
void FileSystemDock::_update_dependencies_after_move(const Map<String, String> &p_renames) const {
|
|
|
|
//The following code assumes that the following holds:
|
|
|
|
// 1) EditorFileSystem contains the old paths/folder structure from before the rename/move.
|
|
|
|
// 2) ResourceLoader can use the new paths without needing to call rescan.
|
|
|
|
Vector<String> remaps;
|
|
|
|
_find_remaps(EditorFileSystem::get_singleton()->get_filesystem(), p_renames, remaps);
|
|
|
|
for (int i = 0; i < remaps.size(); ++i) {
|
|
|
|
//Because we haven't called a rescan yet the found remap might still be an old path itself.
|
|
|
|
String file = p_renames.has(remaps[i]) ? p_renames[remaps[i]] : remaps[i];
|
|
|
|
print_line("Remapping dependencies for: " + file);
|
|
|
|
Error err = ResourceLoader::rename_dependencies(file, p_renames);
|
2017-11-29 01:48:09 +01:00
|
|
|
if (err == OK) {
|
|
|
|
if (ResourceLoader::get_resource_type(file) == "PackedScene")
|
|
|
|
editor->reload_scene(file);
|
|
|
|
} else {
|
2018-01-04 20:00:39 +01:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Unable to update dependencies:") + "\n" + remaps[i] + "\n");
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
2017-09-03 05:22:54 +02:00
|
|
|
}
|
2017-10-01 23:59:27 +02:00
|
|
|
}
|
2017-09-03 05:22:54 +02:00
|
|
|
|
2018-03-01 00:14:12 +01:00
|
|
|
void FileSystemDock::_update_favorite_dirs_list_after_move(const Map<String, String> &p_renames) const {
|
|
|
|
|
|
|
|
Vector<String> favorite_dirs = EditorSettings::get_singleton()->get_favorite_dirs();
|
|
|
|
Vector<String> new_favorite_dirs;
|
|
|
|
|
|
|
|
for (int i = 0; i < favorite_dirs.size(); i++) {
|
|
|
|
String old_path = favorite_dirs[i] + "/";
|
|
|
|
|
|
|
|
if (p_renames.has(old_path)) {
|
|
|
|
String new_path = p_renames[old_path];
|
|
|
|
new_favorite_dirs.push_back(new_path.substr(0, new_path.length() - 1));
|
|
|
|
} else {
|
|
|
|
new_favorite_dirs.push_back(favorite_dirs[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorSettings::get_singleton()->set_favorite_dirs(new_favorite_dirs);
|
|
|
|
}
|
|
|
|
|
2017-10-02 00:33:43 +02:00
|
|
|
void FileSystemDock::_make_dir_confirm() {
|
|
|
|
String dir_name = make_dir_dialog_text->get_text().strip_edges();
|
|
|
|
|
|
|
|
if (dir_name.length() == 0) {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("No name provided"));
|
|
|
|
return;
|
2018-05-01 21:07:41 +02:00
|
|
|
} else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1 || dir_name.ends_with(".") || dir_name.ends_with(" ")) {
|
2017-10-02 00:33:43 +02:00
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Provided name contains invalid characters"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_line("Making folder " + dir_name + " in " + path);
|
|
|
|
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
|
|
|
Error err = da->change_dir(path);
|
|
|
|
if (err == OK) {
|
|
|
|
err = da->make_dir(dir_name);
|
|
|
|
}
|
|
|
|
memdelete(da);
|
|
|
|
|
|
|
|
if (err == OK) {
|
|
|
|
print_line("call rescan!");
|
|
|
|
_rescan();
|
|
|
|
} else {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Could not create folder."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
void FileSystemDock::_rename_operation_confirm() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
String new_name = rename_dialog_text->get_text().strip_edges();
|
|
|
|
if (new_name.length() == 0) {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("No name provided."));
|
|
|
|
return;
|
|
|
|
} else if (new_name.find("/") != -1 || new_name.find("\\") != -1 || new_name.find(":") != -1) {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Name contains invalid characters."));
|
|
|
|
return;
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
String old_path = to_rename.path.ends_with("/") ? to_rename.path.substr(0, to_rename.path.length() - 1) : to_rename.path;
|
|
|
|
String new_path = old_path.get_base_dir().plus_file(new_name);
|
|
|
|
if (old_path == new_path) {
|
|
|
|
return;
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
//Present a more user friendly warning for name conflict
|
2017-03-05 16:44:50 +01:00
|
|
|
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
2018-01-22 03:04:16 +01:00
|
|
|
#if defined(WINDOWS_ENABLED) || defined(UWP_ENABLED)
|
|
|
|
// Workaround case insensitivity on Windows
|
|
|
|
if ((da->file_exists(new_path) || da->dir_exists(new_path)) && new_path.to_lower() != old_path.to_lower()) {
|
|
|
|
#else
|
2017-10-01 23:59:27 +02:00
|
|
|
if (da->file_exists(new_path) || da->dir_exists(new_path)) {
|
2018-01-22 03:04:16 +01:00
|
|
|
#endif
|
2017-10-01 23:59:27 +02:00
|
|
|
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
|
|
|
|
memdelete(da);
|
|
|
|
return;
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
2017-10-01 23:59:27 +02:00
|
|
|
memdelete(da);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2018-03-01 00:14:12 +01:00
|
|
|
Map<String, String> file_renames;
|
|
|
|
Map<String, String> folder_renames;
|
|
|
|
_try_move_item(to_rename, new_path, file_renames, folder_renames);
|
|
|
|
_update_dependencies_after_move(file_renames);
|
|
|
|
_update_resource_paths_after_move(file_renames);
|
|
|
|
_update_favorite_dirs_list_after_move(folder_renames);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
//Rescan everything
|
|
|
|
print_line("call rescan!");
|
|
|
|
_rescan();
|
|
|
|
}
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-12-01 12:13:50 +01:00
|
|
|
void FileSystemDock::_duplicate_operation_confirm() {
|
|
|
|
|
|
|
|
String new_name = duplicate_dialog_text->get_text().strip_edges();
|
|
|
|
if (new_name.length() == 0) {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("No name provided."));
|
|
|
|
return;
|
|
|
|
} else if (new_name.find("/") != -1 || new_name.find("\\") != -1 || new_name.find(":") != -1) {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Name contains invalid characters."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-31 18:10:03 +01:00
|
|
|
String new_path;
|
|
|
|
String base_dir = to_duplicate.path.get_base_dir();
|
|
|
|
if (to_duplicate.is_file) {
|
|
|
|
new_path = base_dir.plus_file(new_name);
|
|
|
|
} else {
|
|
|
|
new_path = base_dir.substr(0, base_dir.find_last("/")) + "/" + new_name;
|
2017-12-01 12:13:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Present a more user friendly warning for name conflict
|
|
|
|
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
|
|
|
if (da->file_exists(new_path) || da->dir_exists(new_path)) {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
|
|
|
|
memdelete(da);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memdelete(da);
|
|
|
|
|
2017-12-31 18:10:03 +01:00
|
|
|
_try_duplicate_item(to_duplicate, new_path);
|
2017-12-01 12:13:50 +01:00
|
|
|
|
|
|
|
//Rescan everything
|
|
|
|
print_line("call rescan!");
|
|
|
|
_rescan();
|
|
|
|
}
|
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
void FileSystemDock::_move_operation_confirm(const String &p_to_path) {
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2018-03-01 00:14:12 +01:00
|
|
|
Map<String, String> file_renames;
|
|
|
|
Map<String, String> folder_renames;
|
2017-10-01 23:59:27 +02:00
|
|
|
for (int i = 0; i < to_move.size(); i++) {
|
|
|
|
String old_path = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path;
|
|
|
|
String new_path = p_to_path.plus_file(old_path.get_file());
|
2018-03-01 00:14:12 +01:00
|
|
|
_try_move_item(to_move[i], new_path, file_renames, folder_renames);
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2018-03-01 00:14:12 +01:00
|
|
|
_update_dependencies_after_move(file_renames);
|
|
|
|
_update_resource_paths_after_move(file_renames);
|
|
|
|
_update_favorite_dirs_list_after_move(folder_renames);
|
2017-12-26 20:32:12 +01:00
|
|
|
|
2015-08-24 01:15:56 +02:00
|
|
|
print_line("call rescan!");
|
|
|
|
_rescan();
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_file_option(int p_option) {
|
2017-03-05 16:44:50 +01:00
|
|
|
switch (p_option) {
|
2017-10-09 15:59:48 +02:00
|
|
|
case FILE_SHOW_IN_EXPLORER: {
|
2018-03-28 11:34:46 +02:00
|
|
|
|
|
|
|
String path = this->path;
|
|
|
|
|
|
|
|
// first try to grab directory from selected file, so that it works for searched files
|
|
|
|
int idx = files->get_current();
|
|
|
|
|
|
|
|
if (idx >= 0 && idx < files->get_item_count()) {
|
|
|
|
path = files->get_item_metadata(idx);
|
|
|
|
path = path.get_base_dir();
|
|
|
|
}
|
|
|
|
|
|
|
|
path = ProjectSettings::get_singleton()->globalize_path(path);
|
|
|
|
OS::get_singleton()->shell_open(String("file://") + path);
|
2017-10-09 15:59:48 +02:00
|
|
|
} break;
|
2016-05-16 01:25:51 +02:00
|
|
|
case FILE_OPEN: {
|
2017-12-01 09:01:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
|
|
|
if (files->is_selected(i)) {
|
|
|
|
_select_file(i);
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 01:25:51 +02:00
|
|
|
} break;
|
|
|
|
case FILE_INSTANCE: {
|
|
|
|
|
2016-07-20 19:09:03 +02:00
|
|
|
Vector<String> paths;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-07-21 15:36:47 +02:00
|
|
|
if (!files->is_selected(i))
|
|
|
|
continue;
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(i);
|
|
|
|
if (EditorFileSystem::get_singleton()->get_file_type(fpath) == "PackedScene") {
|
|
|
|
paths.push_back(fpath);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-20 19:09:03 +02:00
|
|
|
|
|
|
|
if (!paths.empty()) {
|
|
|
|
emit_signal("instance", paths);
|
|
|
|
}
|
2016-05-16 01:25:51 +02:00
|
|
|
} break;
|
2015-08-24 01:15:56 +02:00
|
|
|
case FILE_DEPENDENCIES: {
|
|
|
|
|
|
|
|
int idx = files->get_current();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (idx < 0 || idx >= files->get_item_count())
|
2015-08-24 01:15:56 +02:00
|
|
|
break;
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(idx);
|
|
|
|
deps_editor->edit(fpath);
|
2015-08-24 01:15:56 +02:00
|
|
|
} break;
|
|
|
|
case FILE_OWNERS: {
|
|
|
|
|
|
|
|
int idx = files->get_current();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (idx < 0 || idx >= files->get_item_count())
|
2015-08-24 01:15:56 +02:00
|
|
|
break;
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(idx);
|
|
|
|
owners_editor->show(fpath);
|
2015-08-24 01:15:56 +02:00
|
|
|
} break;
|
|
|
|
case FILE_MOVE: {
|
2017-10-01 23:59:27 +02:00
|
|
|
to_move.clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2015-08-24 01:15:56 +02:00
|
|
|
if (!files->is_selected(i))
|
|
|
|
continue;
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(i);
|
|
|
|
to_move.push_back(FileOrFolder(fpath, !fpath.ends_with("/")));
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
2017-10-01 23:59:27 +02:00
|
|
|
if (to_move.size() > 0) {
|
2015-08-24 01:15:56 +02:00
|
|
|
move_dialog->popup_centered_ratio();
|
|
|
|
}
|
2017-10-01 23:59:27 +02:00
|
|
|
} break;
|
|
|
|
case FILE_RENAME: {
|
|
|
|
int idx = files->get_current();
|
|
|
|
if (idx < 0 || idx >= files->get_item_count())
|
|
|
|
break;
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
to_rename.path = files->get_item_metadata(idx);
|
|
|
|
to_rename.is_file = !to_rename.path.ends_with("/");
|
|
|
|
if (to_rename.is_file) {
|
|
|
|
String name = to_rename.path.get_file();
|
|
|
|
rename_dialog->set_title(TTR("Renaming file:") + " " + name);
|
|
|
|
rename_dialog_text->set_text(name);
|
|
|
|
rename_dialog_text->select(0, name.find_last("."));
|
|
|
|
} else {
|
|
|
|
String name = to_rename.path.substr(0, to_rename.path.length() - 1).get_file();
|
|
|
|
rename_dialog->set_title(TTR("Renaming folder:") + " " + name);
|
|
|
|
rename_dialog_text->set_text(name);
|
|
|
|
rename_dialog_text->select(0, name.length());
|
|
|
|
}
|
|
|
|
rename_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
|
|
|
|
rename_dialog_text->grab_focus();
|
2015-08-24 01:15:56 +02:00
|
|
|
} break;
|
|
|
|
case FILE_REMOVE: {
|
2017-10-02 00:24:49 +02:00
|
|
|
Vector<String> remove_files;
|
|
|
|
Vector<String> remove_folders;
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(i);
|
|
|
|
if (files->is_selected(i) && fpath != "res://") {
|
|
|
|
if (fpath.ends_with("/")) {
|
|
|
|
remove_folders.push_back(fpath);
|
2017-10-02 00:24:49 +02:00
|
|
|
} else {
|
2017-09-03 22:35:18 +02:00
|
|
|
remove_files.push_back(fpath);
|
2017-10-02 00:24:49 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2017-10-02 00:24:49 +02:00
|
|
|
if (remove_files.size() + remove_folders.size() > 0) {
|
|
|
|
remove_dialog->show(remove_folders, remove_files);
|
|
|
|
//1) find if used
|
|
|
|
//2) warn
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
} break;
|
2017-12-01 12:13:50 +01:00
|
|
|
case FILE_DUPLICATE: {
|
|
|
|
int idx = files->get_current();
|
|
|
|
if (idx < 0 || idx >= files->get_item_count())
|
|
|
|
break;
|
|
|
|
|
|
|
|
to_duplicate.path = files->get_item_metadata(idx);
|
|
|
|
to_duplicate.is_file = !to_duplicate.path.ends_with("/");
|
|
|
|
if (to_duplicate.is_file) {
|
|
|
|
String name = to_duplicate.path.get_file();
|
|
|
|
duplicate_dialog->set_title(TTR("Duplicating file:") + " " + name);
|
|
|
|
duplicate_dialog_text->set_text(name);
|
|
|
|
duplicate_dialog_text->select(0, name.find_last("."));
|
|
|
|
} else {
|
|
|
|
String name = to_duplicate.path.substr(0, to_duplicate.path.length() - 1).get_file();
|
|
|
|
duplicate_dialog->set_title(TTR("Duplicating folder:") + " " + name);
|
|
|
|
duplicate_dialog_text->set_text(name);
|
|
|
|
duplicate_dialog_text->select(0, name.length());
|
|
|
|
}
|
|
|
|
duplicate_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
|
|
|
|
duplicate_dialog_text->grab_focus();
|
|
|
|
} break;
|
2015-08-24 01:15:56 +02:00
|
|
|
case FILE_INFO: {
|
|
|
|
|
|
|
|
} break;
|
2016-05-27 19:18:40 +02:00
|
|
|
case FILE_REIMPORT: {
|
|
|
|
|
|
|
|
Vector<String> reimport;
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-05-27 19:18:40 +02:00
|
|
|
|
|
|
|
if (!files->is_selected(i))
|
|
|
|
continue;
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(i);
|
|
|
|
reimport.push_back(fpath);
|
2016-05-27 19:18:40 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND(reimport.size() == 0);
|
|
|
|
/*
|
2016-05-27 19:18:40 +02:00
|
|
|
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(reimport[0]);
|
|
|
|
ERR_FAIL_COND(!rimd.is_valid());
|
|
|
|
String editor=rimd->get_editor();
|
|
|
|
|
|
|
|
if (editor.begins_with("texture_")) { //compatibility fix for old texture format
|
|
|
|
editor="texture";
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(editor);
|
|
|
|
ERR_FAIL_COND(!rimp.is_valid());
|
|
|
|
|
|
|
|
if (reimport.size()==1) {
|
|
|
|
rimp->import_dialog(reimport[0]);
|
|
|
|
} else {
|
|
|
|
rimp->reimport_multiple_files(reimport);
|
|
|
|
|
|
|
|
}
|
2017-01-26 01:55:59 +01:00
|
|
|
*/
|
2016-05-27 19:18:40 +02:00
|
|
|
} break;
|
2017-10-02 00:33:43 +02:00
|
|
|
case FILE_NEW_FOLDER: {
|
|
|
|
make_dir_dialog_text->set_text("new folder");
|
|
|
|
make_dir_dialog_text->select_all();
|
|
|
|
make_dir_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
|
|
|
|
make_dir_dialog_text->grab_focus();
|
|
|
|
} break;
|
2018-04-25 09:18:10 +02:00
|
|
|
case FILE_NEW_SCRIPT: {
|
|
|
|
String tarDir = path;
|
|
|
|
if (tarDir != "res://" && !tarDir.ends_with("/")) {
|
|
|
|
tarDir += "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
make_script_dialog_text->config("Node", tarDir + "new_script.gd");
|
|
|
|
make_script_dialog_text->popup_centered(Size2(300, 300) * EDSCALE);
|
|
|
|
} break;
|
2017-10-09 15:59:48 +02:00
|
|
|
case FILE_COPY_PATH: {
|
2016-06-06 17:20:03 +02:00
|
|
|
int idx = files->get_current();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (idx < 0 || idx >= files->get_item_count())
|
2016-06-06 17:20:03 +02:00
|
|
|
break;
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(idx);
|
|
|
|
OS::get_singleton()->set_clipboard(fpath);
|
2017-10-09 15:59:48 +02:00
|
|
|
} break;
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-01-10 13:19:59 +01:00
|
|
|
void FileSystemDock::_folder_option(int p_option) {
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
TreeItem *selected = tree->get_selected();
|
2017-01-10 13:19:59 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
switch (p_option) {
|
2017-09-03 22:35:18 +02:00
|
|
|
case FOLDER_EXPAND_ALL:
|
2017-10-09 15:59:48 +02:00
|
|
|
case FOLDER_COLLAPSE_ALL: {
|
2017-09-03 22:35:18 +02:00
|
|
|
bool is_collapsed = (p_option == FOLDER_COLLAPSE_ALL);
|
|
|
|
Vector<TreeItem *> needs_check;
|
|
|
|
needs_check.push_back(selected);
|
|
|
|
|
|
|
|
while (needs_check.size()) {
|
|
|
|
needs_check[0]->set_collapsed(is_collapsed);
|
|
|
|
|
|
|
|
TreeItem *child = needs_check[0]->get_children();
|
|
|
|
while (child) {
|
|
|
|
needs_check.push_back(child);
|
|
|
|
child = child->get_next();
|
|
|
|
}
|
|
|
|
|
|
|
|
needs_check.remove(0);
|
2017-01-10 13:19:59 +01:00
|
|
|
}
|
2017-10-09 15:59:48 +02:00
|
|
|
} break;
|
2017-10-01 23:59:27 +02:00
|
|
|
case FOLDER_MOVE: {
|
|
|
|
to_move.clear();
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = selected->get_metadata(tree->get_selected_column());
|
2017-10-01 23:59:27 +02:00
|
|
|
if (fpath != "res://") {
|
|
|
|
fpath = fpath.ends_with("/") ? fpath.substr(0, fpath.length() - 1) : fpath;
|
|
|
|
to_move.push_back(FileOrFolder(fpath, false));
|
|
|
|
move_dialog->popup_centered_ratio();
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case FOLDER_RENAME: {
|
2017-09-03 22:35:18 +02:00
|
|
|
to_rename.path = selected->get_metadata(tree->get_selected_column());
|
2017-10-01 23:59:27 +02:00
|
|
|
to_rename.is_file = false;
|
|
|
|
if (to_rename.path != "res://") {
|
|
|
|
String name = to_rename.path.ends_with("/") ? to_rename.path.substr(0, to_rename.path.length() - 1).get_file() : to_rename.path.get_file();
|
|
|
|
rename_dialog->set_title(TTR("Renaming folder:") + " " + name);
|
|
|
|
rename_dialog_text->set_text(name);
|
|
|
|
rename_dialog_text->select(0, name.length());
|
|
|
|
rename_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
|
|
|
|
rename_dialog_text->grab_focus();
|
|
|
|
}
|
|
|
|
} break;
|
2017-10-02 00:24:49 +02:00
|
|
|
case FOLDER_REMOVE: {
|
|
|
|
Vector<String> remove_folders;
|
|
|
|
Vector<String> remove_files;
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = selected->get_metadata(tree->get_selected_column());
|
|
|
|
if (fpath != "res://") {
|
|
|
|
remove_folders.push_back(fpath);
|
2017-10-02 00:24:49 +02:00
|
|
|
remove_dialog->show(remove_folders, remove_files);
|
|
|
|
}
|
|
|
|
} break;
|
2017-10-02 00:33:43 +02:00
|
|
|
case FOLDER_NEW_FOLDER: {
|
|
|
|
make_dir_dialog_text->set_text("new folder");
|
|
|
|
make_dir_dialog_text->select_all();
|
|
|
|
make_dir_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
|
|
|
|
make_dir_dialog_text->grab_focus();
|
|
|
|
} break;
|
2017-10-09 15:59:48 +02:00
|
|
|
case FOLDER_COPY_PATH: {
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = selected->get_metadata(tree->get_selected_column());
|
|
|
|
OS::get_singleton()->set_clipboard(fpath);
|
2017-10-09 15:59:48 +02:00
|
|
|
} break;
|
|
|
|
case FOLDER_SHOW_IN_EXPLORER: {
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = selected->get_metadata(tree->get_selected_column());
|
|
|
|
String dir = ProjectSettings::get_singleton()->globalize_path(fpath);
|
2017-04-24 17:54:51 +02:00
|
|
|
OS::get_singleton()->shell_open(String("file://") + dir);
|
2017-10-09 15:59:48 +02:00
|
|
|
} break;
|
2017-01-10 13:19:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
void FileSystemDock::_go_to_file_list() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (low_height_mode) {
|
2015-08-24 01:15:56 +02:00
|
|
|
tree->hide();
|
2016-05-16 01:25:51 +02:00
|
|
|
file_list_vb->show();
|
2015-08-24 01:15:56 +02:00
|
|
|
button_favorite->hide();
|
2017-12-16 14:52:51 +01:00
|
|
|
} else {
|
|
|
|
bool collapsed = tree->get_selected()->is_collapsed();
|
|
|
|
tree->get_selected()->set_collapsed(!collapsed);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
//file_options->show();
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
_update_files(false);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-01-14 12:26:56 +01:00
|
|
|
//emit_signal("open",path);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::_dir_rmb_pressed(const Vector2 &p_pos) {
|
2017-01-10 13:19:59 +01:00
|
|
|
folder_options->clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
folder_options->set_size(Size2(1, 1));
|
2017-01-10 13:19:59 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
folder_options->add_item(TTR("Expand all"), FOLDER_EXPAND_ALL);
|
|
|
|
folder_options->add_item(TTR("Collapse all"), FOLDER_COLLAPSE_ALL);
|
2017-01-10 13:19:59 +01:00
|
|
|
|
2017-10-09 15:59:48 +02:00
|
|
|
TreeItem *item = tree->get_selected();
|
|
|
|
if (item) {
|
|
|
|
String fpath = item->get_metadata(tree->get_selected_column());
|
|
|
|
folder_options->add_separator();
|
|
|
|
folder_options->add_item(TTR("Copy Path"), FOLDER_COPY_PATH);
|
2017-10-01 23:59:27 +02:00
|
|
|
if (fpath != "res://") {
|
2018-04-22 19:36:01 +02:00
|
|
|
folder_options->add_item(TTR("Rename..."), FOLDER_RENAME);
|
|
|
|
folder_options->add_item(TTR("Move To..."), FOLDER_MOVE);
|
2017-10-02 00:24:49 +02:00
|
|
|
folder_options->add_item(TTR("Delete"), FOLDER_REMOVE);
|
2017-10-01 23:59:27 +02:00
|
|
|
}
|
2017-10-09 15:59:48 +02:00
|
|
|
folder_options->add_separator();
|
2018-04-22 19:36:01 +02:00
|
|
|
folder_options->add_item(TTR("New Folder..."), FOLDER_NEW_FOLDER);
|
2017-10-09 15:59:48 +02:00
|
|
|
folder_options->add_item(TTR("Show In File Manager"), FOLDER_SHOW_IN_EXPLORER);
|
|
|
|
}
|
2017-03-29 17:29:38 +02:00
|
|
|
folder_options->set_position(tree->get_global_position() + p_pos);
|
2017-01-10 13:19:59 +01:00
|
|
|
folder_options->popup();
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::_search_changed(const String &p_text) {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (file_list_vb->is_visible())
|
|
|
|
_update_files(false);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_rescan() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-01-21 13:07:29 +01:00
|
|
|
_set_scanning_mode();
|
2014-02-10 02:10:30 +01:00
|
|
|
EditorFileSystem::get_singleton()->scan();
|
2015-08-24 01:15:56 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::fix_dependencies(const String &p_for_file) {
|
2015-08-24 01:15:56 +02:00
|
|
|
deps_editor->edit(p_for_file);
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::focus_on_filter() {
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
if (low_height_mode && tree->is_visible()) {
|
2017-01-21 13:07:29 +01:00
|
|
|
// Tree mode, switch to files list with search box
|
|
|
|
tree->hide();
|
|
|
|
file_list_vb->show();
|
|
|
|
button_favorite->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
search_box->grab_focus();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2016-08-16 18:25:42 +02:00
|
|
|
void FileSystemDock::set_display_mode(int p_mode) {
|
|
|
|
|
|
|
|
if (p_mode == display_mode)
|
|
|
|
return;
|
2015-12-15 17:39:13 +01:00
|
|
|
|
2016-08-16 18:25:42 +02:00
|
|
|
button_display_mode->set_pressed(p_mode == DISPLAY_LIST);
|
|
|
|
_change_file_display();
|
2015-12-15 17:39:13 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
2017-10-25 00:09:04 +02:00
|
|
|
bool is_favorite = false;
|
|
|
|
Vector<String> paths;
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_from == tree) {
|
2016-05-16 01:25:51 +02:00
|
|
|
TreeItem *selected = tree->get_selected();
|
|
|
|
if (!selected)
|
|
|
|
return Variant();
|
|
|
|
|
2017-10-25 00:09:04 +02:00
|
|
|
String folder = selected->get_metadata(0);
|
|
|
|
if (folder == String())
|
2016-05-16 01:25:51 +02:00
|
|
|
return Variant();
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2017-10-25 00:09:04 +02:00
|
|
|
paths.push_back(folder.ends_with("/") ? folder : (folder + "/"));
|
|
|
|
is_favorite = selected->get_parent() != NULL && tree->get_root()->get_children() == selected->get_parent();
|
|
|
|
} else if (p_from == files) {
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-05-11 16:46:08 +02:00
|
|
|
if (files->is_selected(i)) {
|
2017-10-25 00:09:04 +02:00
|
|
|
paths.push_back(files->get_item_metadata(i));
|
2016-05-11 16:46:08 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-25 00:09:04 +02:00
|
|
|
}
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2017-10-25 00:09:04 +02:00
|
|
|
if (paths.empty())
|
|
|
|
return Variant();
|
2017-09-03 22:35:18 +02:00
|
|
|
|
2017-10-25 00:09:04 +02:00
|
|
|
Dictionary drag_data = EditorNode::get_singleton()->drag_files_and_dirs(paths, p_from);
|
|
|
|
if (is_favorite) {
|
|
|
|
drag_data["type"] = "favorite";
|
2016-05-11 16:46:08 +02:00
|
|
|
}
|
2017-10-25 00:09:04 +02:00
|
|
|
return drag_data;
|
2016-05-11 16:46:08 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
2016-05-11 16:46:08 +02:00
|
|
|
|
|
|
|
Dictionary drag_data = p_data;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
|
2016-05-24 04:24:17 +02:00
|
|
|
|
|
|
|
//moving favorite around
|
2017-09-10 15:37:49 +02:00
|
|
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
2016-05-24 04:24:17 +02:00
|
|
|
if (!ti)
|
|
|
|
return false;
|
|
|
|
|
2017-09-10 15:37:49 +02:00
|
|
|
int what = tree->get_drop_section_at_position(p_point);
|
2016-05-24 04:24:17 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (ti == tree->get_root()->get_children()) {
|
|
|
|
return (what == 1); //the parent, first fav
|
2016-05-24 04:24:17 +02:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
if (ti->get_parent() && tree->get_root()->get_children() == ti->get_parent()) {
|
2016-05-24 04:24:17 +02:00
|
|
|
return true; // a favorite
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (ti == tree->get_root()->get_children()->get_next()) {
|
|
|
|
return (what == -1); //the tree, last fav
|
2016-05-24 04:24:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
|
2017-10-25 16:40:33 +02:00
|
|
|
String to_dir = _get_drag_target_folder(p_point, p_from);
|
|
|
|
return !to_dir.empty();
|
2016-05-11 16:46:08 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) {
|
2017-10-25 16:27:35 +02:00
|
|
|
String to_dir = _get_drag_target_folder(p_point, p_from);
|
|
|
|
if (to_dir.empty())
|
|
|
|
return false;
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2017-10-25 16:27:35 +02:00
|
|
|
//Attempting to move a folder into itself will fail later
|
|
|
|
//Rather than bring up a message don't try to do it in the first place
|
|
|
|
to_dir = to_dir.ends_with("/") ? to_dir : (to_dir + "/");
|
2016-05-11 16:46:08 +02:00
|
|
|
Vector<String> fnames = drag_data["files"];
|
2017-10-25 16:27:35 +02:00
|
|
|
for (int i = 0; i < fnames.size(); ++i) {
|
|
|
|
if (fnames[i].ends_with("/") && to_dir.begins_with(fnames[i]))
|
2016-05-16 01:25:51 +02:00
|
|
|
return false;
|
|
|
|
}
|
2017-10-25 16:27:35 +02:00
|
|
|
|
|
|
|
return true;
|
2016-05-11 16:46:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (!can_drop_data_fw(p_point, p_data, p_from))
|
2016-05-11 16:46:08 +02:00
|
|
|
return;
|
|
|
|
Dictionary drag_data = p_data;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
|
2016-05-24 04:24:17 +02:00
|
|
|
|
|
|
|
//moving favorite around
|
2017-09-10 15:37:49 +02:00
|
|
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
2016-05-24 04:24:17 +02:00
|
|
|
if (!ti)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Vector<String> files = drag_data["files"];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND(files.size() != 1);
|
2016-05-24 04:24:17 +02:00
|
|
|
|
|
|
|
String swap = files[0];
|
2017-03-05 16:44:50 +01:00
|
|
|
if (swap != "res://" && swap.ends_with("/")) {
|
|
|
|
swap = swap.substr(0, swap.length() - 1);
|
2016-05-24 04:24:17 +02:00
|
|
|
}
|
|
|
|
|
2017-09-10 15:37:49 +02:00
|
|
|
int what = tree->get_drop_section_at_position(p_point);
|
2016-05-24 04:24:17 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
TreeItem *swap_item = NULL;
|
2016-05-24 04:24:17 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (ti == tree->get_root()->get_children()) {
|
|
|
|
swap_item = tree->get_root()->get_children()->get_children();
|
2016-05-24 04:24:17 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (ti->get_parent() && tree->get_root()->get_children() == ti->get_parent()) {
|
|
|
|
if (what == -1) {
|
|
|
|
swap_item = ti;
|
2016-05-24 04:24:17 +02:00
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
swap_item = ti->get_next();
|
2016-05-24 04:24:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String swap_with;
|
|
|
|
|
|
|
|
if (swap_item) {
|
2017-03-05 16:44:50 +01:00
|
|
|
swap_with = swap_item->get_metadata(0);
|
|
|
|
if (swap_with != "res://" && swap_with.ends_with("/")) {
|
|
|
|
swap_with = swap_with.substr(0, swap_with.length() - 1);
|
2016-05-24 04:24:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (swap == swap_with)
|
2016-05-24 04:24:17 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
Vector<String> dirs = EditorSettings::get_singleton()->get_favorite_dirs();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND(dirs.find(swap) == -1);
|
|
|
|
ERR_FAIL_COND(swap_with != String() && dirs.find(swap_with) == -1);
|
2016-05-24 04:24:17 +02:00
|
|
|
|
|
|
|
dirs.erase(swap);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (swap_with == String()) {
|
2016-05-24 04:24:17 +02:00
|
|
|
dirs.push_back(swap);
|
|
|
|
} else {
|
|
|
|
int idx = dirs.find(swap_with);
|
2017-03-05 16:44:50 +01:00
|
|
|
dirs.insert(idx, swap);
|
2016-05-24 04:24:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorSettings::get_singleton()->set_favorite_dirs(dirs);
|
2017-09-03 22:35:18 +02:00
|
|
|
_update_tree(true);
|
2016-05-24 04:24:17 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
|
2016-05-11 16:46:08 +02:00
|
|
|
Ref<Resource> res = drag_data["resource"];
|
2017-10-25 16:40:33 +02:00
|
|
|
String to_dir = _get_drag_target_folder(p_point, p_from);
|
|
|
|
if (res.is_valid() && !to_dir.empty()) {
|
|
|
|
EditorNode::get_singleton()->push_item(res.ptr());
|
|
|
|
EditorNode::get_singleton()->save_resource_as(res, to_dir);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
2016-05-11 16:46:08 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) {
|
2017-10-25 16:27:35 +02:00
|
|
|
String to_dir = _get_drag_target_folder(p_point, p_from);
|
|
|
|
if (!to_dir.empty()) {
|
2016-05-16 01:25:51 +02:00
|
|
|
Vector<String> fnames = drag_data["files"];
|
2017-10-01 23:59:27 +02:00
|
|
|
to_move.clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < fnames.size(); i++) {
|
2017-10-01 23:59:27 +02:00
|
|
|
to_move.push_back(FileOrFolder(fnames[i], !fnames[i].ends_with("/")));
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
2017-10-01 23:59:27 +02:00
|
|
|
_move_operation_confirm(to_dir);
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
2016-05-11 16:46:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-25 16:27:35 +02:00
|
|
|
String FileSystemDock::_get_drag_target_folder(const Point2 &p_point, Control *p_from) const {
|
|
|
|
if (p_from == files) {
|
|
|
|
int pos = files->get_item_at_position(p_point, true);
|
|
|
|
if (pos == -1)
|
|
|
|
return path;
|
|
|
|
|
|
|
|
String target = files->get_item_metadata(pos);
|
|
|
|
return target.ends_with("/") ? target : path;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_from == tree) {
|
|
|
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
|
|
|
if (ti && ti != tree->get_root()->get_children())
|
|
|
|
return ti->get_metadata(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return String();
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-10-09 15:59:48 +02:00
|
|
|
//Right clicking ".." should clear current selection
|
|
|
|
if (files->get_item_text(p_item) == "..") {
|
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
|
|
|
files->unselect(i);
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-10-09 15:59:48 +02:00
|
|
|
Vector<String> filenames;
|
|
|
|
Vector<String> foldernames;
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-10-09 15:59:48 +02:00
|
|
|
bool all_files = true;
|
|
|
|
bool all_files_scenes = true;
|
|
|
|
bool all_folders = true;
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2017-10-09 15:59:48 +02:00
|
|
|
if (!files->is_selected(i)) {
|
2016-05-16 01:25:51 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(i);
|
|
|
|
if (fpath.ends_with("/")) {
|
|
|
|
foldernames.push_back(fpath);
|
2017-10-09 15:59:48 +02:00
|
|
|
all_files = false;
|
2016-05-27 19:18:40 +02:00
|
|
|
} else {
|
2017-09-03 22:35:18 +02:00
|
|
|
filenames.push_back(fpath);
|
2017-10-09 15:59:48 +02:00
|
|
|
all_folders = false;
|
2017-09-03 22:35:18 +02:00
|
|
|
all_files_scenes &= (EditorFileSystem::get_singleton()->get_file_type(fpath) == "PackedScene");
|
2016-05-27 19:18:40 +02:00
|
|
|
}
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
file_options->clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
file_options->set_size(Size2(1, 1));
|
2017-12-01 09:01:50 +01:00
|
|
|
if (all_files) {
|
|
|
|
|
|
|
|
if (all_files_scenes && filenames.size() >= 1) {
|
|
|
|
file_options->add_item(TTR("Open Scene(s)"), FILE_OPEN);
|
2017-10-09 15:59:48 +02:00
|
|
|
file_options->add_item(TTR("Instance"), FILE_INSTANCE);
|
2017-12-01 09:01:50 +01:00
|
|
|
file_options->add_separator();
|
2017-10-09 15:59:48 +02:00
|
|
|
}
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-12-01 09:01:50 +01:00
|
|
|
if (!all_files_scenes && filenames.size() == 1) {
|
|
|
|
file_options->add_item(TTR("Open"), FILE_OPEN);
|
|
|
|
file_options->add_separator();
|
2017-12-09 03:33:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (filenames.size() == 1) {
|
2018-04-22 19:36:01 +02:00
|
|
|
file_options->add_item(TTR("Edit Dependencies..."), FILE_DEPENDENCIES);
|
|
|
|
file_options->add_item(TTR("View Owners..."), FILE_OWNERS);
|
2017-11-21 00:45:26 +01:00
|
|
|
file_options->add_separator();
|
2017-10-09 15:59:48 +02:00
|
|
|
}
|
2017-12-09 03:33:28 +01:00
|
|
|
|
2017-10-09 15:59:48 +02:00
|
|
|
} else if (all_folders && foldernames.size() > 0) {
|
|
|
|
file_options->add_item(TTR("Open"), FILE_OPEN);
|
2017-11-21 00:45:26 +01:00
|
|
|
file_options->add_separator();
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
|
|
|
|
2017-10-09 15:59:48 +02:00
|
|
|
int num_items = filenames.size() + foldernames.size();
|
|
|
|
if (num_items >= 1) {
|
|
|
|
if (num_items == 1) {
|
2017-09-25 15:15:11 +02:00
|
|
|
file_options->add_item(TTR("Copy Path"), FILE_COPY_PATH);
|
2018-04-22 19:36:01 +02:00
|
|
|
file_options->add_item(TTR("Rename..."), FILE_RENAME);
|
|
|
|
file_options->add_item(TTR("Duplicate..."), FILE_DUPLICATE);
|
2017-09-25 15:15:11 +02:00
|
|
|
}
|
2018-04-22 19:36:01 +02:00
|
|
|
file_options->add_item(TTR("Move To..."), FILE_MOVE);
|
2017-10-09 15:59:48 +02:00
|
|
|
file_options->add_item(TTR("Delete"), FILE_REMOVE);
|
|
|
|
file_options->add_separator();
|
2016-05-16 01:25:51 +02:00
|
|
|
}
|
|
|
|
|
2018-04-22 19:36:01 +02:00
|
|
|
file_options->add_item(TTR("New Folder..."), FILE_NEW_FOLDER);
|
2018-04-25 09:18:10 +02:00
|
|
|
file_options->add_item(TTR("New Script..."), FILE_NEW_SCRIPT);
|
2017-03-05 16:44:50 +01:00
|
|
|
file_options->add_item(TTR("Show In File Manager"), FILE_SHOW_IN_EXPLORER);
|
2016-05-18 09:37:59 +02:00
|
|
|
|
2017-03-29 17:29:38 +02:00
|
|
|
file_options->set_position(files->get_global_position() + p_pos);
|
2016-05-16 01:25:51 +02:00
|
|
|
file_options->popup();
|
|
|
|
}
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2017-11-20 19:25:13 +01:00
|
|
|
void FileSystemDock::_rmb_pressed(const Vector2 &p_pos) {
|
2017-11-20 23:13:37 +01:00
|
|
|
file_options->clear();
|
|
|
|
file_options->set_size(Size2(1, 1));
|
2017-11-20 19:25:13 +01:00
|
|
|
|
2018-04-22 19:36:01 +02:00
|
|
|
file_options->add_item(TTR("New Folder..."), FILE_NEW_FOLDER);
|
2018-04-25 09:18:10 +02:00
|
|
|
file_options->add_item(TTR("New Script..."), FILE_NEW_SCRIPT);
|
2017-11-20 23:13:37 +01:00
|
|
|
file_options->add_item(TTR("Show In File Manager"), FILE_SHOW_IN_EXPLORER);
|
|
|
|
file_options->set_position(files->get_global_position() + p_pos);
|
|
|
|
file_options->popup();
|
2017-11-20 19:25:13 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::select_file(const String &p_file) {
|
2017-01-25 18:30:40 +01:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
navigate_to_path(p_file);
|
2017-01-25 18:30:40 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) {
|
2017-02-01 13:45:45 +01:00
|
|
|
|
2017-11-02 14:05:34 +01:00
|
|
|
import_dock_needs_update = true;
|
|
|
|
call_deferred("_update_import_dock");
|
2017-02-01 13:45:45 +01:00
|
|
|
}
|
|
|
|
|
2018-01-05 20:45:54 +01:00
|
|
|
void FileSystemDock::_files_gui_input(Ref<InputEvent> p_event) {
|
|
|
|
|
|
|
|
if (get_viewport()->get_modal_stack_top())
|
|
|
|
return; //ignore because of modal window
|
|
|
|
|
|
|
|
Ref<InputEventKey> key = p_event;
|
|
|
|
if (key.is_valid() && key->is_pressed() && !key->is_echo()) {
|
|
|
|
if (ED_IS_SHORTCUT("filesystem_dock/duplicate", p_event)) {
|
|
|
|
_file_option(FILE_DUPLICATE);
|
|
|
|
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_path", p_event)) {
|
|
|
|
_file_option(FILE_COPY_PATH);
|
|
|
|
} else if (ED_IS_SHORTCUT("filesystem_dock/delete", p_event)) {
|
|
|
|
_file_option(FILE_REMOVE);
|
2018-03-26 19:50:48 +02:00
|
|
|
} else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) {
|
|
|
|
_file_option(FILE_RENAME);
|
2018-01-05 20:45:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-01 13:45:45 +01:00
|
|
|
void FileSystemDock::_file_selected() {
|
|
|
|
|
2017-11-02 14:05:34 +01:00
|
|
|
import_dock_needs_update = true;
|
|
|
|
_update_import_dock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileSystemDock::_update_import_dock() {
|
|
|
|
|
|
|
|
if (!import_dock_needs_update)
|
|
|
|
return;
|
|
|
|
|
2017-02-01 13:45:45 +01:00
|
|
|
//check import
|
|
|
|
Vector<String> imports;
|
|
|
|
String import_type;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2017-02-01 13:45:45 +01:00
|
|
|
if (!files->is_selected(i))
|
|
|
|
continue;
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
String fpath = files->get_item_metadata(i);
|
|
|
|
if (!FileAccess::exists(fpath + ".import")) {
|
2017-02-01 13:45:45 +01:00
|
|
|
imports.clear();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Ref<ConfigFile> cf;
|
|
|
|
cf.instance();
|
2017-09-03 22:35:18 +02:00
|
|
|
Error err = cf->load(fpath + ".import");
|
2017-03-05 16:44:50 +01:00
|
|
|
if (err != OK) {
|
2017-02-01 13:45:45 +01:00
|
|
|
imports.clear();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String type = cf->get_value("remap", "type");
|
|
|
|
if (import_type == "") {
|
|
|
|
import_type = type;
|
|
|
|
} else if (import_type != type) {
|
2017-02-01 13:45:45 +01:00
|
|
|
//all should be the same type
|
|
|
|
imports.clear();
|
|
|
|
break;
|
|
|
|
}
|
2017-09-03 22:35:18 +02:00
|
|
|
imports.push_back(fpath);
|
2017-02-01 13:45:45 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (imports.size() == 0) {
|
2017-02-01 13:45:45 +01:00
|
|
|
EditorNode::get_singleton()->get_import_dock()->clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (imports.size() == 1) {
|
2017-02-01 13:45:45 +01:00
|
|
|
EditorNode::get_singleton()->get_import_dock()->set_edit_path(imports[0]);
|
|
|
|
} else {
|
|
|
|
EditorNode::get_singleton()->get_import_dock()->set_edit_multiple_paths(imports);
|
|
|
|
}
|
2017-11-02 14:05:34 +01:00
|
|
|
|
|
|
|
import_dock_needs_update = false;
|
2017-02-01 13:45:45 +01:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
void FileSystemDock::_bind_methods() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2018-01-05 20:45:54 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_files_gui_input"), &FileSystemDock::_files_gui_input);
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_update_tree"), &FileSystemDock::_update_tree);
|
|
|
|
ClassDB::bind_method(D_METHOD("_rescan"), &FileSystemDock::_rescan);
|
|
|
|
ClassDB::bind_method(D_METHOD("_favorites_pressed"), &FileSystemDock::_favorites_pressed);
|
2017-02-13 12:47:24 +01:00
|
|
|
//ClassDB::bind_method(D_METHOD("_instance_pressed"),&ScenesDock::_instance_pressed);
|
2017-09-03 22:35:18 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("_go_to_file_list"), &FileSystemDock::_go_to_file_list);
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_dir_rmb_pressed"), &FileSystemDock::_dir_rmb_pressed);
|
2017-02-13 12:47:24 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_thumbnail_done"), &FileSystemDock::_thumbnail_done);
|
2017-02-13 12:47:24 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file);
|
|
|
|
ClassDB::bind_method(D_METHOD("_go_to_tree"), &FileSystemDock::_go_to_tree);
|
2017-09-03 22:35:18 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("navigate_to_path"), &FileSystemDock::navigate_to_path);
|
2017-02-13 12:47:24 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_change_file_display"), &FileSystemDock::_change_file_display);
|
|
|
|
ClassDB::bind_method(D_METHOD("_fw_history"), &FileSystemDock::_fw_history);
|
|
|
|
ClassDB::bind_method(D_METHOD("_bw_history"), &FileSystemDock::_bw_history);
|
|
|
|
ClassDB::bind_method(D_METHOD("_fs_changed"), &FileSystemDock::_fs_changed);
|
|
|
|
ClassDB::bind_method(D_METHOD("_dir_selected"), &FileSystemDock::_dir_selected);
|
|
|
|
ClassDB::bind_method(D_METHOD("_file_option"), &FileSystemDock::_file_option);
|
|
|
|
ClassDB::bind_method(D_METHOD("_folder_option"), &FileSystemDock::_folder_option);
|
2017-10-02 00:33:43 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("_make_dir_confirm"), &FileSystemDock::_make_dir_confirm);
|
2017-10-01 23:59:27 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("_move_operation_confirm"), &FileSystemDock::_move_operation_confirm);
|
|
|
|
ClassDB::bind_method(D_METHOD("_rename_operation_confirm"), &FileSystemDock::_rename_operation_confirm);
|
2017-12-01 12:13:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_duplicate_operation_confirm"), &FileSystemDock::_duplicate_operation_confirm);
|
2017-02-13 12:47:24 +01:00
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("_search_changed"), &FileSystemDock::_search_changed);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &FileSystemDock::get_drag_data_fw);
|
|
|
|
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &FileSystemDock::can_drop_data_fw);
|
|
|
|
ClassDB::bind_method(D_METHOD("drop_data_fw"), &FileSystemDock::drop_data_fw);
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_files_list_rmb_select"), &FileSystemDock::_files_list_rmb_select);
|
2016-07-03 18:15:15 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_preview_invalidated"), &FileSystemDock::_preview_invalidated);
|
|
|
|
ClassDB::bind_method(D_METHOD("_file_selected"), &FileSystemDock::_file_selected);
|
|
|
|
ClassDB::bind_method(D_METHOD("_file_multi_selected"), &FileSystemDock::_file_multi_selected);
|
2017-11-02 14:05:34 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_update_import_dock"), &FileSystemDock::_update_import_dock);
|
2017-11-20 19:25:13 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_rmb_pressed"), &FileSystemDock::_rmb_pressed);
|
2016-07-03 18:15:15 +02:00
|
|
|
|
2017-01-11 04:52:51 +01:00
|
|
|
ADD_SIGNAL(MethodInfo("instance", PropertyInfo(Variant::POOL_STRING_ARRAY, "files")));
|
2014-02-10 02:10:30 +01:00
|
|
|
ADD_SIGNAL(MethodInfo("open"));
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
FileSystemDock::FileSystemDock(EditorNode *p_editor) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-11-26 02:59:31 +01:00
|
|
|
set_name("FileSystem");
|
2017-03-05 16:44:50 +01:00
|
|
|
editor = p_editor;
|
2017-09-03 22:35:18 +02:00
|
|
|
path = "res://";
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2018-01-05 20:45:54 +01:00
|
|
|
ED_SHORTCUT("filesystem_dock/copy_path", TTR("Copy Path"), KEY_MASK_CMD | KEY_C);
|
|
|
|
ED_SHORTCUT("filesystem_dock/duplicate", TTR("Duplicate..."), KEY_MASK_CMD | KEY_D);
|
|
|
|
ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), KEY_DELETE);
|
2018-03-26 19:50:48 +02:00
|
|
|
ED_SHORTCUT("filesystem_dock/rename", TTR("Rename"));
|
2018-01-05 20:45:54 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
HBoxContainer *toolbar_hbc = memnew(HBoxContainer);
|
2014-05-16 13:48:23 +02:00
|
|
|
add_child(toolbar_hbc);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
button_hist_prev = memnew(ToolButton);
|
2015-08-24 01:15:56 +02:00
|
|
|
button_hist_prev->set_disabled(true);
|
2017-09-03 22:35:18 +02:00
|
|
|
button_hist_prev->set_focus_mode(FOCUS_NONE);
|
2016-05-04 03:25:37 +02:00
|
|
|
button_hist_prev->set_tooltip(TTR("Previous Directory"));
|
2017-09-03 22:35:18 +02:00
|
|
|
toolbar_hbc->add_child(button_hist_prev);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
button_hist_next = memnew(ToolButton);
|
2015-08-24 01:15:56 +02:00
|
|
|
button_hist_next->set_disabled(true);
|
|
|
|
button_hist_next->set_focus_mode(FOCUS_NONE);
|
2016-05-04 03:25:37 +02:00
|
|
|
button_hist_next->set_tooltip(TTR("Next Directory"));
|
2017-09-03 22:35:18 +02:00
|
|
|
toolbar_hbc->add_child(button_hist_next);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
current_path = memnew(LineEdit);
|
2016-05-24 04:24:17 +02:00
|
|
|
current_path->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
toolbar_hbc->add_child(current_path);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
button_reload = memnew(Button);
|
2014-02-10 02:10:30 +01:00
|
|
|
button_reload->set_flat(true);
|
2017-03-05 16:44:50 +01:00
|
|
|
button_reload->connect("pressed", this, "_rescan");
|
2015-08-24 01:15:56 +02:00
|
|
|
button_reload->set_focus_mode(FOCUS_NONE);
|
2016-05-04 03:25:37 +02:00
|
|
|
button_reload->set_tooltip(TTR("Re-Scan Filesystem"));
|
2016-05-24 04:24:17 +02:00
|
|
|
button_reload->hide();
|
2017-09-03 22:35:18 +02:00
|
|
|
toolbar_hbc->add_child(button_reload);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-05-02 23:02:06 +02:00
|
|
|
//toolbar_hbc->add_spacer();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
button_favorite = memnew(Button);
|
2014-02-10 02:10:30 +01:00
|
|
|
button_favorite->set_flat(true);
|
|
|
|
button_favorite->set_toggle_mode(true);
|
2017-03-05 16:44:50 +01:00
|
|
|
button_favorite->connect("pressed", this, "_favorites_pressed");
|
2016-05-04 03:25:37 +02:00
|
|
|
button_favorite->set_tooltip(TTR("Toggle folder status as Favorite"));
|
2015-08-24 01:15:56 +02:00
|
|
|
button_favorite->set_focus_mode(FOCUS_NONE);
|
2017-09-03 22:35:18 +02:00
|
|
|
toolbar_hbc->add_child(button_favorite);
|
2016-05-24 04:24:17 +02:00
|
|
|
|
2017-01-14 12:26:56 +01:00
|
|
|
//Control *spacer = memnew( Control);
|
2016-05-24 04:24:17 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
/*
|
2014-02-10 02:10:30 +01:00
|
|
|
button_open = memnew( Button );
|
|
|
|
button_open->set_flat(true);
|
2017-09-03 22:35:18 +02:00
|
|
|
button_open->connect("pressed",this,"_go_to_file_list");
|
2014-05-16 13:48:23 +02:00
|
|
|
toolbar_hbc->add_child(button_open);
|
2015-08-24 01:15:56 +02:00
|
|
|
button_open->hide();
|
|
|
|
button_open->set_focus_mode(FOCUS_NONE);
|
|
|
|
button_open->set_tooltip("Open the selected file.\nOpen as scene if a scene, or as resource otherwise.");
|
|
|
|
|
2014-05-16 13:48:23 +02:00
|
|
|
|
|
|
|
button_instance = memnew( Button );
|
|
|
|
button_instance->set_flat(true);
|
|
|
|
button_instance->connect("pressed",this,"_instance_pressed");
|
|
|
|
toolbar_hbc->add_child(button_instance);
|
2015-08-24 01:15:56 +02:00
|
|
|
button_instance->hide();
|
|
|
|
button_instance->set_focus_mode(FOCUS_NONE);
|
2016-05-04 03:25:37 +02:00
|
|
|
button_instance->set_tooltip(TTR("Instance the selected scene(s) as child of the selected node."));
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2016-05-16 01:25:51 +02:00
|
|
|
*/
|
2017-03-05 16:44:50 +01:00
|
|
|
file_options = memnew(PopupMenu);
|
2016-05-16 01:25:51 +02:00
|
|
|
add_child(file_options);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
folder_options = memnew(PopupMenu);
|
2017-01-10 13:19:59 +01:00
|
|
|
add_child(folder_options);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
split_box = memnew(VSplitContainer);
|
2016-05-16 01:25:51 +02:00
|
|
|
split_box->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-09-03 22:35:18 +02:00
|
|
|
add_child(split_box);
|
2014-05-16 13:48:23 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
tree = memnew(Tree);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
|
|
|
tree->set_hide_root(true);
|
2016-05-16 01:25:51 +02:00
|
|
|
tree->set_drag_forwarding(this);
|
2017-01-10 13:19:59 +01:00
|
|
|
tree->set_allow_rmb_select(true);
|
2017-09-03 22:35:18 +02:00
|
|
|
tree->set_custom_minimum_size(Size2(0, 200 * EDSCALE));
|
|
|
|
split_box->add_child(tree);
|
2014-05-16 13:48:23 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
tree->connect("item_edited", this, "_favorite_toggled");
|
2017-09-03 22:35:18 +02:00
|
|
|
tree->connect("item_activated", this, "_go_to_file_list");
|
2017-03-05 16:44:50 +01:00
|
|
|
tree->connect("cell_selected", this, "_dir_selected");
|
|
|
|
tree->connect("item_rmb_selected", this, "_dir_rmb_pressed");
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
file_list_vb = memnew(VBoxContainer);
|
2016-05-16 01:25:51 +02:00
|
|
|
file_list_vb->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-09-03 22:35:18 +02:00
|
|
|
split_box->add_child(file_list_vb);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
path_hb = memnew(HBoxContainer);
|
2016-05-16 01:25:51 +02:00
|
|
|
file_list_vb->add_child(path_hb);
|
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
button_tree = memnew(ToolButton);
|
|
|
|
button_tree->hide();
|
|
|
|
path_hb->add_child(button_tree);
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
search_box = memnew(LineEdit);
|
2016-05-16 01:25:51 +02:00
|
|
|
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
|
2017-03-05 16:44:50 +01:00
|
|
|
search_box->connect("text_changed", this, "_search_changed");
|
2017-09-03 22:35:18 +02:00
|
|
|
path_hb->add_child(search_box);
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
button_display_mode = memnew(ToolButton);
|
2016-08-16 18:25:42 +02:00
|
|
|
button_display_mode->set_toggle_mode(true);
|
2017-09-03 22:35:18 +02:00
|
|
|
path_hb->add_child(button_display_mode);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
files = memnew(ItemList);
|
|
|
|
files->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
files->set_select_mode(ItemList::SELECT_MULTI);
|
|
|
|
files->set_drag_forwarding(this);
|
|
|
|
files->connect("item_rmb_selected", this, "_files_list_rmb_select");
|
2018-01-05 20:45:54 +01:00
|
|
|
files->connect("gui_input", this, "_files_gui_input");
|
2017-09-03 22:35:18 +02:00
|
|
|
files->connect("item_selected", this, "_file_selected");
|
|
|
|
files->connect("multi_selected", this, "_file_multi_selected");
|
2017-11-20 19:25:13 +01:00
|
|
|
files->connect("rmb_clicked", this, "_rmb_pressed");
|
2017-09-03 22:35:18 +02:00
|
|
|
files->set_allow_rmb_select(true);
|
2016-05-16 01:25:51 +02:00
|
|
|
file_list_vb->add_child(files);
|
2015-08-24 01:15:56 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
scanning_vb = memnew(VBoxContainer);
|
2017-09-03 22:35:18 +02:00
|
|
|
scanning_vb->hide();
|
|
|
|
add_child(scanning_vb);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Label *slabel = memnew(Label);
|
2018-04-22 19:36:01 +02:00
|
|
|
slabel->set_text(TTR("Scanning Files,\nPlease Wait..."));
|
2015-08-24 01:15:56 +02:00
|
|
|
slabel->set_align(Label::ALIGN_CENTER);
|
|
|
|
scanning_vb->add_child(slabel);
|
2017-09-03 22:35:18 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
scanning_progress = memnew(ProgressBar);
|
2015-08-24 01:15:56 +02:00
|
|
|
scanning_vb->add_child(scanning_progress);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
deps_editor = memnew(DependencyEditor);
|
2015-08-24 01:15:56 +02:00
|
|
|
add_child(deps_editor);
|
|
|
|
|
2017-11-15 05:05:49 +01:00
|
|
|
owners_editor = memnew(DependencyEditorOwners(editor));
|
2015-08-24 01:15:56 +02:00
|
|
|
add_child(owners_editor);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
remove_dialog = memnew(DependencyRemoveDialog);
|
2015-08-24 01:15:56 +02:00
|
|
|
add_child(remove_dialog);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
move_dialog = memnew(EditorDirDialog);
|
2017-09-03 22:35:18 +02:00
|
|
|
move_dialog->get_ok()->set_text(TTR("Move"));
|
2016-03-09 00:00:52 +01:00
|
|
|
add_child(move_dialog);
|
2017-10-01 23:59:27 +02:00
|
|
|
move_dialog->connect("dir_selected", this, "_move_operation_confirm");
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2017-10-01 23:59:27 +02:00
|
|
|
rename_dialog = memnew(ConfirmationDialog);
|
|
|
|
VBoxContainer *rename_dialog_vb = memnew(VBoxContainer);
|
|
|
|
rename_dialog->add_child(rename_dialog_vb);
|
|
|
|
|
|
|
|
rename_dialog_text = memnew(LineEdit);
|
|
|
|
rename_dialog_vb->add_margin_child(TTR("Name:"), rename_dialog_text);
|
|
|
|
rename_dialog->get_ok()->set_text(TTR("Rename"));
|
2015-08-24 01:15:56 +02:00
|
|
|
add_child(rename_dialog);
|
2017-10-01 23:59:27 +02:00
|
|
|
rename_dialog->register_text_enter(rename_dialog_text);
|
|
|
|
rename_dialog->connect("confirmed", this, "_rename_operation_confirm");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-12-01 12:13:50 +01:00
|
|
|
duplicate_dialog = memnew(ConfirmationDialog);
|
|
|
|
VBoxContainer *duplicate_dialog_vb = memnew(VBoxContainer);
|
|
|
|
duplicate_dialog->add_child(duplicate_dialog_vb);
|
|
|
|
|
|
|
|
duplicate_dialog_text = memnew(LineEdit);
|
|
|
|
duplicate_dialog_vb->add_margin_child(TTR("Name:"), duplicate_dialog_text);
|
|
|
|
duplicate_dialog->get_ok()->set_text(TTR("Duplicate"));
|
|
|
|
add_child(duplicate_dialog);
|
|
|
|
duplicate_dialog->register_text_enter(duplicate_dialog_text);
|
|
|
|
duplicate_dialog->connect("confirmed", this, "_duplicate_operation_confirm");
|
|
|
|
|
2017-10-02 00:33:43 +02:00
|
|
|
make_dir_dialog = memnew(ConfirmationDialog);
|
|
|
|
make_dir_dialog->set_title(TTR("Create Folder"));
|
|
|
|
VBoxContainer *make_folder_dialog_vb = memnew(VBoxContainer);
|
|
|
|
make_dir_dialog->add_child(make_folder_dialog_vb);
|
|
|
|
|
|
|
|
make_dir_dialog_text = memnew(LineEdit);
|
|
|
|
make_folder_dialog_vb->add_margin_child(TTR("Name:"), make_dir_dialog_text);
|
|
|
|
add_child(make_dir_dialog);
|
|
|
|
make_dir_dialog->register_text_enter(make_dir_dialog_text);
|
|
|
|
make_dir_dialog->connect("confirmed", this, "_make_dir_confirm");
|
|
|
|
|
2018-04-25 09:18:10 +02:00
|
|
|
make_script_dialog_text = memnew(ScriptCreateDialog);
|
|
|
|
make_script_dialog_text->set_title(TTR("Create Script"));
|
|
|
|
add_child(make_script_dialog_text);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
updating_tree = false;
|
|
|
|
initialized = false;
|
2017-11-02 14:05:34 +01:00
|
|
|
import_dock_needs_update = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
history_pos = 0;
|
2017-09-03 22:35:18 +02:00
|
|
|
history_max_size = 20;
|
|
|
|
history.push_back("res://");
|
2016-05-16 01:25:51 +02:00
|
|
|
|
2017-09-03 22:35:18 +02:00
|
|
|
low_height_mode = false;
|
2016-08-16 18:25:42 +02:00
|
|
|
display_mode = DISPLAY_THUMBNAILS;
|
2014-05-16 13:48:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:34:57 +02:00
|
|
|
FileSystemDock::~FileSystemDock() {
|
2014-05-16 13:48:23 +02:00
|
|
|
}
|