forked from qt-creator/qt-creator
Utils: Make FilePathAspect::setDefaultValue take a QString
This sets the unexpanded value, so going to a "cooked" FilePath can at least theoretically break. On the user side it saves a roundtrip in a few cases, but is more ugly when the input is already a proper FilePath. Change-Id: I8a7e8f6d46fcc34c96b55e41d656dca933fbef4e Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -1312,9 +1312,9 @@ void FilePathAspect::setValue(const QString &filePath, Announcement howToAnnounc
|
||||
TypedAspect::setValue(filePath, howToAnnounce);
|
||||
}
|
||||
|
||||
void FilePathAspect::setDefaultValue(const FilePath &filePath)
|
||||
void FilePathAspect::setDefaultValue(const QString &filePath)
|
||||
{
|
||||
TypedAspect::setDefaultValue(filePath.toUserOutput());
|
||||
TypedAspect::setDefaultValue(filePath);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -592,7 +592,7 @@ public:
|
||||
QString value() const;
|
||||
void setValue(const FilePath &filePath, Announcement howToAnnounce = DoEmit);
|
||||
void setValue(const QString &filePath, Announcement howToAnnounce = DoEmit);
|
||||
void setDefaultValue(const FilePath &filePath);
|
||||
void setDefaultValue(const QString &filePath);
|
||||
|
||||
void setPromptDialogFilter(const QString &filter);
|
||||
void setPromptDialogTitle(const QString &title);
|
||||
|
||||
@@ -222,7 +222,7 @@ CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Id id) :
|
||||
|
||||
stagingDir.setSettingsKey(STAGING_DIR_KEY);
|
||||
stagingDir.setLabelText(Tr::tr("Staging directory:"));
|
||||
stagingDir.setDefaultValue(FilePath::fromUserInput(initialStagingDir(kit())));
|
||||
stagingDir.setDefaultValue(initialStagingDir(kit()));
|
||||
|
||||
Kit *kit = buildConfiguration()->kit();
|
||||
if (CMakeBuildConfiguration::isIos(kit)) {
|
||||
|
||||
@@ -22,7 +22,7 @@ ConanSettings::ConanSettings()
|
||||
|
||||
conanFilePath.setSettingsKey("ConanFilePath");
|
||||
conanFilePath.setExpectedKind(PathChooser::ExistingCommand);
|
||||
conanFilePath.setDefaultValue(FilePath::fromString(HostOsInfo::withExecutableSuffix("conan")));
|
||||
conanFilePath.setDefaultValue(HostOsInfo::withExecutableSuffix("conan"));
|
||||
|
||||
readSettings();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ CopilotSettings::CopilotSettings()
|
||||
const FilePath distFromVim = findOrDefault(searchDirs, &FilePath::exists);
|
||||
|
||||
nodeJsPath.setExpectedKind(PathChooser::ExistingCommand);
|
||||
nodeJsPath.setDefaultValue(nodeFromPath);
|
||||
nodeJsPath.setDefaultValue(nodeFromPath.toUserOutput());
|
||||
nodeJsPath.setSettingsKey("Copilot.NodeJsPath");
|
||||
nodeJsPath.setLabelText(Tr::tr("Node.js path:"));
|
||||
nodeJsPath.setHistoryCompleter("Copilot.NodePath.History");
|
||||
@@ -66,7 +66,7 @@ CopilotSettings::CopilotSettings()
|
||||
"for installation instructions."));
|
||||
|
||||
distPath.setExpectedKind(PathChooser::File);
|
||||
distPath.setDefaultValue(distFromVim);
|
||||
distPath.setDefaultValue(distFromVim.toUserOutput());
|
||||
distPath.setSettingsKey("Copilot.DistPath");
|
||||
distPath.setLabelText(Tr::tr("Path to agent.js:"));
|
||||
distPath.setHistoryCompleter("Copilot.DistPath.History");
|
||||
|
||||
@@ -26,7 +26,7 @@ FileShareProtocolSettings::FileShareProtocolSettings()
|
||||
|
||||
path.setSettingsKey("Path");
|
||||
path.setExpectedKind(PathChooser::ExistingDirectory);
|
||||
path.setDefaultValue(TemporaryDirectory::masterDirectoryFilePath());
|
||||
path.setDefaultValue(TemporaryDirectory::masterDirectoryPath());
|
||||
path.setLabelText(Tr::tr("&Path:"));
|
||||
|
||||
displayCount.setSettingsKey("DisplayCount");
|
||||
|
||||
@@ -44,10 +44,10 @@ CppcheckSettings::CppcheckSettings()
|
||||
if (HostOsInfo::isAnyUnixHost()) {
|
||||
binary.setDefaultValue("cppcheck");
|
||||
} else {
|
||||
FilePath programFiles = FilePath::fromUserInput(qtcEnvironmentVariable("PROGRAMFILES"));
|
||||
QString programFiles = qtcEnvironmentVariable("PROGRAMFILES");
|
||||
if (programFiles.isEmpty())
|
||||
programFiles = "C:/Program Files";
|
||||
binary.setDefaultValue(programFiles.pathAppended("Cppcheck/cppcheck.exe"));
|
||||
binary.setDefaultValue(programFiles + "/Cppcheck/cppcheck.exe");
|
||||
}
|
||||
|
||||
warning.setSettingsKey("warning");
|
||||
|
||||
@@ -49,7 +49,7 @@ DockerSettings::DockerSettings()
|
||||
|
||||
dockerBinaryPath.setExpectedKind(PathChooser::ExistingCommand);
|
||||
dockerBinaryPath.setDefaultValue(
|
||||
FilePath::fromString("docker").searchInPath(additionalPaths));
|
||||
FilePath::fromString("docker").searchInPath(additionalPaths).toUserOutput());
|
||||
dockerBinaryPath.setDisplayName(Tr::tr("Docker CLI"));
|
||||
dockerBinaryPath.setHistoryCompleter("Docker.Command.History");
|
||||
dockerBinaryPath.setLabelText(Tr::tr("Command:"));
|
||||
|
||||
@@ -33,8 +33,8 @@ HaskellSettings::HaskellSettings()
|
||||
// stack from brew or the installer script from https://docs.haskellstack.org
|
||||
// install to /usr/local/bin.
|
||||
stackPath.setDefaultValue(HostOsInfo::isAnyUnixHost()
|
||||
? FilePath::fromString("/usr/local/bin/stack")
|
||||
: FilePath::fromString("stack"));
|
||||
? QLatin1String("/usr/local/bin/stack")
|
||||
: QLatin1String("stack"));
|
||||
|
||||
setLayouter([this] {
|
||||
using namespace Layouting;
|
||||
|
||||
@@ -42,7 +42,8 @@ PerforceSettings::PerforceSettings()
|
||||
setAutoApply(false);
|
||||
|
||||
p4BinaryPath.setSettingsKey("Command");
|
||||
p4BinaryPath.setDefaultValue(Environment::systemEnvironment().searchInPath(defaultCommand()));
|
||||
p4BinaryPath.setDefaultValue(
|
||||
Environment::systemEnvironment().searchInPath(defaultCommand()).toUserOutput());
|
||||
p4BinaryPath.setHistoryCompleter("Perforce.Command.History");
|
||||
p4BinaryPath.setExpectedKind(PathChooser::Command);
|
||||
p4BinaryPath.setDisplayName(Tr::tr("Perforce Command"));
|
||||
|
||||
@@ -50,16 +50,16 @@ static int defaultFontSize()
|
||||
return 10;
|
||||
}
|
||||
|
||||
static FilePath defaultShell()
|
||||
static QString defaultShell()
|
||||
{
|
||||
if (HostOsInfo::isWindowsHost())
|
||||
return FilePath::fromUserInput(qtcEnvironmentVariable("COMSPEC"));
|
||||
return qtcEnvironmentVariable("COMSPEC");
|
||||
|
||||
FilePath defaultShell = FilePath::fromUserInput(qtcEnvironmentVariable("SHELL"));
|
||||
if (defaultShell.isExecutableFile())
|
||||
return defaultShell;
|
||||
return defaultShell.toUserOutput();
|
||||
|
||||
return Environment::systemEnvironment().searchInPath("sh");
|
||||
return Environment::systemEnvironment().searchInPath("sh").toUserOutput();
|
||||
}
|
||||
|
||||
void setupColor(TerminalSettings *settings,
|
||||
|
||||
@@ -37,10 +37,10 @@ VcpkgSettings::VcpkgSettings()
|
||||
vcpkgRoot.setExpectedKind(PathChooser::ExistingDirectory);
|
||||
FilePath defaultPath = Environment::systemEnvironment().searchInPath(Constants::VCPKG_COMMAND)
|
||||
.parentDir();
|
||||
if (!defaultPath.isDir())
|
||||
if (defaultPath.isDir())
|
||||
defaultPath = FilePath::fromUserInput(qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT));
|
||||
if (defaultPath.isDir())
|
||||
vcpkgRoot.setDefaultValue(defaultPath);
|
||||
vcpkgRoot.setDefaultValue(defaultPath.toUserOutput());
|
||||
|
||||
setLayouter([this] {
|
||||
using namespace Layouting;
|
||||
|
||||
@@ -66,7 +66,7 @@ CommonVcsSettings::CommonVcsSettings()
|
||||
sshPasswordPrompt.setSettingsKey("SshPasswordPrompt");
|
||||
sshPasswordPrompt.setExpectedKind(PathChooser::ExistingCommand);
|
||||
sshPasswordPrompt.setHistoryCompleter("Vcs.SshPrompt.History");
|
||||
sshPasswordPrompt.setDefaultValue(FilePath::fromUserInput(sshPasswordPromptDefault()));
|
||||
sshPasswordPrompt.setDefaultValue(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 "
|
||||
|
||||
@@ -56,7 +56,7 @@ WebAssemblySettings::WebAssemblySettings()
|
||||
|
||||
emSdk.setSettingsKey("EmSdk");
|
||||
emSdk.setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||
emSdk.setDefaultValue(FileUtils::homePath());
|
||||
emSdk.setDefaultValue(QDir::homePath());
|
||||
|
||||
connect(this, &Utils::AspectContainer::applied, &WebAssemblyToolChain::registerToolChains);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user