aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/coreplugin/fileutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/coreplugin/fileutils.cpp')
-rw-r--r--src/plugins/coreplugin/fileutils.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/plugins/coreplugin/fileutils.cpp b/src/plugins/coreplugin/fileutils.cpp
index 5712c9c8b5b..f7c7d4a759c 100644
--- a/src/plugins/coreplugin/fileutils.cpp
+++ b/src/plugins/coreplugin/fileutils.cpp
@@ -32,10 +32,28 @@
#include <QTextStream>
#include <QTextCodec>
+#ifdef Q_OS_WIN
+#ifdef QTCREATOR_PCH_H
+#define CALLBACK WINAPI
+#endif
+#include <qt_windows.h>
+#include <shlobj.h>
+#endif
+
using namespace Utils;
namespace Core {
+static FilePath windowsDirectory()
+{
+#ifdef Q_OS_WIN
+ wchar_t str[UNICODE_STRING_MAX_CHARS] = {};
+ if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_WINDOWS, nullptr, 0, str)))
+ return FilePath::fromUserInput(QString::fromUtf16(reinterpret_cast<char16_t *>(str)));
+#endif
+ return {};
+}
+
// Show error with option to open settings.
static void showGraphicalShellError(QWidget *parent, const QString &app, const QString &error)
{
@@ -56,13 +74,7 @@ void FileUtils::showInGraphicalShell(QWidget *parent, const FilePath &pathIn)
const QFileInfo fileInfo = pathIn.toFileInfo();
// Mac, Windows support folder or file.
if (HostOsInfo::isWindowsHost()) {
- const FilePath explorer = FilePath("explorer.exe").searchInPath();
- if (explorer.isEmpty()) {
- QMessageBox::warning(parent,
- Tr::tr("Launching Windows Explorer Failed"),
- Tr::tr("Could not find explorer.exe in path to launch Windows Explorer."));
- return;
- }
+ const FilePath explorer = windowsDirectory().pathAppended("explorer.exe");
QStringList param;
if (!pathIn.isDir())
param += QLatin1String("/select,");