Unify key names for various fields in stored RunConfigurations

This replaces various versions of the key name of the arguments,
working directory, use terminal and use dyld image suffix fields
by unified versions ("RunConfiguration.Arguments",
"RunConfiguration.WorkingDirectory", "RunConfiguration.UseTerminal",
"RunConfiguration.UseDyldImageSuffix").

The different names for the fields are technically not needed
(as proven by several cases that already now used the same key),
partially outdated ("Qt4ProjectManager.MaemoRunConfiguration.Arguments")
make RunConfiguration constructors less uniform and more complex
than needed.

The "RunConfiguration." prefix in the new names is not needed, but used
by several other settings, so having it there looks more uniform now.

In (the unexpected case) that different keys would ever be necessary,
the default key name could still be overridden by using setSettingsKey
from user code.

Change-Id: Ifb74ad74e0a9c724c8bf5e71e1bb2424d5d1831b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2018-07-30 13:10:38 +02:00
parent 9f9c72302f
commit 98f3b961c6
15 changed files with 126 additions and 58 deletions

View File

@@ -49,8 +49,8 @@ BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(Target *target,
exeAspect->setExpectedKind(PathChooser::Any);
addExtraAspect(exeAspect);
addExtraAspect(new ArgumentsAspect(this, "Qt4ProjectManager.MaemoRunConfiguration.Arguments"));
addExtraAspect(new WorkingDirectoryAspect(this, "BareMetal.RunConfig.WorkingDirectory"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new WorkingDirectoryAspect(this));
setDefaultDisplayName(RunConfigurationFactory::decoratedTargetName(tr("Custom Executable"), target));
}

View File

@@ -48,8 +48,8 @@ BareMetalRunConfiguration::BareMetalRunConfiguration(Target *target, Core::Id id
exeAspect->setPlaceHolderText(tr("Unknown"));
addExtraAspect(exeAspect);
addExtraAspect(new ArgumentsAspect(this, "Qt4ProjectManager.MaemoRunConfiguration.Arguments"));
addExtraAspect(new WorkingDirectoryAspect(this, "BareMetal.RunConfig.WorkingDirectory"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new WorkingDirectoryAspect(this));
connect(target, &Target::deploymentDataChanged,
this, &BareMetalRunConfiguration::updateTargetInformation);

View File

@@ -55,9 +55,9 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *target, Core::Id id)
};
addExtraAspect(new LocalEnvironmentAspect(this, cmakeRunEnvironmentModifier));
addExtraAspect(new ExecutableAspect(this));
addExtraAspect(new ArgumentsAspect(this, "CMakeProjectManager.CMakeRunConfiguration.Arguments"));
addExtraAspect(new TerminalAspect(this, "CMakeProjectManager.CMakeRunConfiguration.UseTerminal"));
addExtraAspect(new WorkingDirectoryAspect(this, "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new TerminalAspect(this));
addExtraAspect(new WorkingDirectoryAspect(this));
connect(target->project(), &Project::parsingFinished,
this, &CMakeRunConfiguration::updateTargetInformation);

View File

@@ -97,7 +97,7 @@ private:
IosRunConfiguration::IosRunConfiguration(Target *target, Core::Id id)
: RunConfiguration(target, id)
{
addExtraAspect(new ArgumentsAspect(this, "Ios.run_arguments"));
addExtraAspect(new ArgumentsAspect(this));
setOutputFormatter<QtSupport::QtOutputFormatter>();
connect(DeviceManager::instance(), &DeviceManager::updated,

View File

@@ -45,10 +45,10 @@ NimRunConfiguration::NimRunConfiguration(Target *target, Core::Id id)
: RunConfiguration(target, id)
{
addExtraAspect(new ExecutableAspect(this));
addExtraAspect(new ArgumentsAspect(this, "Nim.NimRunConfiguration.ArgumentAspect"));
addExtraAspect(new WorkingDirectoryAspect(this, "Nim.NimRunConfiguration.WorkingDirectoryAspect"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new WorkingDirectoryAspect(this));
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
addExtraAspect(new TerminalAspect(this, "Nim.NimRunConfiguration.TerminalAspect"));
addExtraAspect(new TerminalAspect(this));
setDisplayName(tr("Current Build Target"));
setDefaultDisplayName(tr("Current Build Target"));

View File

@@ -86,10 +86,7 @@ private:
CustomExecutableDialog::CustomExecutableDialog(RunConfiguration *rc)
: QDialog(Core::ICore::dialogParent()),
m_rc(rc),
m_arguments(rc, rc->extraAspect<ArgumentsAspect>()->settingsKey()),
m_workingDirectory(rc, rc->extraAspect<WorkingDirectoryAspect>()->settingsKey()),
m_terminal(rc, rc->extraAspect<TerminalAspect>()->settingsKey())
m_rc(rc), m_arguments(rc), m_workingDirectory(rc), m_terminal(rc)
{
auto vbox = new QVBoxLayout(this);
vbox->addWidget(new QLabel(tr("Could not find the executable, please specify one.")));
@@ -189,9 +186,9 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe
exeAspect->setEnvironment(envAspect->environment());
addExtraAspect(exeAspect);
addExtraAspect(new ArgumentsAspect(this, "ProjectExplorer.CustomExecutableRunConfiguration.Arguments"));
addExtraAspect(new TerminalAspect(this, "ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal"));
addExtraAspect(new WorkingDirectoryAspect(this, "ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new TerminalAspect(this));
addExtraAspect(new WorkingDirectoryAspect(this));
connect(envAspect, &EnvironmentAspect::environmentChanged,
this, [exeAspect, envAspect] { exeAspect->setEnvironment(envAspect->environment()); });

View File

@@ -51,12 +51,12 @@ namespace ProjectExplorer {
\class ProjectExplorer::TerminalAspect
*/
TerminalAspect::TerminalAspect(RunConfiguration *runConfig, const QString &key, bool useTerminal) :
TerminalAspect::TerminalAspect(RunConfiguration *runConfig, bool useTerminal) :
IRunConfigurationAspect(runConfig), m_useTerminal(useTerminal)
{
setDisplayName(tr("Terminal"));
setId("TerminalAspect");
setSettingsKey(key);
setSettingsKey("RunConfiguration.UseTerminal");
}
void TerminalAspect::addToConfigurationLayout(QFormLayout *layout)
@@ -115,12 +115,12 @@ bool TerminalAspect::isUserSet() const
\class ProjectExplorer::WorkingDirectoryAspect
*/
WorkingDirectoryAspect::WorkingDirectoryAspect(RunConfiguration *runConfig, const QString &key)
WorkingDirectoryAspect::WorkingDirectoryAspect(RunConfiguration *runConfig)
: IRunConfigurationAspect(runConfig)
{
setDisplayName(tr("Working Directory"));
setId("WorkingDirectoryAspect");
setSettingsKey(key);
setSettingsKey("RunConfiguration.WorkingDirectory");
}
void WorkingDirectoryAspect::addToConfigurationLayout(QFormLayout *layout)
@@ -235,12 +235,12 @@ PathChooser *WorkingDirectoryAspect::pathChooser() const
\class ProjectExplorer::ArgumentsAspect
*/
ArgumentsAspect::ArgumentsAspect(RunConfiguration *runConfig, const QString &key)
ArgumentsAspect::ArgumentsAspect(RunConfiguration *runConfig)
: IRunConfigurationAspect(runConfig)
{
setDisplayName(tr("Arguments"));
setId("ArgumentsAspect");
setSettingsKey(key);
setSettingsKey("RunConfiguration.Arguments");
}
QString ArgumentsAspect::arguments() const
@@ -654,10 +654,11 @@ void BaseBoolAspect::setLabel(const QString &label)
\class ProjectExplorer::UseLibraryPathsAspect
*/
UseLibraryPathsAspect::UseLibraryPathsAspect(RunConfiguration *rc, const QString &settingsKey)
: BaseBoolAspect(rc, settingsKey)
UseLibraryPathsAspect::UseLibraryPathsAspect(RunConfiguration *rc)
: BaseBoolAspect(rc)
{
setId("UseLibraryPath");
setSettingsKey("RunConfiguration.UseLibrarySearchPath");
if (HostOsInfo::isMacHost())
setLabel(tr("Add build library search path to DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH"));
else if (HostOsInfo::isWindowsHost())
@@ -671,10 +672,11 @@ UseLibraryPathsAspect::UseLibraryPathsAspect(RunConfiguration *rc, const QString
\class ProjectExplorer::UseDyldSuffixAspect
*/
UseDyldSuffixAspect::UseDyldSuffixAspect(RunConfiguration *rc, const QString &settingsKey)
: BaseBoolAspect(rc, settingsKey)
UseDyldSuffixAspect::UseDyldSuffixAspect(RunConfiguration *rc)
: BaseBoolAspect(rc)
{
setId("UseDyldSuffix");
setSettingsKey("RunConfiguration.UseDyldImageSuffix");
setLabel(tr("Use debug version of frameworks (DYLD_IMAGE_SUFFIX=_debug)"));
}

View File

@@ -47,8 +47,7 @@ class PROJECTEXPLORER_EXPORT TerminalAspect : public IRunConfigurationAspect
Q_OBJECT
public:
TerminalAspect(RunConfiguration *rc, const QString &settingsKey,
bool useTerminal = false);
TerminalAspect(RunConfiguration *rc, bool useTerminal = false);
void addToConfigurationLayout(QFormLayout *layout) override;
@@ -71,8 +70,7 @@ class PROJECTEXPLORER_EXPORT WorkingDirectoryAspect : public IRunConfigurationAs
Q_OBJECT
public:
explicit WorkingDirectoryAspect(RunConfiguration *runConfig,
const QString &settingsKey = QString());
explicit WorkingDirectoryAspect(RunConfiguration *runConfig);
void addToConfigurationLayout(QFormLayout *layout) override;
@@ -100,7 +98,7 @@ class PROJECTEXPLORER_EXPORT ArgumentsAspect : public IRunConfigurationAspect
Q_OBJECT
public:
explicit ArgumentsAspect(RunConfiguration *runConfig, const QString &settingsKey = QString());
explicit ArgumentsAspect(RunConfiguration *runConfig);
void addToConfigurationLayout(QFormLayout *layout) override;
@@ -149,7 +147,7 @@ class PROJECTEXPLORER_EXPORT UseLibraryPathsAspect : public BaseBoolAspect
Q_OBJECT
public:
UseLibraryPathsAspect(RunConfiguration *rc, const QString &settingsKey);
explicit UseLibraryPathsAspect(RunConfiguration *rc);
};
class PROJECTEXPLORER_EXPORT UseDyldSuffixAspect : public BaseBoolAspect
@@ -157,7 +155,7 @@ class PROJECTEXPLORER_EXPORT UseDyldSuffixAspect : public BaseBoolAspect
Q_OBJECT
public:
UseDyldSuffixAspect(RunConfiguration *rc, const QString &settingsKey);
explicit UseDyldSuffixAspect(RunConfiguration *rc);
};
class PROJECTEXPLORER_EXPORT BaseStringAspect : public IRunConfigurationAspect

View File

@@ -122,6 +122,17 @@ public:
static QVariant process(const QVariant &entry);
};
// Version 19 makes arguments, working directory and run-in-terminal
// run configuration fields use the same key in the settings file.
class UserFileVersion19Upgrader : public VersionUpgrader
{
public:
UserFileVersion19Upgrader() : VersionUpgrader(19, "4.8-pre2") { }
QVariantMap upgrade(const QVariantMap &map) final;
static QVariant process(const QVariant &entry, const QStringList &path);
};
} // namespace
//
@@ -322,6 +333,7 @@ UserFileAccessor::UserFileAccessor(Project *project) :
addVersionUpgrader(std::make_unique<UserFileVersion16Upgrader>());
addVersionUpgrader(std::make_unique<UserFileVersion17Upgrader>());
addVersionUpgrader(std::make_unique<UserFileVersion18Upgrader>());
addVersionUpgrader(std::make_unique<UserFileVersion19Upgrader>());
}
Project *UserFileAccessor::project() const
@@ -773,6 +785,71 @@ QVariant UserFileVersion18Upgrader::process(const QVariant &entry)
}
}
QVariantMap UserFileVersion19Upgrader::upgrade(const QVariantMap &map)
{
return process(map, QStringList()).toMap();
}
QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const QStringList &path)
{
static const QStringList argsKeys = {"Qt4ProjectManager.MaemoRunConfiguration.Arguments",
"CMakeProjectManager.CMakeRunConfiguration.Arguments",
"Ios.run_arguments",
"Nim.NimRunConfiguration.ArgumentAspect",
"ProjectExplorer.CustomExecutableRunConfiguration.Arguments",
"PythonEditor.RunConfiguration.Arguments",
"Qbs.RunConfiguration.CommandLineArguments",
"Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments",
"RemoteLinux.CustomRunConfig.Arguments",
"WinRtRunConfigurationArgumentsId",
"CommandLineArgs"};
static const QStringList wdKeys = {"BareMetal.RunConfig.WorkingDirectory",
"CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory",
"Nim.NimRunConfiguration.WorkingDirectoryAspect",
"ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory",
"Qbs.RunConfiguration.WorkingDirectory",
"Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory",
"RemoteLinux.CustomRunConfig.WorkingDirectory"
"RemoteLinux.RunConfig.WorkingDirectory",
"WorkingDir"};
static const QStringList termKeys = {"CMakeProjectManager.CMakeRunConfiguration.UseTerminal",
"Nim.NimRunConfiguration.TerminalAspect",
"ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal",
"PythonEditor.RunConfiguration.UseTerminal",
"Qbs.RunConfiguration.UseTerminal",
"Qt4ProjectManager.Qt4RunConfiguration.UseTerminal"};
static const QStringList libsKeys = {"Qbs.RunConfiguration.UsingLibraryPaths",
"QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath"};
static const QStringList dyldKeys = {"Qbs.RunConfiguration.UseDyldImageSuffix",
"QmakeProjectManager.QmakeRunConfiguration.UseDyldImageSuffix"};
switch (entry.type()) {
case QVariant::List:
return Utils::transform(entry.toList(),
std::bind(&UserFileVersion19Upgrader::process, std::placeholders::_1, path));
case QVariant::Map:
return Utils::transform<QVariantMap>(
entry.toMap().toStdMap(), [&](const std::pair<const QString, QVariant> &item) {
if (path.size() == 2 && path.at(1).startsWith("ProjectExplorer.Target.RunConfiguration.")) {
if (argsKeys.contains(item.first))
return qMakePair(QString("RunConfiguration.Arguments"), item.second);
if (wdKeys.contains(item.first))
return qMakePair(QString("RunConfiguration.WorkingDirectory"), item.second);
if (termKeys.contains(item.first))
return qMakePair(QString("RunConfiguration.UseTerminal"), item.second);
if (libsKeys.contains(item.first))
return qMakePair(QString("RunConfiguration.UseLibrarySearchPath"), item.second);
if (dyldKeys.contains(item.first))
return qMakePair(QString("RunConfiguration.UseDyldImageSuffix"), item.second);
}
QStringList newPath = path;
newPath.append(item.first);
return qMakePair(item.first, UserFileVersion19Upgrader::process(item.second, newPath));
});
default:
return entry;
}
}
#if defined(WITH_TESTS)
#include <QTest>

View File

@@ -266,8 +266,8 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Core::Id id)
addExtraAspect(scriptAspect);
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
addExtraAspect(new ArgumentsAspect(this, "PythonEditor.RunConfiguration.Arguments"));
addExtraAspect(new TerminalAspect(this, "PythonEditor.RunConfiguration.UseTerminal"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new TerminalAspect(this));
setOutputFormatter<PythonOutputFormatter>();

View File

@@ -59,18 +59,18 @@ QbsRunConfiguration::QbsRunConfiguration(Target *target, Core::Id id)
addExtraAspect(envAspect);
addExtraAspect(new ExecutableAspect(this));
addExtraAspect(new ArgumentsAspect(this, "Qbs.RunConfiguration.CommandLineArguments"));
addExtraAspect(new WorkingDirectoryAspect(this, "Qbs.RunConfiguration.WorkingDirectory"));
addExtraAspect(new TerminalAspect(this, "Qbs.RunConfiguration.UseTerminal"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new WorkingDirectoryAspect(this));
addExtraAspect(new TerminalAspect(this));
setOutputFormatter<QtSupport::QtOutputFormatter>();
auto libAspect = new UseLibraryPathsAspect(this, "Qbs.RunConfiguration.UsingLibraryPaths");
auto libAspect = new UseLibraryPathsAspect(this);
addExtraAspect(libAspect);
connect(libAspect, &UseLibraryPathsAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);
if (HostOsInfo::isMacHost()) {
auto dyldAspect = new UseDyldSuffixAspect(this, "Qbs.RunConfiguration.UseDyldImageSuffix");
auto dyldAspect = new UseDyldSuffixAspect(this);
addExtraAspect(dyldAspect);
connect(dyldAspect, &UseDyldSuffixAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);

View File

@@ -69,19 +69,19 @@ DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *target, Core:
addExtraAspect(envAspect);
addExtraAspect(new ExecutableAspect(this));
addExtraAspect(new ArgumentsAspect(this, "Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"));
addExtraAspect(new TerminalAspect(this, "Qt4ProjectManager.Qt4RunConfiguration.UseTerminal"));
addExtraAspect(new WorkingDirectoryAspect(this, "Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new TerminalAspect(this));
addExtraAspect(new WorkingDirectoryAspect(this));
setOutputFormatter<QtSupport::QtOutputFormatter>();
auto libAspect = new UseLibraryPathsAspect(this, "QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath");
auto libAspect = new UseLibraryPathsAspect(this);
addExtraAspect(libAspect);
connect(libAspect, &UseLibraryPathsAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);
if (HostOsInfo::isMacHost()) {
auto dyldAspect = new UseDyldSuffixAspect(this, "QmakeProjectManager.QmakeRunConfiguration.UseDyldImageSuffix");
auto dyldAspect = new UseDyldSuffixAspect(this);
addExtraAspect(dyldAspect);
connect(dyldAspect, &UseLibraryPathsAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);

View File

@@ -57,8 +57,8 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar
symbolsAspect->setDisplayStyle(SymbolFileAspect::PathChooserDisplay);
addExtraAspect(symbolsAspect);
addExtraAspect(new ArgumentsAspect(this, "RemoteLinux.CustomRunConfig.Arguments"));
addExtraAspect(new WorkingDirectoryAspect(this, "RemoteLinux.CustomRunConfig.WorkingDirectory"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new WorkingDirectoryAspect(this));
addExtraAspect(new RemoteLinuxEnvironmentAspect(this));
setDefaultDisplayName(runConfigDefaultDisplayName());

View File

@@ -59,14 +59,8 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Core::I
symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay);
addExtraAspect(symbolsAspect);
auto argsAspect = new ArgumentsAspect(this);
argsAspect->setSettingsKey("Qt4ProjectManager.MaemoRunConfiguration.Arguments");
addExtraAspect(argsAspect);
auto wdAspect = new WorkingDirectoryAspect(this);
wdAspect->setSettingsKey("RemoteLinux.RunConfig.WorkingDirectory");
addExtraAspect(wdAspect);
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new WorkingDirectoryAspect(this));
addExtraAspect(new RemoteLinuxEnvironmentAspect(this));
setOutputFormatter<QtSupport::QtOutputFormatter>();

View File

@@ -56,7 +56,7 @@ WinRtRunConfiguration::WinRtRunConfiguration(Target *target, Core::Id id)
: RunConfiguration(target, id)
{
setDisplayName(tr("Run App Package"));
addExtraAspect(new ArgumentsAspect(this, "WinRtRunConfigurationArgumentsId"));
addExtraAspect(new ArgumentsAspect(this));
addExtraAspect(new UninstallAfterStopAspect(this));
}