diff --git a/core/os/os.h b/core/os/os.h index c6a12dd933..a2617063a9 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -69,6 +69,11 @@ public: RENDERING_SOURCE_FALLBACK }; + enum PlatformString { + PLATFORM_STRING_FILE_MANAGER_OPEN, + PLATFORM_STRING_FILE_MANAGER_SHOW, + }; + private: static OS *singleton; static uint64_t target_ticks; @@ -391,6 +396,17 @@ public: // This is invoked by the GDExtensionManager after loading GDExtensions specified by the project. virtual void load_platform_gdextensions() const {} + virtual String get_platform_string(PlatformString p_platform_string) const { + switch (p_platform_string) { + case PlatformString::PLATFORM_STRING_FILE_MANAGER_OPEN: + return ETR("Open in File Manager"); + case PlatformString::PLATFORM_STRING_FILE_MANAGER_SHOW: + return ETR("Show in File Manager"); + default: + ERR_FAIL_V_MSG("", vformat("Couldn't find a string for platform string: %d.", p_platform_string)); + } + } + #ifdef TOOLS_ENABLED // Tests OpenGL context and Rendering Device simultaneous creation. This function is expected to crash on some NVIDIA drivers. virtual bool _test_create_rendering_device_and_gl(const String &p_display_driver) const { return true; } diff --git a/drivers/apple_embedded/os_apple_embedded.h b/drivers/apple_embedded/os_apple_embedded.h index 7dc1509409..1bab2bbda8 100644 --- a/drivers/apple_embedded/os_apple_embedded.h +++ b/drivers/apple_embedded/os_apple_embedded.h @@ -144,6 +144,17 @@ public: virtual bool request_permission(const String &p_name) override; virtual Vector get_granted_permissions() const override; + + virtual String get_platform_string(PlatformString p_platform_string) const override { + switch (p_platform_string) { + case OS::PlatformString::PLATFORM_STRING_FILE_MANAGER_OPEN: + return ETR("Open in Files"); + case OS::PlatformString::PLATFORM_STRING_FILE_MANAGER_SHOW: + return ETR("Show in Files"); + default: + return OS::get_platform_string(p_platform_string); + } + } }; #endif // APPLE_EMBEDDED_ENABLED diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index dc5889cf5d..6570a72622 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -2440,7 +2440,7 @@ Instead, use the monitors tab to obtain more precise VRAM usage. 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(OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_SHOW), VMEM_MENU_SHOW_IN_EXPLORER); vmem_item_menu->add_item(TTRC("View Owners..."), VMEM_MENU_OWNERS); add_child(vmem_item_menu); } diff --git a/editor/docks/filesystem_dock.cpp b/editor/docks/filesystem_dock.cpp index b472c7a8fe..35b8f11b7c 100644 --- a/editor/docks/filesystem_dock.cpp +++ b/editor/docks/filesystem_dock.cpp @@ -3652,7 +3652,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect } p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Filesystem")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_MENU_SHOW_IN_EXPLORER); - p_popup->set_item_text(p_popup->get_item_index(FILE_MENU_SHOW_IN_EXPLORER), is_directory ? TTRC("Open in File Manager") : TTRC("Show in File Manager")); + p_popup->set_item_text(p_popup->get_item_index(FILE_MENU_SHOW_IN_EXPLORER), is_directory ? OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_OPEN) : OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_SHOW)); #endif current_path = fpath; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index c688161151..4f562e7bc8 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -9193,7 +9193,7 @@ EditorNode::EditorNode() { } remove_android_build_template = memnew(ConfirmationDialog); - remove_android_build_template->set_ok_button_text(TTR("Show in File Manager")); + remove_android_build_template->set_ok_button_text(OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_OPEN)); remove_android_build_template->connect(SceneStringName(confirmed), callable_mp(this, &EditorNode::_android_explore_build_templates)); gui_base->add_child(remove_android_build_template); diff --git a/editor/gui/editor_quick_open_dialog.cpp b/editor/gui/editor_quick_open_dialog.cpp index e063ac5bc7..0aaca70ddd 100644 --- a/editor/gui/editor_quick_open_dialog.cpp +++ b/editor/gui/editor_quick_open_dialog.cpp @@ -363,7 +363,7 @@ QuickOpenResultContainer::QuickOpenResultContainer() { file_context_menu = memnew(PopupMenu); file_context_menu->add_item(TTR("Show in FileSystem"), FILE_SHOW_IN_FILESYSTEM); - file_context_menu->add_item(TTR("Show in File Manager"), FILE_SHOW_IN_FILE_MANAGER); + file_context_menu->add_item(OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_SHOW), FILE_SHOW_IN_FILE_MANAGER); file_context_menu->connect(SceneStringName(id_pressed), callable_mp(this, &QuickOpenResultContainer::_menu_option)); file_context_menu->hide(); scroll_container->add_child(file_context_menu); diff --git a/editor/project_manager/project_list.cpp b/editor/project_manager/project_list.cpp index 2fb9f4f2ec..bbbe0f537b 100644 --- a/editor/project_manager/project_list.cpp +++ b/editor/project_manager/project_list.cpp @@ -331,13 +331,13 @@ void ProjectListItemControl::set_is_missing(bool p_missing) { explore_button->set_button_icon(get_editor_theme_icon(SNAME("FileBroken"))); explore_button->set_tooltip_text(TTRC("Error: Project is missing on the filesystem.")); } else { -#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED) - explore_button->set_button_icon(get_editor_theme_icon(SNAME("Load"))); - explore_button->set_tooltip_text(TTRC("Show in File Manager")); -#else +#if defined(ANDROID_ENABLED) || defined(WEB_ENABLED) // Opening the system file manager is not supported on the Android and web editors. explore_button->hide(); -#endif +#else // !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED) + explore_button->set_button_icon(get_editor_theme_icon(SNAME("Load"))); + explore_button->set_tooltip_text(OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_OPEN)); +#endif // defined(ANDROID_ENABLED) || defined(WEB_ENABLED) } } @@ -1211,8 +1211,8 @@ void ProjectList::_open_menu(const Vector2 &p_at, Control *p_hb) { project_context_menu->add_item(TTRC("Run Project"), MENU_RUN); project_context_menu->add_separator(); #if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED) - project_context_menu->add_item(TTRC("Show in File Manager"), MENU_SHOW_IN_FILE_MANAGER); -#endif + project_context_menu->add_item(OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_OPEN), MENU_SHOW_IN_FILE_MANAGER); +#endif // !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED) project_context_menu->add_item(TTRC("Copy Path"), MENU_COPY_PATH); project_context_menu->add_separator(); project_context_menu->add_item(TTRC("Rename"), MENU_RENAME); diff --git a/modules/objectdb_profiler/editor/objectdb_profiler_panel.cpp b/modules/objectdb_profiler/editor/objectdb_profiler_panel.cpp index 16498a512a..78c7779623 100644 --- a/modules/objectdb_profiler/editor/objectdb_profiler_panel.cpp +++ b/modules/objectdb_profiler/editor/objectdb_profiler_panel.cpp @@ -272,7 +272,7 @@ void ObjectDBProfilerPanel::_snapshot_rmb(const Vector2 &p_pos, MouseButton p_bu rmb_menu->clear(false); rmb_menu->add_icon_item(get_editor_theme_icon(SNAME("Rename")), TTRC("Rename"), OdbProfilerMenuOptions::ODB_MENU_RENAME); - rmb_menu->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("Show in File Manager"), OdbProfilerMenuOptions::ODB_MENU_SHOW_IN_FOLDER); + rmb_menu->add_icon_item(get_editor_theme_icon(SNAME("Folder")), OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_OPEN), OdbProfilerMenuOptions::ODB_MENU_SHOW_IN_FOLDER); rmb_menu->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTRC("Delete"), OdbProfilerMenuOptions::ODB_MENU_DELETE); rmb_menu->set_position(snapshot_list->get_screen_position() + p_pos); diff --git a/platform/macos/os_macos.h b/platform/macos/os_macos.h index b171d88a7e..5c311d1f34 100644 --- a/platform/macos/os_macos.h +++ b/platform/macos/os_macos.h @@ -167,6 +167,17 @@ public: virtual void run() = 0; + virtual String get_platform_string(PlatformString p_platform_string) const override { + switch (p_platform_string) { + case OS::PlatformString::PLATFORM_STRING_FILE_MANAGER_OPEN: + return ETR("Open in Finder"); + case OS::PlatformString::PLATFORM_STRING_FILE_MANAGER_SHOW: + return ETR("Show in Finder"); + default: + return OS::get_platform_string(p_platform_string); + } + } + OS_MacOS(const char *p_execpath, int p_argc, char **p_argv); }; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 453f333449..ea1896318f 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -264,6 +264,17 @@ public: void set_main_window(HWND p_main_window) { main_window = p_main_window; } + virtual String get_platform_string(PlatformString p_platform_string) const override { + switch (p_platform_string) { + case OS::PlatformString::PLATFORM_STRING_FILE_MANAGER_OPEN: + return ETR("Open in File Explorer"); + case OS::PlatformString::PLATFORM_STRING_FILE_MANAGER_SHOW: + return ETR("Show in File Explorer"); + default: + return OS::get_platform_string(p_platform_string); + } + } + #ifdef TOOLS_ENABLED virtual bool _test_create_rendering_device_and_gl(const String &p_display_driver) const override; virtual bool _test_create_rendering_device(const String &p_display_driver) const override; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index d7326e9368..41960e93af 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -803,7 +803,7 @@ void FileDialog::_popup_menu(const Vector2 &p_pos, int p_for_item) { meta = file_list->get_item_metadata(p_for_item); } - item_menu->add_item((p_for_item == -1 || meta["dir"]) ? ETR("Open in File Manager") : ETR("Show in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); + item_menu->add_item((p_for_item == -1 || meta["dir"]) ? OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_OPEN) : OS::get_singleton()->get_platform_string(OS::PLATFORM_STRING_FILE_MANAGER_SHOW), ITEM_MENU_SHOW_IN_EXPLORER); item_menu->set_item_icon(-1, theme_cache.menu_show_in_file_manager); if (meta["bundle"]) { item_menu->add_item(ETR("Show Package Contents"), ITEM_MENU_SHOW_BUNDLE_CONTENT);