summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorPoommetee Ketson <poommetee@protonmail.com>2017-10-02 23:52:09 +0700
committerGitHub <noreply@github.com>2017-10-02 23:52:09 +0700
commit478fd21e07fd4092e3a099556d4004e34ae31177 (patch)
tree45f4cee59e852440f43b2e9e8c17e879053f8eb7 /editor
parent34ea27138072446947ee12bfcaba288f9ff825e5 (diff)
parent20918587d39c5c9c370e3b4beccf883f553d9b3e (diff)
Merge pull request #11575 from marcelofg55/move_path_to_trash
FileSystemDock will now remove files/dirs to trashcan using OS::move_to_trash
Diffstat (limited to 'editor')
-rw-r--r--editor/dependency_editor.cpp13
-rw-r--r--editor/filesystem_dock.cpp20
2 files changed, 20 insertions, 13 deletions
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 54bf31cd62..5305c4f256 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -409,17 +409,22 @@ void DependencyRemoveDialog::show(const Vector<String> &to_erase) {
void DependencyRemoveDialog::ok_pressed() {
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ bool changed = false;
+
for (Map<String, TreeItem *>::Element *E = files.front(); E; E = E->next()) {
if (ResourceCache::has(E->key())) {
Resource *res = ResourceCache::get(E->key());
res->set_path(""); //clear reference to path
}
- da->remove(E->key());
- EditorFileSystem::get_singleton()->update_file(E->key());
+ String fpath = OS::get_singleton()->get_resource_dir() + E->key().replace_first("res://", "/");
+ OS::get_singleton()->move_to_trash(fpath);
+ changed = true;
+ }
+
+ if (changed) {
+ EditorFileSystem::get_singleton()->scan_changes();
}
- memdelete(da);
}
DependencyRemoveDialog::DependencyRemoveDialog() {
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 5f9f109a2e..a9d72607b4 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1002,7 +1002,7 @@ void FileSystemDock::_file_option(int p_option) {
for (int i = 0; i < files->get_item_count(); i++) {
String path = files->get_item_metadata(i);
- if (path.ends_with("/") || !files->is_selected(i))
+ if (!files->is_selected(i))
continue;
torem.push_back(path);
}
@@ -1466,6 +1466,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
bool all_scenes = true;
bool all_can_reimport = true;
+ bool is_dir = false;
Set<String> types;
for (int i = 0; i < files->get_item_count(); i++) {
@@ -1481,8 +1482,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
}
if (path.ends_with("/")) {
- //no operate on dirs
- return;
+ is_dir = true;
}
int pos;
@@ -1513,17 +1513,19 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
file_options->add_separator();
- if (filenames.size() == 1) {
+ if (filenames.size() == 1 && !is_dir) {
file_options->add_item(TTR("Edit Dependencies.."), FILE_DEPENDENCIES);
file_options->add_item(TTR("View Owners.."), FILE_OWNERS);
file_options->add_separator();
}
- if (filenames.size() == 1) {
- file_options->add_item(TTR("Copy Path"), FILE_COPY_PATH);
- file_options->add_item(TTR("Rename or Move.."), FILE_MOVE);
- } else {
- file_options->add_item(TTR("Move To.."), FILE_MOVE);
+ if (!is_dir) {
+ if (filenames.size() == 1) {
+ file_options->add_item(TTR("Copy Path"), FILE_COPY_PATH);
+ file_options->add_item(TTR("Rename or Move.."), FILE_MOVE);
+ } else {
+ file_options->add_item(TTR("Move To.."), FILE_MOVE);
+ }
}
file_options->add_item(TTR("Delete"), FILE_REMOVE);