forked from qt-creator/qt-creator
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:
@@ -873,11 +873,6 @@ void StringAspect::setFilePath(const FilePath &value)
|
|||||||
setValue(value.toUserOutput());
|
setValue(value.toUserOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringAspect::setDefaultFilePath(const FilePath &value)
|
|
||||||
{
|
|
||||||
setDefaultValue(value.toUserOutput());
|
|
||||||
}
|
|
||||||
|
|
||||||
PathChooser *StringAspect::pathChooser() const
|
PathChooser *StringAspect::pathChooser() const
|
||||||
{
|
{
|
||||||
return d->m_pathChooserDisplay.data();
|
return d->m_pathChooserDisplay.data();
|
||||||
@@ -1337,6 +1332,11 @@ void FilePathAspect::setValue(const FilePath &filePath)
|
|||||||
StringAspect::setValue(filePath.toUserOutput());
|
StringAspect::setValue(filePath.toUserOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FilePathAspect::setDefaultValue(const FilePath &filePath)
|
||||||
|
{
|
||||||
|
StringAspect::setDefaultValue(filePath.toUserOutput());
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Utils::ColorAspect
|
\class Utils::ColorAspect
|
||||||
\inmodule QtCreator
|
\inmodule QtCreator
|
||||||
|
@@ -503,7 +503,6 @@ public:
|
|||||||
|
|
||||||
FilePath filePath() const;
|
FilePath filePath() const;
|
||||||
void setFilePath(const FilePath &value);
|
void setFilePath(const FilePath &value);
|
||||||
void setDefaultFilePath(const FilePath &value);
|
|
||||||
|
|
||||||
PathChooser *pathChooser() const; // Avoid to use.
|
PathChooser *pathChooser() const; // Avoid to use.
|
||||||
|
|
||||||
@@ -524,6 +523,7 @@ public:
|
|||||||
|
|
||||||
FilePath operator()() const { return filePath(); }
|
FilePath operator()() const { return filePath(); }
|
||||||
void setValue(const FilePath &filePath);
|
void setValue(const FilePath &filePath);
|
||||||
|
void setDefaultValue(const FilePath &filePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT IntegerAspect : public TypedAspect<qint64>
|
class QTCREATOR_UTILS_EXPORT IntegerAspect : public TypedAspect<qint64>
|
||||||
|
@@ -209,7 +209,7 @@ CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Id id) :
|
|||||||
m_stagingDir = addAspect<FilePathAspect>();
|
m_stagingDir = addAspect<FilePathAspect>();
|
||||||
m_stagingDir->setSettingsKey(STAGING_DIR_KEY);
|
m_stagingDir->setSettingsKey(STAGING_DIR_KEY);
|
||||||
m_stagingDir->setLabelText(Tr::tr("Staging directory:"));
|
m_stagingDir->setLabelText(Tr::tr("Staging directory:"));
|
||||||
m_stagingDir->setDefaultValue(initialStagingDir(kit()));
|
m_stagingDir->setDefaultValue(FilePath::fromUserInput(initialStagingDir(kit())));
|
||||||
|
|
||||||
Kit *kit = buildConfiguration()->kit();
|
Kit *kit = buildConfiguration()->kit();
|
||||||
if (CMakeBuildConfiguration::isIos(kit)) {
|
if (CMakeBuildConfiguration::isIos(kit)) {
|
||||||
|
@@ -24,7 +24,7 @@ ConanSettings::ConanSettings()
|
|||||||
|
|
||||||
conanFilePath.setSettingsKey("ConanFilePath");
|
conanFilePath.setSettingsKey("ConanFilePath");
|
||||||
conanFilePath.setExpectedKind(PathChooser::ExistingCommand);
|
conanFilePath.setExpectedKind(PathChooser::ExistingCommand);
|
||||||
conanFilePath.setDefaultValue(HostOsInfo::withExecutableSuffix("conan"));
|
conanFilePath.setDefaultValue(FilePath::fromString(HostOsInfo::withExecutableSuffix("conan")));
|
||||||
|
|
||||||
readSettings(Core::ICore::settings());
|
readSettings(Core::ICore::settings());
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,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.setDefaultFilePath(nodeFromPath);
|
nodeJsPath.setDefaultValue(nodeFromPath);
|
||||||
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");
|
||||||
@@ -58,7 +58,7 @@ CopilotSettings::CopilotSettings()
|
|||||||
"for installation instructions."));
|
"for installation instructions."));
|
||||||
|
|
||||||
distPath.setExpectedKind(PathChooser::File);
|
distPath.setExpectedKind(PathChooser::File);
|
||||||
distPath.setDefaultFilePath(distFromVim);
|
distPath.setDefaultValue(distFromVim);
|
||||||
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");
|
||||||
|
@@ -22,7 +22,7 @@ FileShareProtocolSettings::FileShareProtocolSettings()
|
|||||||
|
|
||||||
path.setSettingsKey("Path");
|
path.setSettingsKey("Path");
|
||||||
path.setExpectedKind(PathChooser::ExistingDirectory);
|
path.setExpectedKind(PathChooser::ExistingDirectory);
|
||||||
path.setDefaultValue(TemporaryDirectory::masterDirectoryPath());
|
path.setDefaultValue(TemporaryDirectory::masterDirectoryFilePath());
|
||||||
path.setLabelText(Tr::tr("&Path:"));
|
path.setLabelText(Tr::tr("&Path:"));
|
||||||
|
|
||||||
displayCount.setSettingsKey("DisplayCount");
|
displayCount.setSettingsKey("DisplayCount");
|
||||||
|
@@ -44,7 +44,7 @@ CppcheckOptions::CppcheckOptions()
|
|||||||
FilePath programFiles = FilePath::fromUserInput(qtcEnvironmentVariable("PROGRAMFILES"));
|
FilePath programFiles = FilePath::fromUserInput(qtcEnvironmentVariable("PROGRAMFILES"));
|
||||||
if (programFiles.isEmpty())
|
if (programFiles.isEmpty())
|
||||||
programFiles = "C:/Program Files";
|
programFiles = "C:/Program Files";
|
||||||
binary.setDefaultValue(programFiles.pathAppended("Cppcheck/cppcheck.exe").toString());
|
binary.setDefaultValue(programFiles.pathAppended("Cppcheck/cppcheck.exe"));
|
||||||
}
|
}
|
||||||
|
|
||||||
warning.setSettingsKey("warning");
|
warning.setSettingsKey("warning");
|
||||||
|
@@ -42,7 +42,7 @@ DockerSettings::DockerSettings()
|
|||||||
additionalPaths.append("/usr/local/bin");
|
additionalPaths.append("/usr/local/bin");
|
||||||
|
|
||||||
dockerBinaryPath.setExpectedKind(PathChooser::ExistingCommand);
|
dockerBinaryPath.setExpectedKind(PathChooser::ExistingCommand);
|
||||||
dockerBinaryPath.setDefaultFilePath(
|
dockerBinaryPath.setDefaultValue(
|
||||||
FilePath::fromString("docker").searchInPath(additionalPaths));
|
FilePath::fromString("docker").searchInPath(additionalPaths));
|
||||||
dockerBinaryPath.setDisplayName(Tr::tr("Docker CLI"));
|
dockerBinaryPath.setDisplayName(Tr::tr("Docker CLI"));
|
||||||
dockerBinaryPath.setHistoryCompleter("Docker.Command.History");
|
dockerBinaryPath.setHistoryCompleter("Docker.Command.History");
|
||||||
|
@@ -37,7 +37,7 @@ 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.setDefaultFilePath(HostOsInfo::isAnyUnixHost()
|
stackPath.setDefaultValue(HostOsInfo::isAnyUnixHost()
|
||||||
? FilePath::fromString("/usr/local/bin/stack")
|
? FilePath::fromString("/usr/local/bin/stack")
|
||||||
: FilePath::fromString("stack"));
|
: FilePath::fromString("stack"));
|
||||||
|
|
||||||
|
@@ -36,8 +36,7 @@ PerforceSettings::PerforceSettings()
|
|||||||
setAutoApply(false);
|
setAutoApply(false);
|
||||||
|
|
||||||
p4BinaryPath.setSettingsKey("Command");
|
p4BinaryPath.setSettingsKey("Command");
|
||||||
p4BinaryPath.setDefaultValue(
|
p4BinaryPath.setDefaultValue(Environment::systemEnvironment().searchInPath(defaultCommand()));
|
||||||
Environment::systemEnvironment().searchInPath(defaultCommand()).toString());
|
|
||||||
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"));
|
||||||
|
@@ -49,17 +49,16 @@ static int defaultFontSize()
|
|||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString defaultShell()
|
static FilePath defaultShell()
|
||||||
{
|
{
|
||||||
if (HostOsInfo::isWindowsHost())
|
if (HostOsInfo::isWindowsHost())
|
||||||
return qtcEnvironmentVariable("COMSPEC");
|
return FilePath::fromUserInput(qtcEnvironmentVariable("COMSPEC"));
|
||||||
|
|
||||||
QString defaultShell = qtcEnvironmentVariable("SHELL");
|
FilePath defaultShell = FilePath::fromUserInput(qtcEnvironmentVariable("SHELL"));
|
||||||
if (FilePath::fromUserInput(defaultShell).isExecutableFile())
|
if (defaultShell.isExecutableFile())
|
||||||
return defaultShell;
|
return defaultShell;
|
||||||
|
|
||||||
Utils::FilePath shPath = Utils::Environment::systemEnvironment().searchInPath("sh");
|
return Environment::systemEnvironment().searchInPath("sh");
|
||||||
return shPath.nativePath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupColor(TerminalSettings *settings,
|
void setupColor(TerminalSettings *settings,
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Vcpkg::Internal {
|
namespace Vcpkg::Internal {
|
||||||
|
|
||||||
static VcpkgSettings *theSettings = nullptr;
|
static VcpkgSettings *theSettings = nullptr;
|
||||||
@@ -34,13 +36,14 @@ VcpkgSettings::VcpkgSettings()
|
|||||||
setCategory(CMakeProjectManager::Constants::Settings::CATEGORY);
|
setCategory(CMakeProjectManager::Constants::Settings::CATEGORY);
|
||||||
|
|
||||||
vcpkgRoot.setSettingsKey("VcpkgRoot");
|
vcpkgRoot.setSettingsKey("VcpkgRoot");
|
||||||
vcpkgRoot.setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
vcpkgRoot.setExpectedKind(PathChooser::ExistingDirectory);
|
||||||
vcpkgRoot.setDefaultValue(Utils::qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT));
|
vcpkgRoot.setDefaultValue(
|
||||||
|
FilePath::fromUserInput(qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT)));
|
||||||
|
|
||||||
setLayouter([this] {
|
setLayouter([this] {
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
auto websiteButton = new QToolButton;
|
auto websiteButton = new QToolButton;
|
||||||
websiteButton->setIcon(Utils::Icons::ONLINE.icon());
|
websiteButton->setIcon(Icons::ONLINE.icon());
|
||||||
websiteButton->setToolTip(Constants::WEBSITE_URL);
|
websiteButton->setToolTip(Constants::WEBSITE_URL);
|
||||||
|
|
||||||
connect(websiteButton, &QAbstractButton::clicked, [] {
|
connect(websiteButton, &QAbstractButton::clicked, [] {
|
||||||
@@ -53,7 +56,7 @@ VcpkgSettings::VcpkgSettings()
|
|||||||
Group {
|
Group {
|
||||||
title(Tr::tr("Vcpkg installation")),
|
title(Tr::tr("Vcpkg installation")),
|
||||||
Form {
|
Form {
|
||||||
Utils::PathChooser::label(),
|
PathChooser::label(),
|
||||||
Span { 2, Row { vcpkgRoot, websiteButton } },
|
Span { 2, Row { vcpkgRoot, websiteButton } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -72,7 +72,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(sshPasswordPromptDefault());
|
sshPasswordPrompt.setDefaultValue(FilePath::fromUserInput(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 "
|
||||||
|
@@ -63,7 +63,7 @@ WebAssemblySettings::WebAssemblySettings()
|
|||||||
registerAspect(&emSdk);
|
registerAspect(&emSdk);
|
||||||
emSdk.setSettingsKey("EmSdk");
|
emSdk.setSettingsKey("EmSdk");
|
||||||
emSdk.setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
emSdk.setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||||
emSdk.setDefaultFilePath(FileUtils::homePath());
|
emSdk.setDefaultValue(FileUtils::homePath());
|
||||||
|
|
||||||
connect(this, &Utils::AspectContainer::applied, &WebAssemblyToolChain::registerToolChains);
|
connect(this, &Utils::AspectContainer::applied, &WebAssemblyToolChain::registerToolChains);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user