Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/data/file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,20 @@ void FileDialog::open(const std::string& title,

if (!fileName_.empty())
{

// NOTE: this is a fix for Linux to make sure that the file dialog opens
// inside (!) the folder of the last file. When providing a path to a folder
// with zenity on Linux, the file dialog does not open in that folder, but
// one level above. Specifying a path to a file makes the file dialog open
// in the folder with the file pre-selected.
#if __linux__
startPath = fileName_;
#else
const size_t sep = fileName_.find_last_of("/\\");
startPath = (sep == std::string::npos) ? pfd::path::home()
: fileName_.substr(0, sep);
#endif

}
if (startPath.empty())
startPath = pfd::path::home();
Expand Down
Loading