aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2018-04-16 12:17:18 +0200
committerEike Ziller <eike.ziller@qt.io>2018-04-27 13:46:52 +0000
commit103d6e8d7b699c90a32deec1e9dcc07181e738d5 (patch)
tree2f419a1b0f2b8181b13d5f3b591283823ded7dde
parent8abeba7cd428411e9c74ad211dcac096c208ab38 (diff)
Adapt to upstream changes
Change-Id: I22bd72ee5b8d8a28d87459fe125ef3a211b9ad16 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--plugins/haskell/haskellconstants.h2
-rw-r--r--plugins/haskell/haskellproject.cpp1
-rw-r--r--plugins/haskell/haskellrunconfiguration.cpp80
-rw-r--r--plugins/haskell/haskellrunconfiguration.h25
4 files changed, 45 insertions, 63 deletions
diff --git a/plugins/haskell/haskellconstants.h b/plugins/haskell/haskellconstants.h
index db0f4dd..23463eb 100644
--- a/plugins/haskell/haskellconstants.h
+++ b/plugins/haskell/haskellconstants.h
@@ -31,9 +31,7 @@ namespace Constants {
const char C_HASKELLEDITOR_ID[] = "Haskell.HaskellEditor";
const char C_HASKELLSNIPPETSGROUP_ID[] = "Haskell";
const char C_HASKELL_PROJECT_MIMETYPE[] = "text/x-haskell-project";
-const char C_HASKELL_RUNCONFIG_ID[] = "Haskell.RunConfiguration";
const char C_HASKELL_PROJECT_ID[] = "Haskell.Project";
-const char C_HASKELL_EXECUTABLE_KEY[] = "Haskell.Executable";
const char OPTIONS_GENERAL[] = "Haskell.A.General";
} // namespace Haskell
diff --git a/plugins/haskell/haskellproject.cpp b/plugins/haskell/haskellproject.cpp
index e661f04..298c425 100644
--- a/plugins/haskell/haskellproject.cpp
+++ b/plugins/haskell/haskellproject.cpp
@@ -116,7 +116,6 @@ void HaskellProject::updateApplicationTargets(Target *target)
const QList<BuildTargetInfo> appTargets
= Utils::transform<QList>(executables, [projFilePath](const QString &executable) {
BuildTargetInfo bti;
- bti.targetName = executable;
bti.displayName = executable;
bti.buildKey = executable;
bti.targetFilePath = FileName::fromString(executable);
diff --git a/plugins/haskell/haskellrunconfiguration.cpp b/plugins/haskell/haskellrunconfiguration.cpp
index 57a7ded..89a33c3 100644
--- a/plugins/haskell/haskellrunconfiguration.cpp
+++ b/plugins/haskell/haskellrunconfiguration.cpp
@@ -36,8 +36,6 @@
#include <projectexplorer/runnables.h>
#include <projectexplorer/target.h>
-#include <QFormLayout>
-
using namespace ProjectExplorer;
namespace Haskell {
@@ -45,41 +43,48 @@ namespace Internal {
HaskellRunConfigurationFactory::HaskellRunConfigurationFactory()
{
- registerRunConfiguration<HaskellRunConfiguration>(Constants::C_HASKELL_RUNCONFIG_ID);
+ registerRunConfiguration<HaskellRunConfiguration>("Haskell.RunConfiguration");
addSupportedProjectType(Constants::C_HASKELL_PROJECT_ID);
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
}
-HaskellRunConfiguration::HaskellRunConfiguration(Target *parent)
- : RunConfiguration(parent, Constants::C_HASKELL_RUNCONFIG_ID)
+HaskellExecutableAspect::HaskellExecutableAspect(RunConfiguration *rc)
+ : BaseStringAspect(rc)
{
- auto argumentAspect = new ArgumentsAspect(this, "Haskell.RunAspect.Arguments");
+ setSettingsKey("Haskell.Executable");
+ setLabelText(tr("Executable"));
+ connect(rc->target(), &Target::applicationTargetsChanged,
+ this, &HaskellExecutableAspect::update);
+}
+
+void HaskellExecutableAspect::update()
+{
+ RunConfiguration *rc = runConfiguration();
+ BuildTargetInfo bti = rc->target()->applicationTargets().buildTargetInfo(rc->buildKey());
+ setValue(bti.targetFilePath.toString());
+}
+
+HaskellRunConfiguration::HaskellRunConfiguration(Target *target, Core::Id id)
+ : RunConfiguration(target, id)
+{
+ addExtraAspect(new HaskellExecutableAspect(this));
+ addExtraAspect(new ArgumentsAspect(this, "Haskell.RunAspect.Arguments"));
auto workingDirAspect = new WorkingDirectoryAspect(this, "Haskell.RunAspect.WorkingDirectory");
- workingDirAspect->setDefaultWorkingDirectory(parent->project()->projectDirectory());
- auto terminalAspect = new TerminalAspect(this, "Haskell.RunAspect.Terminal");
- auto environmentAspect
- = new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier());
- addExtraAspect(argumentAspect);
- addExtraAspect(terminalAspect);
- addExtraAspect(environmentAspect);
+ workingDirAspect->setDefaultWorkingDirectory(target->project()->projectDirectory());
+ addExtraAspect(new TerminalAspect(this, "Haskell.RunAspect.Terminal"));
+ addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
}
-QString HaskellRunConfiguration::extraId() const
+void HaskellRunConfiguration::fillConfigurationLayout(QFormLayout *layout) const
{
- // must be the RunConfigurationCreationInfo.targetName or .buildKey
- // (for Target::updateDefaultRunConfigurations())
- return m_executable;
+ extraAspect<HaskellExecutableAspect>()->addToConfigurationLayout(layout);
+ extraAspect<ArgumentsAspect>()->addToConfigurationLayout(layout);
+ extraAspect<TerminalAspect>()->addToConfigurationLayout(layout);
}
-QWidget *HaskellRunConfiguration::createConfigurationWidget()
+void HaskellRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &info)
{
- auto widget = new QWidget;
- auto layout = new QFormLayout(widget);
- layout->setMargin(0);
- layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
- extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(widget, layout);
- extraAspect<TerminalAspect>()->addToMainConfigurationWidget(widget, layout);
- return wrapWidget(widget);
+ extraAspect<HaskellExecutableAspect>()->setValue(info.buildKey);
}
Runnable HaskellRunConfiguration::runnable() const
@@ -92,7 +97,8 @@ Runnable HaskellRunConfiguration::runnable() const
.relativeFilePath(
buildConfiguration->buildDirectory().toString())
+ "\" ";
- r.commandLineArguments += "exec \"" + m_executable + "\"";
+ QString executable = extraAspect<HaskellExecutableAspect>()->value();
+ r.commandLineArguments += "exec \"" + executable + "\"";
auto argumentsAspect = extraAspect<ArgumentsAspect>();
if (!argumentsAspect->arguments().isEmpty())
r.commandLineArguments += " -- " + argumentsAspect->arguments();
@@ -103,27 +109,5 @@ Runnable HaskellRunConfiguration::runnable() const
return r;
}
-bool HaskellRunConfiguration::fromMap(const QVariantMap &map)
-{
- if (!RunConfiguration::fromMap(map))
- return false;
- m_executable = map.value(QString(Constants::C_HASKELL_EXECUTABLE_KEY)).toString();
- setDefaultDisplayName(m_executable);
- return true;
-}
-
-void HaskellRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &info)
-{
- m_executable = info.targetName;
- setDefaultDisplayName(m_executable);
-}
-
-QVariantMap HaskellRunConfiguration::toMap() const
-{
- QVariantMap map = RunConfiguration::toMap();
- map.insert(QString(Constants::C_HASKELL_EXECUTABLE_KEY), m_executable);
- return map;
-}
-
} // namespace Internal
} // namespace Haskell
diff --git a/plugins/haskell/haskellrunconfiguration.h b/plugins/haskell/haskellrunconfiguration.h
index 83efde7..536124d 100644
--- a/plugins/haskell/haskellrunconfiguration.h
+++ b/plugins/haskell/haskellrunconfiguration.h
@@ -25,7 +25,7 @@
#pragma once
-#include <projectexplorer/runconfiguration.h>
+#include <projectexplorer/runconfigurationaspects.h>
namespace Haskell {
namespace Internal {
@@ -36,25 +36,26 @@ public:
HaskellRunConfigurationFactory();
};
-class HaskellRunConfiguration : public ProjectExplorer::RunConfiguration
+class HaskellExecutableAspect : public ProjectExplorer::BaseStringAspect
{
Q_OBJECT
public:
- HaskellRunConfiguration(ProjectExplorer::Target *parent);
+ HaskellExecutableAspect(ProjectExplorer::RunConfiguration *rc);
+ void update();
+};
- QString extraId() const final;
+class HaskellRunConfiguration : public ProjectExplorer::RunConfiguration
+{
+ Q_OBJECT
-private:
- QWidget *createConfigurationWidget() final;
- ProjectExplorer::Runnable runnable() const final;
- void handleBuildSystemDataUpdated();
+public:
+ HaskellRunConfiguration(ProjectExplorer::Target *target, Core::Id id);
- bool fromMap(const QVariantMap &map) final;
- QVariantMap toMap() const final;
+private:
+ void fillConfigurationLayout(QFormLayout *layout) const final;
void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &info) final;
-
- QString m_executable;
+ ProjectExplorer::Runnable runnable() const final;
};
} // namespace Internal