From 135a7682f5e34a1a4789a0c8e803a993f129a54b Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 5 Jul 2023 16:30:42 +0200 Subject: [PATCH] ProjectExplorer: Make more aspects directly usable in AspectContainers Change-Id: I6634c27c8d516411ad84e6cb7c361262ead53124 Reviewed-by: Christian Stenger --- .../projectexplorer/environmentaspect.cpp | 3 +- .../projectexplorer/environmentaspect.h | 2 +- .../runconfigurationaspects.cpp | 39 ++++++++++++++++--- .../projectexplorer/runconfigurationaspects.h | 16 ++++---- src/plugins/python/pythonrunconfiguration.cpp | 6 ++- .../qmlprojectrunconfiguration.cpp | 6 ++- .../remotelinuxcustomrunconfiguration.cpp | 7 +++- .../remotelinuxrunconfiguration.cpp | 7 +++- 8 files changed, 63 insertions(+), 23 deletions(-) diff --git a/src/plugins/projectexplorer/environmentaspect.cpp b/src/plugins/projectexplorer/environmentaspect.cpp index 09bfeb9c80d..e55e95156da 100644 --- a/src/plugins/projectexplorer/environmentaspect.cpp +++ b/src/plugins/projectexplorer/environmentaspect.cpp @@ -21,7 +21,8 @@ const char PRINT_ON_RUN_KEY[] = "PE.EnvironmentAspect.PrintOnRun"; // EnvironmentAspect: // -------------------------------------------------------------------- -EnvironmentAspect::EnvironmentAspect() +EnvironmentAspect::EnvironmentAspect(AspectContainer *container) + : BaseAspect(container) { setDisplayName(Tr::tr("Environment")); setId("EnvironmentAspect"); diff --git a/src/plugins/projectexplorer/environmentaspect.h b/src/plugins/projectexplorer/environmentaspect.h index 97ce26f017d..1de5641f6b0 100644 --- a/src/plugins/projectexplorer/environmentaspect.h +++ b/src/plugins/projectexplorer/environmentaspect.h @@ -20,7 +20,7 @@ class PROJECTEXPLORER_EXPORT EnvironmentAspect : public Utils::BaseAspect Q_OBJECT public: - EnvironmentAspect(); + EnvironmentAspect(Utils::AspectContainer *container = nullptr); // The environment including the user's modifications. Utils::Environment environment() const; diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index 59e814a56b6..5c0242d4a64 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -724,7 +724,8 @@ void ExecutableAspect::toMap(QVariantMap &map) const on Windows and LD_LIBRARY_PATH everywhere else. */ -UseLibraryPathsAspect::UseLibraryPathsAspect() +UseLibraryPathsAspect::UseLibraryPathsAspect(AspectContainer *container) + : BoolAspect(container) { setId("UseLibraryPath"); setSettingsKey("RunConfiguration.UseLibrarySearchPath"); @@ -749,7 +750,8 @@ UseLibraryPathsAspect::UseLibraryPathsAspect() DYLD_IMAGE_SUFFIX environment variable should be used on Mac. */ -UseDyldSuffixAspect::UseDyldSuffixAspect() +UseDyldSuffixAspect::UseDyldSuffixAspect(AspectContainer *container) + : BoolAspect(container) { setId("UseDyldSuffix"); setSettingsKey("RunConfiguration.UseDyldImageSuffix"); @@ -765,7 +767,8 @@ UseDyldSuffixAspect::UseDyldSuffixAspect() application should run with root permissions. */ -RunAsRootAspect::RunAsRootAspect() +RunAsRootAspect::RunAsRootAspect(AspectContainer *container) + : BoolAspect(container) { setId("RunAsRoot"); setSettingsKey("RunConfiguration.RunAsRoot"); @@ -794,7 +797,8 @@ Interpreter::Interpreter(const QString &_id, to use with files or projects using an interpreted language. */ -InterpreterAspect::InterpreterAspect() +InterpreterAspect::InterpreterAspect(AspectContainer *container) + : BaseAspect(container) { addDataExtractor(this, &InterpreterAspect::currentInterpreter, &Data::interpreter); } @@ -904,8 +908,8 @@ static QString defaultDisplay() return qtcEnvironmentVariable("DISPLAY"); } -X11ForwardingAspect::X11ForwardingAspect(const MacroExpander *expander) - : m_macroExpander(expander) +X11ForwardingAspect::X11ForwardingAspect(AspectContainer *container) + : StringAspect(container) { setLabelText(Tr::tr("X11 Forwarding:")); setDisplayStyle(LineEditDisplay); @@ -918,10 +922,33 @@ X11ForwardingAspect::X11ForwardingAspect(const MacroExpander *expander) addDataExtractor(this, &X11ForwardingAspect::display, &Data::display); } +void X11ForwardingAspect::setMacroExpander(const MacroExpander *expander) +{ + m_macroExpander = expander; +} + QString X11ForwardingAspect::display() const { QTC_ASSERT(m_macroExpander, return value()); return !isChecked() ? QString() : m_macroExpander->expandProcessArgs(value()); } + +/*! + \class ProjectExplorer::SymbolFileAspect + \inmodule QtCreator + + \brief The SymbolFileAspect class lets a user specify a symbol file + for debugging. +*/ + + +SymbolFileAspect::SymbolFileAspect(AspectContainer *container) + : FilePathAspect(container) +{} + +MainScriptAspect::MainScriptAspect(AspectContainer *container) + : StringAspect(container) +{} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h index 80b89cf7b72..384181be730 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.h +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -131,7 +131,7 @@ class PROJECTEXPLORER_EXPORT UseLibraryPathsAspect : public Utils::BoolAspect Q_OBJECT public: - UseLibraryPathsAspect(); + UseLibraryPathsAspect(Utils::AspectContainer *container = nullptr); }; class PROJECTEXPLORER_EXPORT UseDyldSuffixAspect : public Utils::BoolAspect @@ -139,7 +139,7 @@ class PROJECTEXPLORER_EXPORT UseDyldSuffixAspect : public Utils::BoolAspect Q_OBJECT public: - UseDyldSuffixAspect(); + UseDyldSuffixAspect(Utils::AspectContainer *container = nullptr); }; class PROJECTEXPLORER_EXPORT RunAsRootAspect : public Utils::BoolAspect @@ -147,7 +147,7 @@ class PROJECTEXPLORER_EXPORT RunAsRootAspect : public Utils::BoolAspect Q_OBJECT public: - RunAsRootAspect(); + RunAsRootAspect(Utils::AspectContainer *container = nullptr); }; class PROJECTEXPLORER_EXPORT ExecutableAspect : public Utils::BaseAspect @@ -197,7 +197,7 @@ class PROJECTEXPLORER_EXPORT SymbolFileAspect : public Utils::FilePathAspect Q_OBJECT public: - SymbolFileAspect() = default; + SymbolFileAspect(Utils::AspectContainer *container = nullptr); }; class PROJECTEXPLORER_EXPORT Interpreter @@ -227,7 +227,7 @@ class PROJECTEXPLORER_EXPORT InterpreterAspect : public Utils::BaseAspect Q_OBJECT public: - InterpreterAspect(); + InterpreterAspect(Utils::AspectContainer *container = nullptr); Interpreter currentInterpreter() const; void updateInterpreters(const QList &interpreters); @@ -256,7 +256,7 @@ class PROJECTEXPLORER_EXPORT MainScriptAspect : public Utils::StringAspect Q_OBJECT public: - MainScriptAspect() = default; + MainScriptAspect(Utils::AspectContainer *container = nullptr); }; class PROJECTEXPLORER_EXPORT X11ForwardingAspect : public Utils::StringAspect @@ -264,7 +264,9 @@ class PROJECTEXPLORER_EXPORT X11ForwardingAspect : public Utils::StringAspect Q_OBJECT public: - X11ForwardingAspect(const Utils::MacroExpander *macroExpander); + X11ForwardingAspect(Utils::AspectContainer *container = nullptr); + + void setMacroExpander(const Utils::MacroExpander *macroExpander); struct Data : StringAspect::Data { QString display; }; diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index 267036e63e2..04210a8b751 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -209,8 +209,10 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Id id) addAspect(); - if (HostOsInfo::isAnyUnixHost()) - addAspect(macroExpander()); + if (HostOsInfo::isAnyUnixHost()) { + auto x11Forwarding = addAspect(); + x11Forwarding->setMacroExpander(macroExpander()); + } setCommandLineGetter([bufferedAspect, interpreterAspect, argumentsAspect, scriptAspect] { CommandLine cmd{interpreterAspect->currentInterpreter().command}; diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 06b6f35c078..4b64440c5fc 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -166,8 +166,10 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id) return envModifier(environment); }); - if (HostOsInfo::isAnyUnixHost()) - addAspect(macroExpander()); + if (HostOsInfo::isAnyUnixHost()) { + auto x11Forwarding = addAspect(); + x11Forwarding->setMacroExpander(macroExpander()); + } setRunnableModifier([this](Runnable &r) { const QmlBuildSystem *bs = static_cast(activeBuildSystem()); diff --git a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp index 4d124a6be55..cbafc2423b5 100644 --- a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp @@ -55,8 +55,11 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar if (HostOsInfo::isAnyUnixHost()) addAspect(); - if (HostOsInfo::isAnyUnixHost()) - addAspect(macroExpander()); + + if (HostOsInfo::isAnyUnixHost()) { + auto x11Forwarding = addAspect(); + x11Forwarding->setMacroExpander(macroExpander()); + } setDefaultDisplayName(runConfigDefaultDisplayName()); } diff --git a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp index 9ea2618c09c..4234afaf745 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp @@ -56,8 +56,11 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id) if (HostOsInfo::isAnyUnixHost()) addAspect(); - if (HostOsInfo::isAnyUnixHost()) - addAspect(macroExpander()); + + if (HostOsInfo::isAnyUnixHost()) { + auto x11Forwarding = addAspect(); + x11Forwarding->setMacroExpander(macroExpander()); + } auto libAspect = addAspect(); libAspect->setValue(false);