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:
hjk
2023-08-17 12:51:13 +02:00
parent 3fa4fa5cf3
commit ec7abcf98c
14 changed files with 23 additions and 22 deletions

View File

@@ -1312,9 +1312,9 @@ void FilePathAspect::setValue(const QString &filePath, Announcement howToAnnounc
TypedAspect::setValue(filePath, howToAnnounce); TypedAspect::setValue(filePath, howToAnnounce);
} }
void FilePathAspect::setDefaultValue(const FilePath &filePath) void FilePathAspect::setDefaultValue(const QString &filePath)
{ {
TypedAspect::setDefaultValue(filePath.toUserOutput()); TypedAspect::setDefaultValue(filePath);
} }
/*! /*!

View File

@@ -592,7 +592,7 @@ public:
QString value() const; QString value() const;
void setValue(const FilePath &filePath, Announcement howToAnnounce = DoEmit); void setValue(const FilePath &filePath, Announcement howToAnnounce = DoEmit);
void setValue(const QString &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 setPromptDialogFilter(const QString &filter);
void setPromptDialogTitle(const QString &title); void setPromptDialogTitle(const QString &title);

View File

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

View File

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

View File

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

View File

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

View File

@@ -44,10 +44,10 @@ CppcheckSettings::CppcheckSettings()
if (HostOsInfo::isAnyUnixHost()) { if (HostOsInfo::isAnyUnixHost()) {
binary.setDefaultValue("cppcheck"); binary.setDefaultValue("cppcheck");
} else { } else {
FilePath programFiles = FilePath::fromUserInput(qtcEnvironmentVariable("PROGRAMFILES")); QString programFiles = qtcEnvironmentVariable("PROGRAMFILES");
if (programFiles.isEmpty()) if (programFiles.isEmpty())
programFiles = "C:/Program Files"; programFiles = "C:/Program Files";
binary.setDefaultValue(programFiles.pathAppended("Cppcheck/cppcheck.exe")); binary.setDefaultValue(programFiles + "/Cppcheck/cppcheck.exe");
} }
warning.setSettingsKey("warning"); warning.setSettingsKey("warning");

View File

@@ -49,7 +49,7 @@ DockerSettings::DockerSettings()
dockerBinaryPath.setExpectedKind(PathChooser::ExistingCommand); dockerBinaryPath.setExpectedKind(PathChooser::ExistingCommand);
dockerBinaryPath.setDefaultValue( dockerBinaryPath.setDefaultValue(
FilePath::fromString("docker").searchInPath(additionalPaths)); FilePath::fromString("docker").searchInPath(additionalPaths).toUserOutput());
dockerBinaryPath.setDisplayName(Tr::tr("Docker CLI")); dockerBinaryPath.setDisplayName(Tr::tr("Docker CLI"));
dockerBinaryPath.setHistoryCompleter("Docker.Command.History"); dockerBinaryPath.setHistoryCompleter("Docker.Command.History");
dockerBinaryPath.setLabelText(Tr::tr("Command:")); dockerBinaryPath.setLabelText(Tr::tr("Command:"));

View File

@@ -33,8 +33,8 @@ HaskellSettings::HaskellSettings()
// stack from brew or the installer script from https://docs.haskellstack.org // stack from brew or the installer script from https://docs.haskellstack.org
// install to /usr/local/bin. // install to /usr/local/bin.
stackPath.setDefaultValue(HostOsInfo::isAnyUnixHost() stackPath.setDefaultValue(HostOsInfo::isAnyUnixHost()
? FilePath::fromString("/usr/local/bin/stack") ? QLatin1String("/usr/local/bin/stack")
: FilePath::fromString("stack")); : QLatin1String("stack"));
setLayouter([this] { setLayouter([this] {
using namespace Layouting; using namespace Layouting;

View File

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

View File

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

View File

@@ -37,10 +37,10 @@ VcpkgSettings::VcpkgSettings()
vcpkgRoot.setExpectedKind(PathChooser::ExistingDirectory); vcpkgRoot.setExpectedKind(PathChooser::ExistingDirectory);
FilePath defaultPath = Environment::systemEnvironment().searchInPath(Constants::VCPKG_COMMAND) FilePath defaultPath = Environment::systemEnvironment().searchInPath(Constants::VCPKG_COMMAND)
.parentDir(); .parentDir();
if (!defaultPath.isDir()) if (defaultPath.isDir())
defaultPath = FilePath::fromUserInput(qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT)); defaultPath = FilePath::fromUserInput(qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT));
if (defaultPath.isDir()) if (defaultPath.isDir())
vcpkgRoot.setDefaultValue(defaultPath); vcpkgRoot.setDefaultValue(defaultPath.toUserOutput());
setLayouter([this] { setLayouter([this] {
using namespace Layouting; using namespace Layouting;

View File

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

View File

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