From 0416e156120be942935ead91ff5040f806ef5a78 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 16 Aug 2021 09:43:03 +0200 Subject: [PATCH] Utils: Return FilePath from PathChooser::homePath() Change-Id: Ib67435cb828e6bb55f76bfd6eb13165f46922c00 Reviewed-by: David Schulz --- src/libs/utils/pathchooser.cpp | 6 +++--- src/libs/utils/pathchooser.h | 2 +- src/plugins/coreplugin/documentmanager.cpp | 4 ++-- src/plugins/git/gitplugin.cpp | 3 +-- src/plugins/incredibuild/buildconsolebuildstep.cpp | 6 +++--- src/plugins/incredibuild/commandbuilderaspect.cpp | 2 +- src/plugins/projectexplorer/makestep.cpp | 2 +- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index ab080c15d31..8ff224cf9ff 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -641,14 +641,14 @@ QString PathChooser::label() return tr("Path:"); } -QString PathChooser::homePath() +FilePath PathChooser::homePath() { // Return 'users//Documents' on Windows, since Windows explorer // does not let people actually display the contents of their home // directory. Alternatively, create a QtCreator-specific directory? if (HostOsInfo::isWindowsHost()) - return QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - return QDir::homePath(); + return FilePath::fromString(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); + return FilePath::fromString(QDir::homePath()); } /*! diff --git a/src/libs/utils/pathchooser.h b/src/libs/utils/pathchooser.h index a12542006a7..288d370bdaa 100644 --- a/src/libs/utils/pathchooser.h +++ b/src/libs/utils/pathchooser.h @@ -110,7 +110,7 @@ public: void setValidationFunction(const FancyLineEdit::ValidationFunction &fn); /** Return the home directory, which needs some fixing under Windows. */ - static QString homePath(); + static FilePath homePath(); void addButton(const QString &text, QObject *context, const std::function &callback); void insertButton(int index, const QString &text, QObject *context, const std::function &callback); diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index ba73bd32845..0325665b783 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -1369,7 +1369,7 @@ void DocumentManager::saveSettings() s->beginGroup(directoryGroupC); s->setValueWithDefault(projectDirectoryKeyC, d->m_projectsDirectory.toString(), - PathChooser::homePath()); + PathChooser::homePath().toString()); s->setValueWithDefault(useProjectDirectoryKeyC, d->m_useProjectsDirectory, kUseProjectsDirectoryDefault); @@ -1400,7 +1400,7 @@ void readSettings() if (!settingsProjectDir.isEmpty() && settingsProjectDir.isDir()) d->m_projectsDirectory = settingsProjectDir; else - d->m_projectsDirectory = FilePath::fromString(PathChooser::homePath()); + d->m_projectsDirectory = PathChooser::homePath(); d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC), kUseProjectsDirectoryDefault).toBool(); diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 1d16a18c151..de1427e8398 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -1208,8 +1208,7 @@ void GitPluginPrivate::startChangeRelatedAction(const Id &id) { const VcsBasePluginState state = currentState(); - ChangeSelectionDialog dialog(state.hasTopLevel() - ? state.topLevel() : FilePath::fromString(PathChooser::homePath()), + ChangeSelectionDialog dialog(state.hasTopLevel() ? state.topLevel() : PathChooser::homePath(), id, ICore::dialogParent()); int result = dialog.exec(); diff --git a/src/plugins/incredibuild/buildconsolebuildstep.cpp b/src/plugins/incredibuild/buildconsolebuildstep.cpp index 15948dfb8a1..9fcb058bd77 100644 --- a/src/plugins/incredibuild/buildconsolebuildstep.cpp +++ b/src/plugins/incredibuild/buildconsolebuildstep.cpp @@ -128,7 +128,7 @@ BuildConsoleBuildStep::BuildConsoleBuildStep(BuildStepList *buildStepList, Id id profileXml->setLabelText(tr("Profile.xml:")); profileXml->setDisplayStyle(StringAspect::PathChooserDisplay); profileXml->setExpectedKind(PathChooser::Kind::File); - profileXml->setBaseFileName(FilePath::fromString(PathChooser::homePath())); + profileXml->setBaseFileName(PathChooser::homePath()); profileXml->setHistoryCompleter("IncrediBuild.BuildConsole.ProfileXml.History"); profileXml->setToolTip(tr("Defines how Automatic " "Interception Interface should handle the various processes " @@ -190,7 +190,7 @@ BuildConsoleBuildStep::BuildConsoleBuildStep(BuildStepList *buildStepList, Id id monFile->setLabelText(tr("Save IncrediBuild monitor file:")); monFile->setDisplayStyle(StringAspect::PathChooserDisplay); monFile->setExpectedKind(PathChooser::Kind::Any); - monFile->setBaseFileName(FilePath::fromString(PathChooser::homePath())); + monFile->setBaseFileName(PathChooser::homePath()); monFile->setHistoryCompleter(QLatin1String("IncrediBuild.BuildConsole.MonFile.History")); monFile->setToolTip(tr("Writes a copy of the build progress file (.ib_mon) to the specified " "location. If only a folder name is given, a generated GUID will serve " @@ -207,7 +207,7 @@ BuildConsoleBuildStep::BuildConsoleBuildStep(BuildStepList *buildStepList, Id id logFile->setLabelText(tr("Output Log file:")); logFile->setDisplayStyle(StringAspect::PathChooserDisplay); logFile->setExpectedKind(PathChooser::Kind::SaveFile); - logFile->setBaseFileName(FilePath::fromString(PathChooser::homePath())); + logFile->setBaseFileName(PathChooser::homePath()); logFile->setHistoryCompleter(QLatin1String("IncrediBuild.BuildConsole.LogFile.History")); logFile->setToolTip(tr("Writes build output to a file.")); diff --git a/src/plugins/incredibuild/commandbuilderaspect.cpp b/src/plugins/incredibuild/commandbuilderaspect.cpp index 52353791a44..82abefa6339 100644 --- a/src/plugins/incredibuild/commandbuilderaspect.cpp +++ b/src/plugins/incredibuild/commandbuilderaspect.cpp @@ -150,7 +150,7 @@ void CommandBuilderAspect::addToLayout(LayoutBuilder &builder) if (!d->makePathChooser) { d->makePathChooser = new PathChooser; d->makePathChooser->setExpectedKind(PathChooser::Kind::ExistingCommand); - d->makePathChooser->setBaseDirectory(FilePath::fromString(PathChooser::homePath())); + d->makePathChooser->setBaseDirectory(PathChooser::homePath()); d->makePathChooser->setHistoryCompleter("IncrediBuild.BuildConsole.MakeCommand.History"); connect(d->makePathChooser, &PathChooser::rawPathChanged, this, [this] { d->m_activeCommandBuilder->setCommand(d->makePathChooser->rawPath()); diff --git a/src/plugins/projectexplorer/makestep.cpp b/src/plugins/projectexplorer/makestep.cpp index ad44e822fb4..b3e02633e16 100644 --- a/src/plugins/projectexplorer/makestep.cpp +++ b/src/plugins/projectexplorer/makestep.cpp @@ -75,7 +75,7 @@ MakeStep::MakeStep(BuildStepList *parent, Id id) m_makeCommandAspect->setSettingsKey(id.withSuffix(MAKE_COMMAND_SUFFIX).toString()); m_makeCommandAspect->setDisplayStyle(StringAspect::PathChooserDisplay); m_makeCommandAspect->setExpectedKind(PathChooser::ExistingCommand); - m_makeCommandAspect->setBaseFileName(FilePath::fromString(PathChooser::homePath())); + m_makeCommandAspect->setBaseFileName(PathChooser::homePath()); m_makeCommandAspect->setHistoryCompleter("PE.MakeCommand.History"); m_userArgumentsAspect = addAspect();