// Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "remotelinuxcustomrunconfiguration.h" #include "remotelinux_constants.h" #include "remotelinuxtr.h" #include "remotelinuxenvironmentaspect.h" #include #include #include #include using namespace ProjectExplorer; using namespace Utils; namespace RemoteLinux::Internal { class RemoteLinuxCustomRunConfiguration : public RunConfiguration { public: RemoteLinuxCustomRunConfiguration(Target *target, Id id); QString runConfigDefaultDisplayName(); private: Tasks checkForIssues() const override; }; RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { auto envAspect = addAspect(target); auto exeAspect = addAspect(target, ExecutableAspect::RunDevice); exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable"); exeAspect->setLabelText(Tr::tr("Remote executable:")); exeAspect->setDisplayStyle(StringAspect::LineEditDisplay); exeAspect->setHistoryCompleter("RemoteLinux.CustomExecutable.History"); exeAspect->setExpectedKind(PathChooser::Any); auto symbolsAspect = addAspect(); symbolsAspect->setSettingsKey("RemoteLinux.CustomRunConfig.LocalExecutable"); symbolsAspect->setLabelText(Tr::tr("Local executable:")); symbolsAspect->setDisplayStyle(SymbolFileAspect::PathChooserDisplay); addAspect(macroExpander()); addAspect(macroExpander(), envAspect); if (HostOsInfo::isAnyUnixHost()) addAspect(); if (HostOsInfo::isAnyUnixHost()) addAspect(macroExpander()); setRunnableModifier([this](Runnable &r) { if (const auto * const forwardingAspect = aspect()) r.extraData.insert("Ssh.X11ForwardToDisplay", forwardingAspect->display()); }); setDefaultDisplayName(runConfigDefaultDisplayName()); } QString RemoteLinuxCustomRunConfiguration::runConfigDefaultDisplayName() { QString remoteExecutable = aspect()->executable().toString(); QString display = remoteExecutable.isEmpty() ? Tr::tr("Custom Executable") : Tr::tr("Run \"%1\"").arg(remoteExecutable); return RunConfigurationFactory::decoratedTargetName(display, target()); } Tasks RemoteLinuxCustomRunConfiguration::checkForIssues() const { Tasks tasks; if (aspect()->executable().isEmpty()) { tasks << createConfigurationIssue(Tr::tr("The remote executable must be set in order to run " "a custom remote run configuration.")); } return tasks; } // RemoteLinuxCustomRunConfigurationFactory RemoteLinuxCustomRunConfigurationFactory::RemoteLinuxCustomRunConfigurationFactory() : FixedRunConfigurationFactory(Tr::tr("Custom Executable"), true) { registerRunConfiguration(Constants::CustomRunConfigId); addSupportedTargetDeviceType(RemoteLinux::Constants::GenericLinuxOsType); } } // RemoteLinux::Internal