From c37fdd005529f1fbc19d974c62d617fe89dfe988 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Tue, 21 Apr 2020 20:12:50 +0200 Subject: [PATCH] Code review changes (comment added) Add a comment which describes that only the folder is opened without selecting any file. Also explain why it is only done like this for now. --- src/gui/FileBrowser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 29f25ec30..c976c39f6 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -692,6 +692,12 @@ void FileBrowserTreeWidget::openContainingFolder() { if (m_contextMenuItem) { + // Delegate to QDesktopServices::openUrl with the directory of the selected file. Please note that + // this will only open the directory but not select the file as this is much more complicated due + // to different implementations that are needed for different platforms (Linux/Windows/MacOS). + + // Using QDesktopServices::openUrl seems to be the most simple cross platform way which uses + // functionality that's already available in Qt. QFileInfo fileInfo(m_contextMenuItem->fullName()); QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.dir().path())); }