Fix "Open Containing Folder" on Linux (#6469)

Fix "Open Containing Folder" on Linux (SoftFever/OrcaSlicer#6449)
This commit is contained in:
Noisyfox 2024-08-18 16:31:39 +08:00 committed by GitHub
parent 4dd7d79d76
commit 12c4ff0d93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -547,7 +547,7 @@ void desktop_open_datadir_folder()
#endif
}
void desktop_open_any_folder( const std::string path )
void desktop_open_any_folder( const std::string& path )
{
// Execute command to open a file explorer, platform dependent.
// FIXME: The const_casts aren't needed in wxWidgets 3.1, remove them when we upgrade.
@ -558,7 +558,14 @@ void desktop_open_any_folder( const std::string path )
#elif __APPLE__
openFolderForFile(from_u8(path));
#else
const char *argv[] = {"xdg-open", path.data(), nullptr};
// Orca#6449: Open containing dir instead of opening the file directly.
std::string new_path = path;
boost::filesystem::path p(new_path);
if (!fs::is_directory(p)) {
new_path = p.parent_path().string();
}
const char* argv[] = {"xdg-open", new_path.data(), nullptr};
// Check if we're running in an AppImage container, if so, we need to remove AppImage's env vars,
// because they may mess up the environment expected by the file manager.

View file

@ -83,7 +83,7 @@ extern void login();
// Ask the destop to open the datadir using the default file explorer.
extern void desktop_open_datadir_folder();
// Ask the destop to open one folder
extern void desktop_open_any_folder(const std::string path);
extern void desktop_open_any_folder(const std::string& path);
} // namespace GUI
} // namespace Slic3r