RemoteLinux: Use aspects more directly in RemoteLinuxCustomRunRC

This now also unconditionally enables the X11ForwardingAspect.

Change-Id: I5c4c69fcc2902bd6b842adba1ec93978b846f651
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2023-07-14 06:58:35 +02:00
parent 7a279669ef
commit c8e7491685

View File

@@ -27,56 +27,56 @@ public:
private: private:
Tasks checkForIssues() const override; Tasks checkForIssues() const override;
RemoteLinuxEnvironmentAspect environment{this};
ExecutableAspect executable{this};
SymbolFileAspect symbolFile{this};
ArgumentsAspect arguments{this};
WorkingDirectoryAspect workingDir{this};
TerminalAspect terminal{this};
X11ForwardingAspect x11Forwarding{this};
}; };
RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Id id) RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(); environment.setDeviceSelector(target, EnvironmentAspect::RunDevice);
envAspect->setDeviceSelector(target, EnvironmentAspect::RunDevice);
auto exeAspect = addAspect<ExecutableAspect>(); executable.setDeviceSelector(target, ExecutableAspect::RunDevice);
exeAspect->setDeviceSelector(target, ExecutableAspect::RunDevice); executable.setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable");
exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable"); executable.setLabelText(Tr::tr("Remote executable:"));
exeAspect->setLabelText(Tr::tr("Remote executable:")); executable.setReadOnly(false);
exeAspect->setReadOnly(false); executable.setHistoryCompleter("RemoteLinux.CustomExecutable.History");
exeAspect->setHistoryCompleter("RemoteLinux.CustomExecutable.History"); executable.setExpectedKind(PathChooser::Any);
exeAspect->setExpectedKind(PathChooser::Any);
auto symbolsAspect = addAspect<FilePathAspect>(); symbolFile.setSettingsKey("RemoteLinux.CustomRunConfig.LocalExecutable");
symbolsAspect->setSettingsKey("RemoteLinux.CustomRunConfig.LocalExecutable"); symbolFile.setLabelText(Tr::tr("Local executable:"));
symbolsAspect->setLabelText(Tr::tr("Local executable:"));
auto argsAspect = addAspect<ArgumentsAspect>(); arguments.setMacroExpander(macroExpander());
argsAspect->setMacroExpander(macroExpander());
auto workingDirAspect = addAspect<WorkingDirectoryAspect>(); workingDir.setMacroExpander(macroExpander());
workingDirAspect->setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment);
workingDirAspect->setEnvironment(envAspect);
if (HostOsInfo::isAnyUnixHost()) terminal.setVisible(HostOsInfo::isAnyUnixHost());
addAspect<TerminalAspect>();
if (HostOsInfo::isAnyUnixHost()) { x11Forwarding.setMacroExpander(macroExpander());
auto x11Forwarding = addAspect<X11ForwardingAspect>();
x11Forwarding->setMacroExpander(macroExpander());
}
setDefaultDisplayName(runConfigDefaultDisplayName()); setDefaultDisplayName(runConfigDefaultDisplayName());
} }
QString RemoteLinuxCustomRunConfiguration::runConfigDefaultDisplayName() QString RemoteLinuxCustomRunConfiguration::runConfigDefaultDisplayName()
{ {
QString remoteExecutable = aspect<ExecutableAspect>()->executable().toString(); FilePath remoteExecutable = executable();
QString display = remoteExecutable.isEmpty() QString display = remoteExecutable.isEmpty()
? Tr::tr("Custom Executable") : Tr::tr("Run \"%1\"").arg(remoteExecutable); ? Tr::tr("Custom Executable")
: Tr::tr("Run \"%1\"").arg(remoteExecutable.toUserOutput());
return RunConfigurationFactory::decoratedTargetName(display, target()); return RunConfigurationFactory::decoratedTargetName(display, target());
} }
Tasks RemoteLinuxCustomRunConfiguration::checkForIssues() const Tasks RemoteLinuxCustomRunConfiguration::checkForIssues() const
{ {
Tasks tasks; Tasks tasks;
if (aspect<ExecutableAspect>()->executable().isEmpty()) { if (executable().isEmpty()) {
tasks << createConfigurationIssue(Tr::tr("The remote executable must be set in order to run " tasks << createConfigurationIssue(Tr::tr("The remote executable must be set in order to run "
"a custom remote run configuration.")); "a custom remote run configuration."));
} }