Utils: Return FilePath from PathChooser::homePath()

Change-Id: Ib67435cb828e6bb55f76bfd6eb13165f46922c00
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-08-16 09:43:03 +02:00
parent 906348ed50
commit 0416e15612
7 changed files with 12 additions and 13 deletions

View File

@@ -641,14 +641,14 @@ QString PathChooser::label()
return tr("Path:"); return tr("Path:");
} }
QString PathChooser::homePath() FilePath PathChooser::homePath()
{ {
// Return 'users/<name>/Documents' on Windows, since Windows explorer // Return 'users/<name>/Documents' on Windows, since Windows explorer
// does not let people actually display the contents of their home // does not let people actually display the contents of their home
// directory. Alternatively, create a QtCreator-specific directory? // directory. Alternatively, create a QtCreator-specific directory?
if (HostOsInfo::isWindowsHost()) if (HostOsInfo::isWindowsHost())
return QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); return FilePath::fromString(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
return QDir::homePath(); return FilePath::fromString(QDir::homePath());
} }
/*! /*!

View File

@@ -110,7 +110,7 @@ public:
void setValidationFunction(const FancyLineEdit::ValidationFunction &fn); void setValidationFunction(const FancyLineEdit::ValidationFunction &fn);
/** Return the home directory, which needs some fixing under Windows. */ /** 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<void()> &callback); void addButton(const QString &text, QObject *context, const std::function<void()> &callback);
void insertButton(int index, const QString &text, QObject *context, const std::function<void()> &callback); void insertButton(int index, const QString &text, QObject *context, const std::function<void()> &callback);

View File

@@ -1369,7 +1369,7 @@ void DocumentManager::saveSettings()
s->beginGroup(directoryGroupC); s->beginGroup(directoryGroupC);
s->setValueWithDefault(projectDirectoryKeyC, s->setValueWithDefault(projectDirectoryKeyC,
d->m_projectsDirectory.toString(), d->m_projectsDirectory.toString(),
PathChooser::homePath()); PathChooser::homePath().toString());
s->setValueWithDefault(useProjectDirectoryKeyC, s->setValueWithDefault(useProjectDirectoryKeyC,
d->m_useProjectsDirectory, d->m_useProjectsDirectory,
kUseProjectsDirectoryDefault); kUseProjectsDirectoryDefault);
@@ -1400,7 +1400,7 @@ void readSettings()
if (!settingsProjectDir.isEmpty() && settingsProjectDir.isDir()) if (!settingsProjectDir.isEmpty() && settingsProjectDir.isDir())
d->m_projectsDirectory = settingsProjectDir; d->m_projectsDirectory = settingsProjectDir;
else else
d->m_projectsDirectory = FilePath::fromString(PathChooser::homePath()); d->m_projectsDirectory = PathChooser::homePath();
d->m_useProjectsDirectory d->m_useProjectsDirectory
= s->value(QLatin1String(useProjectDirectoryKeyC), kUseProjectsDirectoryDefault).toBool(); = s->value(QLatin1String(useProjectDirectoryKeyC), kUseProjectsDirectoryDefault).toBool();

View File

@@ -1208,8 +1208,7 @@ void GitPluginPrivate::startChangeRelatedAction(const Id &id)
{ {
const VcsBasePluginState state = currentState(); const VcsBasePluginState state = currentState();
ChangeSelectionDialog dialog(state.hasTopLevel() ChangeSelectionDialog dialog(state.hasTopLevel() ? state.topLevel() : PathChooser::homePath(),
? state.topLevel() : FilePath::fromString(PathChooser::homePath()),
id, ICore::dialogParent()); id, ICore::dialogParent());
int result = dialog.exec(); int result = dialog.exec();

View File

@@ -128,7 +128,7 @@ BuildConsoleBuildStep::BuildConsoleBuildStep(BuildStepList *buildStepList, Id id
profileXml->setLabelText(tr("Profile.xml:")); profileXml->setLabelText(tr("Profile.xml:"));
profileXml->setDisplayStyle(StringAspect::PathChooserDisplay); profileXml->setDisplayStyle(StringAspect::PathChooserDisplay);
profileXml->setExpectedKind(PathChooser::Kind::File); profileXml->setExpectedKind(PathChooser::Kind::File);
profileXml->setBaseFileName(FilePath::fromString(PathChooser::homePath())); profileXml->setBaseFileName(PathChooser::homePath());
profileXml->setHistoryCompleter("IncrediBuild.BuildConsole.ProfileXml.History"); profileXml->setHistoryCompleter("IncrediBuild.BuildConsole.ProfileXml.History");
profileXml->setToolTip(tr("Defines how Automatic " profileXml->setToolTip(tr("Defines how Automatic "
"Interception Interface should handle the various processes " "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->setLabelText(tr("Save IncrediBuild monitor file:"));
monFile->setDisplayStyle(StringAspect::PathChooserDisplay); monFile->setDisplayStyle(StringAspect::PathChooserDisplay);
monFile->setExpectedKind(PathChooser::Kind::Any); monFile->setExpectedKind(PathChooser::Kind::Any);
monFile->setBaseFileName(FilePath::fromString(PathChooser::homePath())); monFile->setBaseFileName(PathChooser::homePath());
monFile->setHistoryCompleter(QLatin1String("IncrediBuild.BuildConsole.MonFile.History")); monFile->setHistoryCompleter(QLatin1String("IncrediBuild.BuildConsole.MonFile.History"));
monFile->setToolTip(tr("Writes a copy of the build progress file (.ib_mon) to the specified " 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 " "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->setLabelText(tr("Output Log file:"));
logFile->setDisplayStyle(StringAspect::PathChooserDisplay); logFile->setDisplayStyle(StringAspect::PathChooserDisplay);
logFile->setExpectedKind(PathChooser::Kind::SaveFile); logFile->setExpectedKind(PathChooser::Kind::SaveFile);
logFile->setBaseFileName(FilePath::fromString(PathChooser::homePath())); logFile->setBaseFileName(PathChooser::homePath());
logFile->setHistoryCompleter(QLatin1String("IncrediBuild.BuildConsole.LogFile.History")); logFile->setHistoryCompleter(QLatin1String("IncrediBuild.BuildConsole.LogFile.History"));
logFile->setToolTip(tr("Writes build output to a file.")); logFile->setToolTip(tr("Writes build output to a file."));

View File

@@ -150,7 +150,7 @@ void CommandBuilderAspect::addToLayout(LayoutBuilder &builder)
if (!d->makePathChooser) { if (!d->makePathChooser) {
d->makePathChooser = new PathChooser; d->makePathChooser = new PathChooser;
d->makePathChooser->setExpectedKind(PathChooser::Kind::ExistingCommand); 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"); d->makePathChooser->setHistoryCompleter("IncrediBuild.BuildConsole.MakeCommand.History");
connect(d->makePathChooser, &PathChooser::rawPathChanged, this, [this] { connect(d->makePathChooser, &PathChooser::rawPathChanged, this, [this] {
d->m_activeCommandBuilder->setCommand(d->makePathChooser->rawPath()); d->m_activeCommandBuilder->setCommand(d->makePathChooser->rawPath());

View File

@@ -75,7 +75,7 @@ MakeStep::MakeStep(BuildStepList *parent, Id id)
m_makeCommandAspect->setSettingsKey(id.withSuffix(MAKE_COMMAND_SUFFIX).toString()); m_makeCommandAspect->setSettingsKey(id.withSuffix(MAKE_COMMAND_SUFFIX).toString());
m_makeCommandAspect->setDisplayStyle(StringAspect::PathChooserDisplay); m_makeCommandAspect->setDisplayStyle(StringAspect::PathChooserDisplay);
m_makeCommandAspect->setExpectedKind(PathChooser::ExistingCommand); m_makeCommandAspect->setExpectedKind(PathChooser::ExistingCommand);
m_makeCommandAspect->setBaseFileName(FilePath::fromString(PathChooser::homePath())); m_makeCommandAspect->setBaseFileName(PathChooser::homePath());
m_makeCommandAspect->setHistoryCompleter("PE.MakeCommand.History"); m_makeCommandAspect->setHistoryCompleter("PE.MakeCommand.History");
m_userArgumentsAspect = addAspect<StringAspect>(); m_userArgumentsAspect = addAspect<StringAspect>();