diff --git a/src/plugins/projectexplorer/processstep.cpp b/src/plugins/projectexplorer/processstep.cpp index a34ff10b611..e2aa69dff9b 100644 --- a/src/plugins/projectexplorer/processstep.cpp +++ b/src/plugins/projectexplorer/processstep.cpp @@ -11,13 +11,11 @@ #include "projectexplorertr.h" #include -#include #include using namespace Utils; -namespace ProjectExplorer { -namespace Internal { +namespace ProjectExplorer::Internal { const char PROCESS_COMMAND_KEY[] = "ProjectExplorer.ProcessStep.Command"; const char PROCESS_WORKINGDIRECTORY_KEY[] = "ProjectExplorer.ProcessStep.WorkingDirectory"; @@ -26,60 +24,58 @@ const char PROCESS_ARGUMENTS_KEY[] = "ProjectExplorer.ProcessStep.Arguments"; class ProcessStep final : public AbstractProcessStep { public: - ProcessStep(BuildStepList *bsl, Id id); + ProcessStep(BuildStepList *bsl, Id id) + : AbstractProcessStep(bsl, id) + { + command.setSettingsKey(PROCESS_COMMAND_KEY); + command.setLabelText(Tr::tr("Command:")); + command.setExpectedKind(PathChooser::Command); + command.setHistoryCompleter("PE.ProcessStepCommand.History"); - void setupOutputFormatter(OutputFormatter *formatter) final; + arguments.setSettingsKey(PROCESS_ARGUMENTS_KEY); + arguments.setDisplayStyle(StringAspect::LineEditDisplay); + arguments.setLabelText(Tr::tr("Arguments:")); + + workingDirectory.setSettingsKey(PROCESS_WORKINGDIRECTORY_KEY); + workingDirectory.setValue(Constants::DEFAULT_WORKING_DIR); + workingDirectory.setLabelText(Tr::tr("Working directory:")); + workingDirectory.setExpectedKind(PathChooser::Directory); + + setWorkingDirectoryProvider([this] { + const FilePath workingDir = workingDirectory(); + if (workingDir.isEmpty()) + return FilePath::fromString(fallbackWorkingDirectory()); + return workingDir; + }); + + setCommandLineProvider([this] { + return CommandLine{command(), arguments(), CommandLine::Raw}; + }); + + setSummaryUpdater([this] { + QString display = displayName(); + if (display.isEmpty()) + display = Tr::tr("Custom Process Step"); + ProcessParameters param; + setupProcessParameters(¶m); + return param.summary(display); + }); + + addMacroExpander(); + } + +private: + void setupOutputFormatter(OutputFormatter *formatter) final + { + formatter->addLineParsers(kit()->createOutputParsers()); + AbstractProcessStep::setupOutputFormatter(formatter); + } + + FilePathAspect command{this}; + StringAspect arguments{this}; + FilePathAspect workingDirectory{this}; }; -ProcessStep::ProcessStep(BuildStepList *bsl, Id id) - : AbstractProcessStep(bsl, id) -{ - auto command = addAspect(); - command->setSettingsKey(PROCESS_COMMAND_KEY); - command->setLabelText(Tr::tr("Command:")); - command->setExpectedKind(PathChooser::Command); - command->setHistoryCompleter("PE.ProcessStepCommand.History"); - - auto arguments = addAspect(); - arguments->setSettingsKey(PROCESS_ARGUMENTS_KEY); - arguments->setDisplayStyle(StringAspect::LineEditDisplay); - arguments->setLabelText(Tr::tr("Arguments:")); - - auto workingDirectory = addAspect(); - workingDirectory->setSettingsKey(PROCESS_WORKINGDIRECTORY_KEY); - workingDirectory->setValue(Constants::DEFAULT_WORKING_DIR); - workingDirectory->setLabelText(Tr::tr("Working directory:")); - workingDirectory->setExpectedKind(PathChooser::Directory); - - setWorkingDirectoryProvider([this, workingDirectory] { - const FilePath workingDir = workingDirectory->filePath(); - if (workingDir.isEmpty()) - return FilePath::fromString(fallbackWorkingDirectory()); - return workingDir; - }); - - setCommandLineProvider([command, arguments] { - return CommandLine{command->filePath(), arguments->value(), CommandLine::Raw}; - }); - - setSummaryUpdater([this] { - QString display = displayName(); - if (display.isEmpty()) - display = Tr::tr("Custom Process Step"); - ProcessParameters param; - setupProcessParameters(¶m); - return param.summary(display); - }); - - addMacroExpander(); -} - -void ProcessStep::setupOutputFormatter(OutputFormatter *formatter) -{ - formatter->addLineParsers(kit()->createOutputParsers()); - AbstractProcessStep::setupOutputFormatter(formatter); -} - // ProcessStepFactory ProcessStepFactory::ProcessStepFactory() @@ -89,5 +85,4 @@ ProcessStepFactory::ProcessStepFactory() setDisplayName(Tr::tr("Custom Process Step")); } -} // Internal -} // ProjectExplorer +} // ProjectExplorer::Internal diff --git a/src/plugins/projectexplorer/processstep.h b/src/plugins/projectexplorer/processstep.h index 40384383057..04e9b7183ce 100644 --- a/src/plugins/projectexplorer/processstep.h +++ b/src/plugins/projectexplorer/processstep.h @@ -5,8 +5,7 @@ #include "buildstep.h" -namespace ProjectExplorer { -namespace Internal { +namespace ProjectExplorer::Internal { class ProcessStepFactory final : public BuildStepFactory { @@ -14,5 +13,4 @@ public: ProcessStepFactory(); }; -} // namespace Internal -} // namespace ProjectExplorer +} // ProjectExplorer::Internal