Utils: Use FilePathAspect::setDefaultValue

... instead of StringAspect::setDefaultFilePath.

Closer to the intended uniform access.

Task-number: QTCREATORBUG-29167
Change-Id: I87df385ef98873a0955010149a9a9b09a5f29daf
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-06-29 16:45:11 +02:00
parent 72f269bf6a
commit 98bba063b6
14 changed files with 29 additions and 28 deletions

View File

@@ -873,11 +873,6 @@ void StringAspect::setFilePath(const FilePath &value)
setValue(value.toUserOutput());
}
void StringAspect::setDefaultFilePath(const FilePath &value)
{
setDefaultValue(value.toUserOutput());
}
PathChooser *StringAspect::pathChooser() const
{
return d->m_pathChooserDisplay.data();
@@ -1337,6 +1332,11 @@ void FilePathAspect::setValue(const FilePath &filePath)
StringAspect::setValue(filePath.toUserOutput());
}
void FilePathAspect::setDefaultValue(const FilePath &filePath)
{
StringAspect::setDefaultValue(filePath.toUserOutput());
}
/*!
\class Utils::ColorAspect
\inmodule QtCreator

View File

@@ -503,7 +503,6 @@ public:
FilePath filePath() const;
void setFilePath(const FilePath &value);
void setDefaultFilePath(const FilePath &value);
PathChooser *pathChooser() const; // Avoid to use.
@@ -524,6 +523,7 @@ public:
FilePath operator()() const { return filePath(); }
void setValue(const FilePath &filePath);
void setDefaultValue(const FilePath &filePath);
};
class QTCREATOR_UTILS_EXPORT IntegerAspect : public TypedAspect<qint64>

View File

@@ -209,7 +209,7 @@ CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Id id) :
m_stagingDir = addAspect<FilePathAspect>();
m_stagingDir->setSettingsKey(STAGING_DIR_KEY);
m_stagingDir->setLabelText(Tr::tr("Staging directory:"));
m_stagingDir->setDefaultValue(initialStagingDir(kit()));
m_stagingDir->setDefaultValue(FilePath::fromUserInput(initialStagingDir(kit())));
Kit *kit = buildConfiguration()->kit();
if (CMakeBuildConfiguration::isIos(kit)) {

View File

@@ -24,7 +24,7 @@ ConanSettings::ConanSettings()
conanFilePath.setSettingsKey("ConanFilePath");
conanFilePath.setExpectedKind(PathChooser::ExistingCommand);
conanFilePath.setDefaultValue(HostOsInfo::withExecutableSuffix("conan"));
conanFilePath.setDefaultValue(FilePath::fromString(HostOsInfo::withExecutableSuffix("conan")));
readSettings(Core::ICore::settings());
}

View File

@@ -47,7 +47,7 @@ CopilotSettings::CopilotSettings()
const FilePath distFromVim = findOrDefault(searchDirs, &FilePath::exists);
nodeJsPath.setExpectedKind(PathChooser::ExistingCommand);
nodeJsPath.setDefaultFilePath(nodeFromPath);
nodeJsPath.setDefaultValue(nodeFromPath);
nodeJsPath.setSettingsKey("Copilot.NodeJsPath");
nodeJsPath.setLabelText(Tr::tr("Node.js path:"));
nodeJsPath.setHistoryCompleter("Copilot.NodePath.History");
@@ -58,7 +58,7 @@ CopilotSettings::CopilotSettings()
"for installation instructions."));
distPath.setExpectedKind(PathChooser::File);
distPath.setDefaultFilePath(distFromVim);
distPath.setDefaultValue(distFromVim);
distPath.setSettingsKey("Copilot.DistPath");
distPath.setLabelText(Tr::tr("Path to agent.js:"));
distPath.setHistoryCompleter("Copilot.DistPath.History");

View File

@@ -22,7 +22,7 @@ FileShareProtocolSettings::FileShareProtocolSettings()
path.setSettingsKey("Path");
path.setExpectedKind(PathChooser::ExistingDirectory);
path.setDefaultValue(TemporaryDirectory::masterDirectoryPath());
path.setDefaultValue(TemporaryDirectory::masterDirectoryFilePath());
path.setLabelText(Tr::tr("&Path:"));
displayCount.setSettingsKey("DisplayCount");

View File

@@ -44,7 +44,7 @@ CppcheckOptions::CppcheckOptions()
FilePath programFiles = FilePath::fromUserInput(qtcEnvironmentVariable("PROGRAMFILES"));
if (programFiles.isEmpty())
programFiles = "C:/Program Files";
binary.setDefaultValue(programFiles.pathAppended("Cppcheck/cppcheck.exe").toString());
binary.setDefaultValue(programFiles.pathAppended("Cppcheck/cppcheck.exe"));
}
warning.setSettingsKey("warning");

View File

@@ -42,7 +42,7 @@ DockerSettings::DockerSettings()
additionalPaths.append("/usr/local/bin");
dockerBinaryPath.setExpectedKind(PathChooser::ExistingCommand);
dockerBinaryPath.setDefaultFilePath(
dockerBinaryPath.setDefaultValue(
FilePath::fromString("docker").searchInPath(additionalPaths));
dockerBinaryPath.setDisplayName(Tr::tr("Docker CLI"));
dockerBinaryPath.setHistoryCompleter("Docker.Command.History");

View File

@@ -37,7 +37,7 @@ HaskellSettings::HaskellSettings()
// stack from brew or the installer script from https://docs.haskellstack.org
// install to /usr/local/bin.
stackPath.setDefaultFilePath(HostOsInfo::isAnyUnixHost()
stackPath.setDefaultValue(HostOsInfo::isAnyUnixHost()
? FilePath::fromString("/usr/local/bin/stack")
: FilePath::fromString("stack"));

View File

@@ -36,8 +36,7 @@ PerforceSettings::PerforceSettings()
setAutoApply(false);
p4BinaryPath.setSettingsKey("Command");
p4BinaryPath.setDefaultValue(
Environment::systemEnvironment().searchInPath(defaultCommand()).toString());
p4BinaryPath.setDefaultValue(Environment::systemEnvironment().searchInPath(defaultCommand()));
p4BinaryPath.setHistoryCompleter("Perforce.Command.History");
p4BinaryPath.setExpectedKind(PathChooser::Command);
p4BinaryPath.setDisplayName(Tr::tr("Perforce Command"));

View File

@@ -49,17 +49,16 @@ static int defaultFontSize()
return 10;
}
static QString defaultShell()
static FilePath defaultShell()
{
if (HostOsInfo::isWindowsHost())
return qtcEnvironmentVariable("COMSPEC");
return FilePath::fromUserInput(qtcEnvironmentVariable("COMSPEC"));
QString defaultShell = qtcEnvironmentVariable("SHELL");
if (FilePath::fromUserInput(defaultShell).isExecutableFile())
FilePath defaultShell = FilePath::fromUserInput(qtcEnvironmentVariable("SHELL"));
if (defaultShell.isExecutableFile())
return defaultShell;
Utils::FilePath shPath = Utils::Environment::systemEnvironment().searchInPath("sh");
return shPath.nativePath();
return Environment::systemEnvironment().searchInPath("sh");
}
void setupColor(TerminalSettings *settings,

View File

@@ -15,6 +15,8 @@
#include <QDesktopServices>
#include <QToolButton>
using namespace Utils;
namespace Vcpkg::Internal {
static VcpkgSettings *theSettings = nullptr;
@@ -34,13 +36,14 @@ VcpkgSettings::VcpkgSettings()
setCategory(CMakeProjectManager::Constants::Settings::CATEGORY);
vcpkgRoot.setSettingsKey("VcpkgRoot");
vcpkgRoot.setExpectedKind(Utils::PathChooser::ExistingDirectory);
vcpkgRoot.setDefaultValue(Utils::qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT));
vcpkgRoot.setExpectedKind(PathChooser::ExistingDirectory);
vcpkgRoot.setDefaultValue(
FilePath::fromUserInput(qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT)));
setLayouter([this] {
using namespace Layouting;
auto websiteButton = new QToolButton;
websiteButton->setIcon(Utils::Icons::ONLINE.icon());
websiteButton->setIcon(Icons::ONLINE.icon());
websiteButton->setToolTip(Constants::WEBSITE_URL);
connect(websiteButton, &QAbstractButton::clicked, [] {
@@ -53,7 +56,7 @@ VcpkgSettings::VcpkgSettings()
Group {
title(Tr::tr("Vcpkg installation")),
Form {
Utils::PathChooser::label(),
PathChooser::label(),
Span { 2, Row { vcpkgRoot, websiteButton } },
},
},

View File

@@ -72,7 +72,7 @@ CommonVcsSettings::CommonVcsSettings()
sshPasswordPrompt.setSettingsKey("SshPasswordPrompt");
sshPasswordPrompt.setExpectedKind(PathChooser::ExistingCommand);
sshPasswordPrompt.setHistoryCompleter("Vcs.SshPrompt.History");
sshPasswordPrompt.setDefaultValue(sshPasswordPromptDefault());
sshPasswordPrompt.setDefaultValue(FilePath::fromUserInput(sshPasswordPromptDefault()));
sshPasswordPrompt.setLabelText(Tr::tr("&SSH prompt command:"));
sshPasswordPrompt.setToolTip(Tr::tr("Specifies a command that is executed to graphically prompt "
"for a password,\nshould a repository require SSH-authentication "

View File

@@ -63,7 +63,7 @@ WebAssemblySettings::WebAssemblySettings()
registerAspect(&emSdk);
emSdk.setSettingsKey("EmSdk");
emSdk.setExpectedKind(Utils::PathChooser::ExistingDirectory);
emSdk.setDefaultFilePath(FileUtils::homePath());
emSdk.setDefaultValue(FileUtils::homePath());
connect(this, &Utils::AspectContainer::applied, &WebAssemblyToolChain::registerToolChains);