Răsfoiți Sursa

Merge pull request #4700 from Geequlim/filesystem-show_in_explore

Add 'Show In System' option into filesystem RMB menu
Rémi Verschelde 9 ani în urmă
părinte
comite
674cfe21d3
2 a modificat fișierele cu 18 adăugiri și 2 ștergeri
  1. 16 1
      tools/editor/scenes_dock.cpp
  2. 2 1
      tools/editor/scenes_dock.h

+ 16 - 1
tools/editor/scenes_dock.cpp

@@ -944,6 +944,7 @@ void ScenesDock::_file_option(int p_option) {
 	switch(p_option) {
 
 
+		case FILE_SHOW_IN_EXPLORER:
 		case FILE_OPEN: {
 			int idx=-1;
 			for(int i=0;i<files->get_item_count();i++) {
@@ -959,6 +960,17 @@ void ScenesDock::_file_option(int p_option) {
 
 
 			String path = files->get_item_metadata(idx);
+			if (p_option == FILE_SHOW_IN_EXPLORER) {
+				String dir = DirAccess::get_full_path("res://", DirAccess::ACCESS_FILESYSTEM);
+				const int res_begin = String("res://").length();
+				const int last_sep = path.find_last("/");
+				if (last_sep > res_begin) {
+					dir += "/";
+					dir += path.substr(res_begin, last_sep - res_begin);
+				}
+				OS::get_singleton()->shell_open(String("file://")+dir);
+				return;
+			}
 
 			if (path.ends_with("/")) {
 				if (path!="res://") {
@@ -1416,6 +1428,10 @@ void ScenesDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
 
 	file_options->add_item(TTR("Delete"),FILE_REMOVE);
 	//file_options->add_item(TTR("Info"),FILE_INFO);
+
+	file_options->add_separator();
+	file_options->add_item(TTR("Show In System"),FILE_SHOW_IN_EXPLORER);
+
 	file_options->set_pos(files->get_global_pos() + p_pos);
 	file_options->popup();
 
@@ -1635,4 +1651,3 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
 ScenesDock::~ScenesDock() {
 
 }
-

+ 2 - 1
tools/editor/scenes_dock.h

@@ -62,7 +62,8 @@ class ScenesDock : public VBoxContainer {
 		FILE_MOVE,
 		FILE_REMOVE,
 		FILE_REIMPORT,
-		FILE_INFO
+		FILE_INFO,
+		FILE_SHOW_IN_EXPLORER
 	};