You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-21 14:57:09 +00:00
Improve file move and copy operations
This commit is contained in:
@@ -30,11 +30,14 @@
|
||||
|
||||
#include "editor_dir_dialog.h"
|
||||
|
||||
#include "core/io/dir_access.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/os/os.h"
|
||||
#include "editor/editor_file_system.h"
|
||||
#include "editor/editor_scale.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "scene/gui/check_box.h"
|
||||
#include "scene/gui/tree.h"
|
||||
#include "servers/display_server.h"
|
||||
|
||||
void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p_dir, const String &p_select_path) {
|
||||
@@ -56,8 +59,6 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p
|
||||
p_item->set_text(0, p_dir->get_name());
|
||||
}
|
||||
|
||||
//this should be handled by EditorFileSystem already
|
||||
//bool show_hidden = EDITOR_GET("filesystem/file_dialog/show_hidden_files");
|
||||
updating = false;
|
||||
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
|
||||
TreeItem *ti = tree->create_item(p_item);
|
||||
@@ -78,6 +79,10 @@ void EditorDirDialog::reload(const String &p_path) {
|
||||
must_reload = false;
|
||||
}
|
||||
|
||||
bool EditorDirDialog::is_copy_pressed() const {
|
||||
return copy->is_pressed();
|
||||
}
|
||||
|
||||
void EditorDirDialog::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
@@ -107,6 +112,14 @@ void EditorDirDialog::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void EditorDirDialog::_copy_toggled(bool p_pressed) {
|
||||
if (p_pressed) {
|
||||
set_ok_button_text(TTR("Copy"));
|
||||
} else {
|
||||
set_ok_button_text(TTR("Move"));
|
||||
}
|
||||
}
|
||||
|
||||
void EditorDirDialog::_item_collapsed(Object *p_item) {
|
||||
TreeItem *item = Object::cast_to<TreeItem>(p_item);
|
||||
|
||||
@@ -172,8 +185,7 @@ void EditorDirDialog::_make_dir_confirm() {
|
||||
mkdirerr->popup_centered(Size2(250, 80) * EDSCALE);
|
||||
} else {
|
||||
opened_paths.insert(dir);
|
||||
//reload(dir.path_join(makedirname->get_text()));
|
||||
EditorFileSystem::get_singleton()->scan_changes(); //we created a dir, so rescan changes
|
||||
EditorFileSystem::get_singleton()->scan_changes(); // We created a dir, so rescan changes.
|
||||
}
|
||||
makedirname->set_text(""); // reset label
|
||||
}
|
||||
@@ -186,11 +198,19 @@ EditorDirDialog::EditorDirDialog() {
|
||||
set_title(TTR("Choose a Directory"));
|
||||
set_hide_on_ok(false);
|
||||
|
||||
tree = memnew(Tree);
|
||||
add_child(tree);
|
||||
VBoxContainer *vb = memnew(VBoxContainer);
|
||||
add_child(vb);
|
||||
|
||||
tree = memnew(Tree);
|
||||
vb->add_child(tree);
|
||||
tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
tree->connect("item_activated", callable_mp(this, &EditorDirDialog::_item_activated));
|
||||
|
||||
copy = memnew(CheckBox);
|
||||
vb->add_child(copy);
|
||||
copy->set_text(TTR("Copy File(s)"));
|
||||
copy->connect("toggled", callable_mp(this, &EditorDirDialog::_copy_toggled));
|
||||
|
||||
makedir = add_button(TTR("Create Folder"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "makedir");
|
||||
makedir->connect("pressed", callable_mp(this, &EditorDirDialog::_make_dir));
|
||||
|
||||
@@ -200,7 +220,6 @@ EditorDirDialog::EditorDirDialog() {
|
||||
|
||||
VBoxContainer *makevb = memnew(VBoxContainer);
|
||||
makedialog->add_child(makevb);
|
||||
//makedialog->set_child_rect(makevb);
|
||||
|
||||
makedirname = memnew(LineEdit);
|
||||
makevb->add_margin_child(TTR("Name:"), makedirname);
|
||||
@@ -211,5 +230,5 @@ EditorDirDialog::EditorDirDialog() {
|
||||
mkdirerr->set_text(TTR("Could not create folder."));
|
||||
add_child(mkdirerr);
|
||||
|
||||
set_ok_button_text(TTR("Choose"));
|
||||
set_ok_button_text(TTR("Move"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user