From 8d659cb7dbdf2defca078cc1d892cc2c6f50595c Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 2 Jun 2022 18:16:46 +0200 Subject: [PATCH] RemoteLinux: Slimmer interface of custom command deploy step handling Change-Id: Iad10d6bd111c9f06adb510aae19e861bbce3425d Reviewed-by: Jarek Kobus --- .../remotelinux/customcommanddeploystep.cpp | 69 ++++++++++--------- .../remotelinux/customcommanddeploystep.h | 17 ++--- src/plugins/remotelinux/remotelinuxplugin.cpp | 2 +- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/src/plugins/remotelinux/customcommanddeploystep.cpp b/src/plugins/remotelinux/customcommanddeploystep.cpp index 318d5cd7a47..fef2d103f6c 100644 --- a/src/plugins/remotelinux/customcommanddeploystep.cpp +++ b/src/plugins/remotelinux/customcommanddeploystep.cpp @@ -26,6 +26,7 @@ #include "customcommanddeploystep.h" #include "abstractremotelinuxdeployservice.h" +#include "abstractremotelinuxdeploystep.h" #include "remotelinux_constants.h" #include @@ -108,35 +109,41 @@ void CustomCommandDeployService::stopDeployment() handleDeploymentDone(); } +class CustomCommandDeployStep : public AbstractRemoteLinuxDeployStep +{ + Q_DECLARE_TR_FUNCTIONS(RemoteLinux::Internal::CustomCommandDeployStep) + +public: + CustomCommandDeployStep(BuildStepList *bsl, Id id) + : AbstractRemoteLinuxDeployStep(bsl, id) + { + auto service = createDeployService(); + + auto commandLine = addAspect(); + commandLine->setSettingsKey("RemoteLinuxCustomCommandDeploymentStep.CommandLine"); + commandLine->setLabelText(tr("Command line:")); + commandLine->setDisplayStyle(StringAspect::LineEditDisplay); + commandLine->setHistoryCompleter("RemoteLinuxCustomCommandDeploymentStep.History"); + + setInternalInitializer([service, commandLine] { + service->setCommandLine(commandLine->value().trimmed()); + return service->isDeploymentPossible(); + }); + + addMacroExpander(); + } +}; + + +// CustomCommandDeployStepFactory + +CustomCommandDeployStepFactory::CustomCommandDeployStepFactory() +{ + registerStep(Constants::CustomCommandDeployStepId); + setDisplayName(CustomCommandDeployStep::tr("Run custom remote command")); + setSupportedConfiguration(RemoteLinux::Constants::DeployToGenericLinux); + setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); +} + } // Internal - -CustomCommandDeployStep::CustomCommandDeployStep(BuildStepList *bsl, Utils::Id id) - : AbstractRemoteLinuxDeployStep(bsl, id) -{ - auto service = createDeployService(); - - auto commandLine = addAspect(); - commandLine->setSettingsKey("RemoteLinuxCustomCommandDeploymentStep.CommandLine"); - commandLine->setLabelText(tr("Command line:")); - commandLine->setDisplayStyle(StringAspect::LineEditDisplay); - commandLine->setHistoryCompleter("RemoteLinuxCustomCommandDeploymentStep.History"); - - setInternalInitializer([service, commandLine] { - service->setCommandLine(commandLine->value().trimmed()); - return service->isDeploymentPossible(); - }); - - addMacroExpander(); -} - -Utils::Id CustomCommandDeployStep::stepId() -{ - return Constants::CustomCommandDeployStepId; -} - -QString CustomCommandDeployStep::displayName() -{ - return tr("Run custom remote command"); -} - -} // namespace RemoteLinux +} // RemoteLinux diff --git a/src/plugins/remotelinux/customcommanddeploystep.h b/src/plugins/remotelinux/customcommanddeploystep.h index 0a9503d666b..09b6aaceafc 100644 --- a/src/plugins/remotelinux/customcommanddeploystep.h +++ b/src/plugins/remotelinux/customcommanddeploystep.h @@ -25,21 +25,16 @@ #pragma once -#include "remotelinux_export.h" - -#include "abstractremotelinuxdeploystep.h" +#include namespace RemoteLinux { +namespace Internal { -class REMOTELINUX_EXPORT CustomCommandDeployStep : public AbstractRemoteLinuxDeployStep +class CustomCommandDeployStepFactory : public ProjectExplorer::BuildStepFactory { - Q_OBJECT - public: - CustomCommandDeployStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); - - static Utils::Id stepId(); - static QString displayName(); + CustomCommandDeployStepFactory(); }; -} // namespace RemoteLinux +} // Internal +} // RemoteLinux diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index c0aa4e162e7..1f072a38a50 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -78,7 +78,7 @@ public: TarPackageDeployStepFactory tarPackageDeployStepFactory; GenericDeployStepFactory genericDirectUploadStepFactory; GenericDeployStepFactory rsyncDeployStepFactory; - GenericDeployStepFactory customCommandDeployStepFactory; + CustomCommandDeployStepFactory customCommandDeployStepFactory; GenericDeployStepFactory checkForFreeDiskSpaceStepFactory; GenericDeployStepFactory killAppStepFactory; GenericDeployStepFactory makeInstallStepFactory;