diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 9cb56cf2717..0d7d720e5c7 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -30,6 +30,7 @@ #include "script_editor_debugger.h" +#include "core/config/project_settings.h" #include "core/debugger/debugger_marshalls.h" #include "core/debugger/remote_debugger.h" #include "core/string/ustring.h" @@ -1113,6 +1114,8 @@ void ScriptEditorDebugger::_notification(int p_what) { vmem_notice_icon->set_texture(get_editor_theme_icon(SNAME("NodeInfo"))); vmem_refresh->set_button_icon(get_editor_theme_icon(SNAME("Reload"))); vmem_export->set_button_icon(get_editor_theme_icon(SNAME("Save"))); + vmem_item_menu->set_item_icon(VMEM_MENU_SHOW_IN_FILESYSTEM, get_editor_theme_icon(SNAME("ShowInFileSystem"))); + vmem_item_menu->set_item_icon(VMEM_MENU_SHOW_IN_EXPLORER, get_editor_theme_icon(SNAME("Filesystem"))); search->set_right_icon(get_editor_theme_icon(SNAME("Search"))); reason->add_theme_color_override(SNAME("default_color"), get_theme_color(SNAME("error_color"), EditorStringName(Editor))); @@ -1842,6 +1845,45 @@ void ScriptEditorDebugger::_vmem_item_activated() { FileSystemDock::get_singleton()->navigate_to_path(path); } +void ScriptEditorDebugger::_vmem_tree_rmb_selected(const Vector2 &p_pos, MouseButton p_button) { + if (p_button != MouseButton::RIGHT) { + return; + } + + TreeItem *item = vmem_tree->get_selected(); + if (!item) { + return; + } + + String path = item->get_text(0); + if (path.is_empty() || !FileAccess::exists(path)) { + return; + } + + vmem_item_menu->set_position(vmem_tree->get_screen_position() + p_pos); + vmem_item_menu->popup(); +} + +void ScriptEditorDebugger::_vmem_item_menu_id_pressed(int p_option) { + TreeItem *item = vmem_tree->get_selected(); + if (!item) { + return; + } + + String path = item->get_text(0); + switch (p_option) { + case VMEM_MENU_SHOW_IN_FILESYSTEM: { + FileSystemDock::get_singleton()->navigate_to_path(path); + } break; + case VMEM_MENU_SHOW_IN_EXPLORER: { + OS::get_singleton()->shell_show_in_file_manager(ProjectSettings::get_singleton()->globalize_path(path), true); + } break; + case VMEM_MENU_OWNERS: { + FileSystemDock::get_owners_dialog()->show(path); + } break; + } +} + void ScriptEditorDebugger::_clear_errors_list() { error_tree->clear(); error_count = 0; @@ -2383,9 +2425,17 @@ Instead, use the monitors tab to obtain more precise VRAM usage. vmem_tree->set_hide_root(true); vmem_tree->set_scroll_hint_mode(Tree::SCROLL_HINT_MODE_BOTTOM); mc->add_child(vmem_tree); + vmem_tree->set_allow_rmb_select(true); vmem_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_vmem_item_activated)); - + vmem_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_vmem_tree_rmb_selected)); tabs->add_child(vmem_vb); + + vmem_item_menu = memnew(PopupMenu); + vmem_item_menu->connect(SceneStringName(id_pressed), callable_mp(this, &ScriptEditorDebugger::_vmem_item_menu_id_pressed)); + vmem_item_menu->add_item(TTRC("Show in FileSystem"), VMEM_MENU_SHOW_IN_FILESYSTEM); + vmem_item_menu->add_item(TTRC("Show in File Manager"), VMEM_MENU_SHOW_IN_EXPLORER); + vmem_item_menu->add_item(TTRC("View Owners..."), VMEM_MENU_OWNERS); + add_child(vmem_item_menu); } { // misc diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index 7c07b89bce3..0d4faba98cc 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -83,6 +83,12 @@ private: ACTION_DELETE_ALL_BREAKPOINTS, }; + enum VMemMenu { + VMEM_MENU_SHOW_IN_FILESYSTEM, + VMEM_MENU_SHOW_IN_EXPLORER, + VMEM_MENU_OWNERS, + }; + AcceptDialog *msgdialog = nullptr; LineEdit *clicked_ctrl = nullptr; @@ -139,6 +145,7 @@ private: Button *vmem_export = nullptr; LineEdit *vmem_total = nullptr; TextureRect *vmem_notice_icon = nullptr; + PopupMenu *vmem_item_menu = nullptr; Tree *stack_dump = nullptr; LineEdit *search = nullptr; @@ -267,6 +274,8 @@ private: void _collapse_errors_list(); void _vmem_item_activated(); + void _vmem_tree_rmb_selected(const Vector2 &p_pos, MouseButton p_button); + void _vmem_item_menu_id_pressed(int p_option); void _profiler_activate(bool p_enable, int p_profiler); void _profiler_seeked(); diff --git a/editor/docks/filesystem_dock.h b/editor/docks/filesystem_dock.h index e88bf3552fd..e0aaeed7742 100644 --- a/editor/docks/filesystem_dock.h +++ b/editor/docks/filesystem_dock.h @@ -385,6 +385,7 @@ private: public: static FileSystemDock *get_singleton() { return singleton; } + static DependencyEditorOwners *get_owners_dialog() { return singleton->owners_editor; } protected: void _notification(int p_what);