RemoteLinux: Use new Run:setRunnableModifier

Change-Id: If5f509530f187dde6c6f5f8dc8b03ec8ab16bbfc
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-04-13 10:54:26 +02:00
parent 4d63206d95
commit e03af19edc
4 changed files with 34 additions and 45 deletions

View File

@@ -41,7 +41,20 @@ using namespace Utils;
namespace RemoteLinux {
namespace Internal {
RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Utils::Id id)
class RemoteLinuxCustomRunConfiguration : public RunConfiguration
{
Q_DECLARE_TR_FUNCTIONS(RemoteLinux::Internal::RemoteLinuxCustomRunConfiguration)
public:
RemoteLinuxCustomRunConfiguration(Target *target, Id id);
QString runConfigDefaultDisplayName();
private:
Tasks checkForIssues() const override;
};
RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id)
{
auto exeAspect = addAspect<ExecutableAspect>();
@@ -62,9 +75,14 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar
if (HostOsInfo::isAnyUnixHost())
addAspect<TerminalAspect>();
addAspect<RemoteLinuxEnvironmentAspect>(target);
if (Utils::HostOsInfo::isAnyUnixHost())
if (HostOsInfo::isAnyUnixHost())
addAspect<X11ForwardingAspect>();
setRunnableModifier([this](Runnable &r) {
if (const auto * const forwardingAspect = aspect<X11ForwardingAspect>())
r.extraData.insert("Ssh.X11ForwardToDisplay", forwardingAspect->display(macroExpander()));
});
setDefaultDisplayName(runConfigDefaultDisplayName());
}
@@ -76,14 +94,6 @@ QString RemoteLinuxCustomRunConfiguration::runConfigDefaultDisplayName()
return RunConfigurationFactory::decoratedTargetName(display, target());
}
Runnable RemoteLinuxCustomRunConfiguration::runnable() const
{
ProjectExplorer::Runnable r = RunConfiguration::runnable();
if (const auto * const forwardingAspect = aspect<X11ForwardingAspect>())
r.extraData.insert("Ssh.X11ForwardToDisplay", forwardingAspect->display(macroExpander()));
return r;
}
Tasks RemoteLinuxCustomRunConfiguration::checkForIssues() const
{
Tasks tasks;

View File

@@ -30,20 +30,6 @@
namespace RemoteLinux {
namespace Internal {
class RemoteLinuxCustomRunConfiguration : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
public:
RemoteLinuxCustomRunConfiguration(ProjectExplorer::Target *target, Utils::Id id);
QString runConfigDefaultDisplayName();
private:
ProjectExplorer::Runnable runnable() const override;
ProjectExplorer::Tasks checkForIssues() const override;
};
class RemoteLinuxCustomRunConfigurationFactory
: public ProjectExplorer::FixedRunConfigurationFactory
{

View File

@@ -46,7 +46,15 @@ using namespace Utils;
namespace RemoteLinux {
namespace Internal {
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Utils::Id id)
class RemoteLinuxRunConfiguration final : public RunConfiguration
{
Q_DECLARE_TR_FUNCTIONS(RemoteLinux::Internal::RemoteLinuxRunConfiguration)
public:
RemoteLinuxRunConfiguration(Target *target, Id id);
};
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id)
{
auto exeAspect = addAspect<ExecutableAspect>();
@@ -78,20 +86,16 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Utils::
symbolsAspect->setFilePath(localExecutable);
});
setRunnableModifier([this](Runnable &r) {
if (const auto * const forwardingAspect = aspect<X11ForwardingAspect>())
r.extraData.insert("Ssh.X11ForwardToDisplay", forwardingAspect->display(macroExpander()));
});
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
connect(target, &Target::deploymentDataChanged, this, &RunConfiguration::update);
connect(target, &Target::kitChanged, this, &RunConfiguration::update);
}
Runnable RemoteLinuxRunConfiguration::runnable() const
{
Runnable r = RunConfiguration::runnable();
const auto * const forwardingAspect = aspect<X11ForwardingAspect>();
if (forwardingAspect)
r.extraData.insert("Ssh.X11ForwardToDisplay", forwardingAspect->display(macroExpander()));
return r;
}
// RemoteLinuxRunConfigurationFactory
RemoteLinuxRunConfigurationFactory::RemoteLinuxRunConfigurationFactory()

View File

@@ -32,17 +32,6 @@
namespace RemoteLinux {
namespace Internal {
class RemoteLinuxRunConfiguration final : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
public:
RemoteLinuxRunConfiguration(ProjectExplorer::Target *target, Utils::Id id);
private:
ProjectExplorer::Runnable runnable() const override;
};
class RemoteLinuxRunConfigurationFactory final : public ProjectExplorer::RunConfigurationFactory
{
public: