forked from qt-creator/qt-creator
ProjectExplorer: Compactify runconfiguration aspect creation
Change-Id: I12394d3df8deb7666be6ac3f112082f915454e82 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -111,28 +111,25 @@ void BaseStringListAspect::setLabel(const QString &label)
|
||||
AndroidRunConfiguration::AndroidRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
addExtraAspect(new AndroidRunEnvironmentAspect(this));
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addAspect<AndroidRunEnvironmentAspect>();
|
||||
addAspect<ArgumentsAspect>();
|
||||
|
||||
auto amStartArgsAspect = new BaseStringAspect(this);
|
||||
auto amStartArgsAspect = addAspect<BaseStringAspect>();
|
||||
amStartArgsAspect->setId(Constants::ANDROID_AMSTARTARGS);
|
||||
amStartArgsAspect->setSettingsKey("Android.AmStartArgsKey");
|
||||
amStartArgsAspect->setLabelText(tr("Activity manager start options:"));
|
||||
amStartArgsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
||||
amStartArgsAspect->setHistoryCompleter("Android.AmStartArgs.History");
|
||||
addExtraAspect(amStartArgsAspect);
|
||||
|
||||
auto preStartShellCmdAspect = new BaseStringListAspect(this);
|
||||
auto preStartShellCmdAspect = addAspect<BaseStringListAspect>();
|
||||
preStartShellCmdAspect->setId(Constants::ANDROID_PRESTARTSHELLCMDLIST);
|
||||
preStartShellCmdAspect->setSettingsKey("Android.PreStartShellCmdListKey");
|
||||
preStartShellCmdAspect->setLabel(tr("Shell commands to run on Android device before application launch."));
|
||||
addExtraAspect(preStartShellCmdAspect);
|
||||
|
||||
auto postStartShellCmdAspect = new BaseStringListAspect(this);
|
||||
auto postStartShellCmdAspect = addAspect<BaseStringListAspect>();
|
||||
postStartShellCmdAspect->setId(Constants::ANDROID_POSTFINISHSHELLCMDLIST);
|
||||
postStartShellCmdAspect->setSettingsKey("Android.PostStartShellCmdListKey");
|
||||
postStartShellCmdAspect->setLabel(tr("Shell commands to run on Android device after application quits."));
|
||||
addExtraAspect(postStartShellCmdAspect);
|
||||
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
connect(target->project(), &Project::parsingFinished, this, [this] {
|
||||
|
@@ -41,16 +41,15 @@ namespace Internal {
|
||||
BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto exeAspect = new ExecutableAspect(this);
|
||||
auto exeAspect = addAspect<ExecutableAspect>();
|
||||
exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable");
|
||||
exeAspect->setPlaceHolderText(tr("Unknown"));
|
||||
exeAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
||||
exeAspect->setHistoryCompleter("BareMetal.CustomRunConfig.History");
|
||||
exeAspect->setExpectedKind(PathChooser::Any);
|
||||
addExtraAspect(exeAspect);
|
||||
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new WorkingDirectoryAspect(this));
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
|
||||
setDefaultDisplayName(RunConfigurationFactory::decoratedTargetName(tr("Custom Executable"), target));
|
||||
}
|
||||
|
@@ -43,13 +43,12 @@ namespace Internal {
|
||||
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto exeAspect = new ExecutableAspect(this);
|
||||
auto exeAspect = addAspect<ExecutableAspect>();
|
||||
exeAspect->setDisplayStyle(BaseStringAspect::LabelDisplay);
|
||||
exeAspect->setPlaceHolderText(tr("Unknown"));
|
||||
addExtraAspect(exeAspect);
|
||||
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new WorkingDirectoryAspect(this));
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
|
||||
connect(target, &Target::deploymentDataChanged,
|
||||
this, &BareMetalRunConfiguration::updateTargetInformation);
|
||||
|
@@ -53,11 +53,11 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *target, Core::Id id)
|
||||
if (qt)
|
||||
env.prependOrSetPath(qt->qmakeProperty("QT_INSTALL_BINS"));
|
||||
};
|
||||
addExtraAspect(new LocalEnvironmentAspect(this, cmakeRunEnvironmentModifier));
|
||||
addExtraAspect(new ExecutableAspect(this));
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new WorkingDirectoryAspect(this));
|
||||
addExtraAspect(new TerminalAspect(this));
|
||||
addAspect<LocalEnvironmentAspect>(cmakeRunEnvironmentModifier);
|
||||
addAspect<ExecutableAspect>();
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
addAspect<TerminalAspect>();
|
||||
|
||||
connect(target->project(), &Project::parsingFinished,
|
||||
this, &CMakeRunConfiguration::updateTargetInformation);
|
||||
|
@@ -97,7 +97,7 @@ private:
|
||||
IosRunConfiguration::IosRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addAspect<ArgumentsAspect>();
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
|
||||
connect(DeviceManager::instance(), &DeviceManager::updated,
|
||||
|
@@ -44,11 +44,11 @@ namespace Nim {
|
||||
NimRunConfiguration::NimRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
addExtraAspect(new ExecutableAspect(this));
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new WorkingDirectoryAspect(this));
|
||||
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
|
||||
addExtraAspect(new TerminalAspect(this));
|
||||
addAspect<ExecutableAspect>();
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
addAspect<LocalEnvironmentAspect>(LocalEnvironmentAspect::BaseEnvironmentModifier());
|
||||
addAspect<TerminalAspect>();
|
||||
|
||||
setDisplayName(tr("Current Build Target"));
|
||||
setDefaultDisplayName(tr("Current Build Target"));
|
||||
|
@@ -175,20 +175,18 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe
|
||||
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto envAspect = new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier());
|
||||
addExtraAspect(envAspect);
|
||||
auto envAspect = addAspect<LocalEnvironmentAspect>(LocalEnvironmentAspect::BaseEnvironmentModifier());
|
||||
|
||||
auto exeAspect = new ExecutableAspect(this);
|
||||
auto exeAspect = addAspect<ExecutableAspect>();
|
||||
exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable");
|
||||
exeAspect->setDisplayStyle(BaseStringAspect::PathChooserDisplay);
|
||||
exeAspect->setHistoryCompleter("Qt.CustomExecutable.History");
|
||||
exeAspect->setExpectedKind(PathChooser::ExistingCommand);
|
||||
exeAspect->setEnvironment(envAspect->environment());
|
||||
addExtraAspect(exeAspect);
|
||||
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new WorkingDirectoryAspect(this));
|
||||
addExtraAspect(new TerminalAspect(this));
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
addAspect<TerminalAspect>();
|
||||
|
||||
connect(envAspect, &EnvironmentAspect::environmentChanged,
|
||||
this, [exeAspect, envAspect] { exeAspect->setEnvironment(envAspect->environment()); });
|
||||
|
@@ -231,7 +231,7 @@ RunConfiguration::RunConfiguration(Target *target, Core::Id id)
|
||||
[this] { return displayName(); }, false);
|
||||
|
||||
for (const AspectFactory &factory : theAspectFactories)
|
||||
addExtraAspect(factory(this));
|
||||
m_aspects.append(factory(this));
|
||||
}
|
||||
|
||||
RunConfiguration::~RunConfiguration()
|
||||
@@ -280,12 +280,6 @@ void RunConfiguration::addAspectFactory(const AspectFactory &aspectFactory)
|
||||
theAspectFactories.push_back(aspectFactory);
|
||||
}
|
||||
|
||||
void RunConfiguration::addExtraAspect(IRunConfigurationAspect *aspect)
|
||||
{
|
||||
if (aspect)
|
||||
m_aspects += aspect;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the RunConfiguration of the currently active target
|
||||
* of the startup project, if such exists, or \c nullptr otherwise.
|
||||
|
@@ -222,7 +222,13 @@ public:
|
||||
// The BuildTargetInfo corresponding to the buildKey.
|
||||
BuildTargetInfo buildTargetInfo() const;
|
||||
|
||||
void addExtraAspect(IRunConfigurationAspect *aspect);
|
||||
template<class Aspect, typename ...Args>
|
||||
Aspect *addAspect(Args && ...args)
|
||||
{
|
||||
auto aspect = new Aspect(this, args...);
|
||||
m_aspects.append(aspect);
|
||||
return aspect;
|
||||
}
|
||||
|
||||
static RunConfiguration *startupRunConfiguration();
|
||||
virtual bool canRunForNode(const ProjectExplorer::Node *) const { return false; }
|
||||
|
@@ -250,23 +250,21 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Core::Id id)
|
||||
const Environment sysEnv = Environment::systemEnvironment();
|
||||
const QString exec = sysEnv.searchInPath("python").toString();
|
||||
|
||||
auto interpreterAspect = new InterpreterAspect(this);
|
||||
auto interpreterAspect = addAspect<InterpreterAspect>();
|
||||
interpreterAspect->setSettingsKey("PythonEditor.RunConfiguation.Interpreter");
|
||||
interpreterAspect->setLabelText(tr("Interpreter:"));
|
||||
interpreterAspect->setDisplayStyle(BaseStringAspect::PathChooserDisplay);
|
||||
interpreterAspect->setHistoryCompleter("PythonEditor.Interpreter.History");
|
||||
interpreterAspect->setValue(exec.isEmpty() ? "python" : exec);
|
||||
addExtraAspect(interpreterAspect);
|
||||
|
||||
auto scriptAspect = new MainScriptAspect(this);
|
||||
auto scriptAspect = addAspect<MainScriptAspect>();
|
||||
scriptAspect->setSettingsKey("PythonEditor.RunConfiguation.Script");
|
||||
scriptAspect->setLabelText(tr("Script:"));
|
||||
scriptAspect->setDisplayStyle(BaseStringAspect::LabelDisplay);
|
||||
addExtraAspect(scriptAspect);
|
||||
|
||||
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new TerminalAspect(this));
|
||||
addAspect<LocalEnvironmentAspect>(LocalEnvironmentAspect::BaseEnvironmentModifier());
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<TerminalAspect>();
|
||||
|
||||
setOutputFormatter<PythonOutputFormatter>();
|
||||
|
||||
|
@@ -52,26 +52,23 @@ namespace Internal {
|
||||
QbsRunConfiguration::QbsRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto envAspect = new LocalEnvironmentAspect(this,
|
||||
auto envAspect = addAspect<LocalEnvironmentAspect>(
|
||||
[](RunConfiguration *rc, Environment &env) {
|
||||
static_cast<QbsRunConfiguration *>(rc)->addToBaseEnvironment(env);
|
||||
});
|
||||
addExtraAspect(envAspect);
|
||||
|
||||
addExtraAspect(new ExecutableAspect(this));
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new WorkingDirectoryAspect(this));
|
||||
addExtraAspect(new TerminalAspect(this));
|
||||
addAspect<ExecutableAspect>();
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
addAspect<TerminalAspect>();
|
||||
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
|
||||
auto libAspect = new UseLibraryPathsAspect(this);
|
||||
addExtraAspect(libAspect);
|
||||
auto libAspect = addAspect<UseLibraryPathsAspect>();
|
||||
connect(libAspect, &UseLibraryPathsAspect::changed,
|
||||
envAspect, &EnvironmentAspect::environmentChanged);
|
||||
if (HostOsInfo::isMacHost()) {
|
||||
auto dyldAspect = new UseDyldSuffixAspect(this);
|
||||
addExtraAspect(dyldAspect);
|
||||
auto dyldAspect = addAspect<UseDyldSuffixAspect>();
|
||||
connect(dyldAspect, &UseDyldSuffixAspect::changed,
|
||||
envAspect, &EnvironmentAspect::environmentChanged);
|
||||
}
|
||||
|
@@ -63,26 +63,23 @@ const char PRO_FILE_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.ProFile";
|
||||
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto envAspect = new LocalEnvironmentAspect(this, [](RunConfiguration *rc, Environment &env) {
|
||||
auto envAspect = addAspect<LocalEnvironmentAspect>([](RunConfiguration *rc, Environment &env) {
|
||||
static_cast<DesktopQmakeRunConfiguration *>(rc)->addToBaseEnvironment(env);
|
||||
});
|
||||
addExtraAspect(envAspect);
|
||||
|
||||
addExtraAspect(new ExecutableAspect(this));
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new WorkingDirectoryAspect(this));
|
||||
addExtraAspect(new TerminalAspect(this));
|
||||
addAspect<ExecutableAspect>();
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
addAspect<TerminalAspect>();
|
||||
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
|
||||
auto libAspect = new UseLibraryPathsAspect(this);
|
||||
addExtraAspect(libAspect);
|
||||
auto libAspect = addAspect<UseLibraryPathsAspect>();
|
||||
connect(libAspect, &UseLibraryPathsAspect::changed,
|
||||
envAspect, &EnvironmentAspect::environmentChanged);
|
||||
|
||||
if (HostOsInfo::isMacHost()) {
|
||||
auto dyldAspect = new UseDyldSuffixAspect(this);
|
||||
addExtraAspect(dyldAspect);
|
||||
auto dyldAspect = addAspect<UseDyldSuffixAspect>();
|
||||
connect(dyldAspect, &UseLibraryPathsAspect::changed,
|
||||
envAspect, &EnvironmentAspect::environmentChanged);
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ const char M_CURRENT_FILE[] = "CurrentFile";
|
||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
addExtraAspect(new QmlProjectEnvironmentAspect(this));
|
||||
addAspect<QmlProjectEnvironmentAspect>();
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
|
||||
// reset default settings in constructor
|
||||
|
@@ -36,10 +36,9 @@ namespace Internal {
|
||||
QnxRunConfiguration::QnxRunConfiguration(Target *target, Core::Id id)
|
||||
: RemoteLinuxRunConfiguration(target, id)
|
||||
{
|
||||
auto libAspect = new QtLibPathAspect(this);
|
||||
auto libAspect = addAspect<QtLibPathAspect>();
|
||||
libAspect->setSettingsKey("Qt4ProjectManager.QnxRunConfiguration.QtLibPath");
|
||||
libAspect->setLabelText(tr("Path to Qt libraries on device"));
|
||||
addExtraAspect(libAspect);
|
||||
}
|
||||
|
||||
Runnable QnxRunConfiguration::runnable() const
|
||||
|
@@ -42,24 +42,22 @@ namespace Internal {
|
||||
RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto exeAspect = new ExecutableAspect(this);
|
||||
auto exeAspect = addAspect<ExecutableAspect>();
|
||||
exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable");
|
||||
exeAspect->setLabelText(tr("Remote executable:"));
|
||||
exeAspect->setExecutablePathStyle(OsTypeLinux);
|
||||
exeAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
||||
exeAspect->setHistoryCompleter("RemoteLinux.CustomExecutable.History");
|
||||
exeAspect->setExpectedKind(PathChooser::Any);
|
||||
addExtraAspect(exeAspect);
|
||||
|
||||
auto symbolsAspect = new SymbolFileAspect(this);
|
||||
auto symbolsAspect = addAspect<SymbolFileAspect>();
|
||||
symbolsAspect->setSettingsKey("RemoteLinux.CustomRunConfig.LocalExecutable");
|
||||
symbolsAspect->setLabelText(tr("Local executable:"));
|
||||
symbolsAspect->setDisplayStyle(SymbolFileAspect::PathChooserDisplay);
|
||||
addExtraAspect(symbolsAspect);
|
||||
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new WorkingDirectoryAspect(this));
|
||||
addExtraAspect(new RemoteLinuxEnvironmentAspect(this));
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
addAspect<RemoteLinuxEnvironmentAspect>();
|
||||
|
||||
setDefaultDisplayName(runConfigDefaultDisplayName());
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
|
@@ -45,23 +45,21 @@ namespace RemoteLinux {
|
||||
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto exeAspect = new ExecutableAspect(this);
|
||||
auto exeAspect = addAspect<ExecutableAspect>();
|
||||
exeAspect->setLabelText(tr("Executable on device:"));
|
||||
exeAspect->setExecutablePathStyle(OsTypeLinux);
|
||||
exeAspect->setPlaceHolderText(tr("Remote path not set"));
|
||||
exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable",
|
||||
"RemoteLinux.RunConfig.UseAlternateRemoteExecutable");
|
||||
exeAspect->setHistoryCompleter("RemoteLinux.AlternateExecutable.History");
|
||||
addExtraAspect(exeAspect);
|
||||
|
||||
auto symbolsAspect = new SymbolFileAspect(this);
|
||||
auto symbolsAspect = addAspect<SymbolFileAspect>();
|
||||
symbolsAspect->setLabelText(tr("Executable on host:"));
|
||||
symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay);
|
||||
addExtraAspect(symbolsAspect);
|
||||
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new WorkingDirectoryAspect(this));
|
||||
addExtraAspect(new RemoteLinuxEnvironmentAspect(this));
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<WorkingDirectoryAspect>();
|
||||
addAspect<RemoteLinuxEnvironmentAspect>();
|
||||
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
|
||||
|
@@ -56,8 +56,8 @@ WinRtRunConfiguration::WinRtRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
setDisplayName(tr("Run App Package"));
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
addExtraAspect(new UninstallAfterStopAspect(this));
|
||||
addAspect<ArgumentsAspect>();
|
||||
addAspect<UninstallAfterStopAspect>();
|
||||
}
|
||||
|
||||
QWidget *WinRtRunConfiguration::createConfigurationWidget()
|
||||
|
Reference in New Issue
Block a user