Utils: Use FilePath in FileUtils::showInGraphicalShell

Change-Id: I393f33a6a31fc6cee3c0a4b16c474247673af312
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2021-08-12 12:05:37 +02:00
parent 83ec50a374
commit ba745a45aa
7 changed files with 10 additions and 11 deletions

View File

@@ -650,7 +650,7 @@ void AndroidBuildApkStep::setupOutputFormatter(OutputFormatter *formatter)
void AndroidBuildApkStep::showInGraphicalShell() void AndroidBuildApkStep::showInGraphicalShell()
{ {
Core::FileUtils::showInGraphicalShell(Core::ICore::dialogParent(), m_packagePath); Core::FileUtils::showInGraphicalShell(Core::ICore::dialogParent(), FilePath::fromString(m_packagePath));
} }
QWidget *AndroidBuildApkStep::createConfigWidget() QWidget *AndroidBuildApkStep::createConfigWidget()

View File

@@ -327,7 +327,7 @@ void CorePlugin::addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QM
if (QDir().exists(pathChooser->filePath().toString())) { if (QDir().exists(pathChooser->filePath().toString())) {
auto *showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), menu); auto *showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), menu);
connect(showInGraphicalShell, &QAction::triggered, pathChooser, [pathChooser]() { connect(showInGraphicalShell, &QAction::triggered, pathChooser, [pathChooser]() {
Core::FileUtils::showInGraphicalShell(pathChooser, pathChooser->filePath().toString()); Core::FileUtils::showInGraphicalShell(pathChooser, pathChooser->filePath());
}); });
menu->insertAction(firstAction, showInGraphicalShell); menu->insertAction(firstAction, showInGraphicalShell);

View File

@@ -534,7 +534,7 @@ void EditorManagerPrivate::init()
return; return;
const FilePath fp = EditorManager::currentDocument()->filePath(); const FilePath fp = EditorManager::currentDocument()->filePath();
if (!fp.isEmpty()) if (!fp.isEmpty())
FileUtils::showInGraphicalShell(ICore::dialogParent(), fp.toString()); FileUtils::showInGraphicalShell(ICore::dialogParent(), fp);
}); });
//Save XXX Context Actions //Save XXX Context Actions
@@ -564,8 +564,7 @@ void EditorManagerPrivate::init()
connect(m_openGraphicalShellContextAction, &QAction::triggered, this, [this] { connect(m_openGraphicalShellContextAction, &QAction::triggered, this, [this] {
if (!m_contextMenuEntry || m_contextMenuEntry->fileName().isEmpty()) if (!m_contextMenuEntry || m_contextMenuEntry->fileName().isEmpty())
return; return;
FileUtils::showInGraphicalShell(ICore::dialogParent(), FileUtils::showInGraphicalShell(ICore::dialogParent(), m_contextMenuEntry->fileName());
m_contextMenuEntry->fileName().toString());
}); });
connect(m_openTerminalAction, &QAction::triggered, this, &EditorManagerPrivate::openTerminal); connect(m_openTerminalAction, &QAction::triggered, this, &EditorManagerPrivate::openTerminal);
connect(m_findInDirectoryAction, &QAction::triggered, connect(m_findInDirectoryAction, &QAction::triggered,

View File

@@ -70,9 +70,9 @@ static void showGraphicalShellError(QWidget *parent, const QString &app, const Q
ICore::showOptionsDialog(Constants::SETTINGS_ID_INTERFACE, parent); ICore::showOptionsDialog(Constants::SETTINGS_ID_INTERFACE, parent);
} }
void FileUtils::showInGraphicalShell(QWidget *parent, const QString &pathIn) void FileUtils::showInGraphicalShell(QWidget *parent, const FilePath &pathIn)
{ {
const QFileInfo fileInfo(pathIn); const QFileInfo fileInfo = pathIn.toFileInfo();
// Mac, Windows support folder or file. // Mac, Windows support folder or file.
if (HostOsInfo::isWindowsHost()) { if (HostOsInfo::isWindowsHost()) {
const FilePath explorer = Environment::systemEnvironment().searchInPath(QLatin1String("explorer.exe")); const FilePath explorer = Environment::systemEnvironment().searchInPath(QLatin1String("explorer.exe"));
@@ -85,7 +85,7 @@ void FileUtils::showInGraphicalShell(QWidget *parent, const QString &pathIn)
return; return;
} }
QStringList param; QStringList param;
if (!fileInfo.isDir()) if (!pathIn.isDir())
param += QLatin1String("/select,"); param += QLatin1String("/select,");
param += QDir::toNativeSeparators(fileInfo.canonicalFilePath()); param += QDir::toNativeSeparators(fileInfo.canonicalFilePath());
QProcess::startDetached(explorer.toString(), param); QProcess::startDetached(explorer.toString(), param);

View File

@@ -42,7 +42,7 @@ enum class HandleIncludeGuards { No, Yes };
struct CORE_EXPORT FileUtils struct CORE_EXPORT FileUtils
{ {
// Helpers for common directory browser options. // Helpers for common directory browser options.
static void showInGraphicalShell(QWidget *parent, const QString &path); static void showInGraphicalShell(QWidget *parent, const Utils::FilePath &path);
static void openTerminal(const Utils::FilePath &path); static void openTerminal(const Utils::FilePath &path);
static void openTerminal(const Utils::FilePath &path, const Utils::Environment &env); static void openTerminal(const Utils::FilePath &path, const Utils::Environment &env);
static QString msgFindInDirectory(); static QString msgFindInDirectory();

View File

@@ -3693,7 +3693,7 @@ void ProjectExplorerPluginPrivate::showInGraphicalShell()
{ {
Node *currentNode = ProjectTree::currentNode(); Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode, return); QTC_ASSERT(currentNode, return);
Core::FileUtils::showInGraphicalShell(ICore::dialogParent(), currentNode->path().toString()); Core::FileUtils::showInGraphicalShell(ICore::dialogParent(), currentNode->path());
} }
void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env) void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env)

View File

@@ -91,7 +91,7 @@ AssetExportDialog::AssetExportDialog(const Utils::FilePath &exportPath,
m_ui->exportPath->setPromptDialogFilter(tr("Metadata file (*.metadata)")); m_ui->exportPath->setPromptDialogFilter(tr("Metadata file (*.metadata)"));
m_ui->exportPath->lineEdit()->setReadOnly(true); m_ui->exportPath->lineEdit()->setReadOnly(true);
m_ui->exportPath->addButton(tr("Open"), this, [this]() { m_ui->exportPath->addButton(tr("Open"), this, [this]() {
Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), m_ui->exportPath->path()); Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), m_ui->exportPath->filePath());
}); });
auto optionsWidget = new QWidget; auto optionsWidget = new QWidget;