diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index ab4887c52f2b2c19b59a0a906869dd4a86687c1a..988c49ddc9643d05c6db9c697c7b7b24fa915cfd 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -459,7 +459,10 @@ ProjectExplorer::Environment CMakeProject::environment(const QString &buildConfi void CMakeProject::setUseSystemEnvironment(const QString &buildConfiguration, bool b) { + if (b == useSystemEnvironment(buildConfiguration)) + return; setValue(buildConfiguration, "clearSystemEnvironment", !b); + emit environmentChanged(buildConfiguration); } bool CMakeProject::useSystemEnvironment(const QString &buildConfiguration) const @@ -475,7 +478,11 @@ QList<ProjectExplorer::EnvironmentItem> CMakeProject::userEnvironmentChanges(con void CMakeProject::setUserEnvironmentChanges(const QString &buildConfig, const QList<ProjectExplorer::EnvironmentItem> &diff) { + QStringList list = EnvironmentItem::toStringList(diff); + if (list == value(buildConfig, "userEnvironmentChanges")) + return; setValue(buildConfig, "userEnvironmentChanges", EnvironmentItem::toStringList(diff)); + emit environmentChanged(buildConfig); } QString CMakeProject::buildDirectory(const QString &buildConfiguration) const diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index 08fa7c1d07b4b81d2af712c4c2ef9f45bf2a99ed..cb66f9a8e342dc5df43778d35b37f86576395c02 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -49,6 +49,12 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &t , m_title(title) { setName(title); + + connect(pro, SIGNAL(activeBuildConfigurationChanged()), + this, SIGNAL(baseEnvironmentChanged())); + + connect(pro, SIGNAL(environmentChanged(QString)), + this, SIGNAL(baseEnvironmentChanged())); } CMakeRunConfiguration::~CMakeRunConfiguration() @@ -80,11 +86,6 @@ QStringList CMakeRunConfiguration::commandLineArguments() const return ProjectExplorer::Environment::parseCombinedArgString(m_arguments); } -ProjectExplorer::Environment CMakeRunConfiguration::environment() const -{ - return project()->environment(project()->activeBuildConfiguration()); -} - QString CMakeRunConfiguration::title() const { return m_title; @@ -108,6 +109,7 @@ void CMakeRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writ writer.saveValue("CMakeRunConfiguration.UseTerminal", m_runMode == Console); writer.saveValue("CMakeRunConfiguation.Title", m_title); writer.saveValue("CMakeRunConfiguration.Arguments", m_arguments); + writer.saveValue("CMakeRunConfiguration.UserEnvironmentChanges", ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges)); } void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader) @@ -118,19 +120,12 @@ void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsRea m_runMode = reader.restoreValue("CMakeRunConfiguration.UseTerminal").toBool() ? Console : Gui; m_title = reader.restoreValue("CMakeRunConfiguation.Title").toString(); m_arguments = reader.restoreValue("CMakeRunConfiguration.Arguments").toString(); + m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(reader.restoreValue("CMakeRunConfiguration.UserEnvironmentChanges").toStringList()); } QWidget *CMakeRunConfiguration::configurationWidget() { - QWidget *widget = new QWidget(); - QFormLayout *fl = new QFormLayout(); - widget->setLayout(fl); - QLineEdit *argumentsLineEdit = new QLineEdit(widget); - argumentsLineEdit->setText(m_arguments); - connect(argumentsLineEdit, SIGNAL(textChanged(QString)), - this, SLOT(setArguments(QString))); - fl->addRow(tr("Arguments:"), argumentsLineEdit); - return widget; + return new CMakeRunConfigurationWidget(this); } void CMakeRunConfiguration::setArguments(const QString &newText) @@ -145,6 +140,89 @@ QString CMakeRunConfiguration::dumperLibrary() const return dhl; } +ProjectExplorer::Environment CMakeRunConfiguration::baseEnvironment() const +{ + // TODO use either System Environment + // build environment + // or empty + //Environment env = Environment(QProcess::systemEnvironment()); + + QString config = project()->activeBuildConfiguration(); + ProjectExplorer::Environment env = project()->environment(project()->activeBuildConfiguration()); + return env; +} + +ProjectExplorer::Environment CMakeRunConfiguration::environment() const +{ + ProjectExplorer::Environment env = baseEnvironment(); + env.modify(userEnvironmentChanges()); + return env; +} + +QList<ProjectExplorer::EnvironmentItem> CMakeRunConfiguration::userEnvironmentChanges() const +{ + return m_userEnvironmentChanges; +} + +void CMakeRunConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff) +{ + if (m_userEnvironmentChanges != diff) { + m_userEnvironmentChanges = diff; + emit userEnvironmentChangesChanged(diff); + } +} + +// Configuration widget + + +CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent) + : QWidget(parent), m_cmakeRunConfiguration(cmakeRunConfiguration) +{ + + QFormLayout *fl = new QFormLayout(); + QLineEdit *argumentsLineEdit = new QLineEdit(); + argumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(cmakeRunConfiguration->commandLineArguments())); + connect(argumentsLineEdit, SIGNAL(textChanged(QString)), + this, SLOT(setArguments(QString))); + fl->addRow(tr("Arguments:"), argumentsLineEdit); + + QVBoxLayout *vbx = new QVBoxLayout(this); + vbx->addLayout(fl); + m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this); + vbx->addWidget(m_environmentWidget); + m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment()); + m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges()); + + connect(m_environmentWidget, SIGNAL(userChangesUpdated()), + this, SLOT(userChangesUpdated())); + + connect(m_cmakeRunConfiguration, SIGNAL(baseEnvironmentChanged()), + this, SLOT(baseEnvironmentChanged())); + connect(m_cmakeRunConfiguration, SIGNAL(userEnvironmentChangesChanged(QList<ProjectExplorer::EnvironmentItem>)), + this, SLOT(userEnvironmentChangesChanged())); +} + +void CMakeRunConfigurationWidget::userChangesUpdated() +{ + m_cmakeRunConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges()); +} + +void CMakeRunConfigurationWidget::baseEnvironmentChanged() +{ + m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment()); +} + +void CMakeRunConfigurationWidget::userEnvironmentChangesChanged() +{ + m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges()); +} + +void CMakeRunConfigurationWidget::setArguments(const QString &args) +{ + m_cmakeRunConfiguration->setArguments(args); +} + + // Factory CMakeRunConfigurationFactory::CMakeRunConfigurationFactory() { diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h index f014894a67df02e7d513a83f4146f8b16cfbc583..20ab7415143406074b10d63aba3a75592192652e 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h @@ -33,6 +33,7 @@ #include <projectexplorer/applicationrunconfiguration.h> #include <projectexplorer/environment.h> #include <projectexplorer/persistentsettings.h> +#include <projectexplorer/environmenteditmodel.h> namespace CMakeProjectManager { namespace Internal { @@ -41,6 +42,7 @@ class CMakeProject; class CMakeRunConfiguration : public ProjectExplorer::ApplicationRunConfiguration { + friend class CMakeRunConfigurationWidget; Q_OBJECT public: CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory, const QString &title); @@ -62,24 +64,40 @@ public: virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader); virtual QString dumperLibrary() const; +signals: + void baseEnvironmentChanged(); + void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff); + private slots: void setArguments(const QString &newText); private: + ProjectExplorer::Environment baseEnvironment() const; + void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff); + QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const; + RunMode m_runMode; QString m_target; QString m_workingDirectory; QString m_title; QString m_arguments; + QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges; +}; + +class CMakeRunConfigurationWidget : public QWidget +{ + Q_OBJECT +public: + CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent = 0); +private slots: + void setArguments(const QString &args); + void baseEnvironmentChanged(); + void userEnvironmentChangesChanged(); + void userChangesUpdated(); +private: + CMakeRunConfiguration *m_cmakeRunConfiguration; + ProjectExplorer::EnvironmentWidget *m_environmentWidget; }; -/* The run configuration factory is used for restoring run configurations from - * settings. And used to create new runconfigurations in the "Run Settings" Dialog. - * For the first case bool canCreate(const QString &type) and - * QSharedPointer<RunConfiguration> create(Project *project, QString type) are used. - * For the second type the functions QStringList canCreate(Project *pro) and - * QString nameForType(const QString&) are used to generate a list of creatable - * RunConfigurations, and create(..) is used to create it. - */ class CMakeRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory { Q_OBJECT; diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 1953e9635500d9c4359109a16d53b80e515cfb8e..9efea6c444a03ae89c972412d8a8557a909c8270 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -63,10 +63,8 @@ public: }; CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc) - : m_ignoreChange(false) + : m_ignoreChange(false), m_runConfiguration(rc) { - m_runConfiguration = rc; - QFormLayout *layout = new QFormLayout; layout->setMargin(0); @@ -88,7 +86,14 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE m_useTerminalCheck = new QCheckBox(tr("Run in &Terminal"), this); layout->addRow(QString(), m_useTerminalCheck); - setLayout(layout); + m_environmentWidget = new EnvironmentWidget(this); + m_environmentWidget->setBaseEnvironment(rc->baseEnvironment()); + m_environmentWidget->setUserChanges(rc->userEnvironmentChanges()); + + QVBoxLayout *vbox = new QVBoxLayout(this); + vbox->addLayout(layout); + vbox->addWidget(m_environmentWidget); + changed(); connect(m_userName, SIGNAL(textEdited(QString)), @@ -103,8 +108,32 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE this, SLOT(termToggled(bool))); connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed())); + + connect(m_environmentWidget, SIGNAL(userChangesUpdated()), + this, SLOT(userChangesUpdated())); + + connect(m_runConfiguration, SIGNAL(baseEnvironmentChanged()), + this, SLOT(baseEnvironmentChanged())); + connect(m_runConfiguration, SIGNAL(userEnvironmentChangesChanged(QList<ProjectExplorer::EnvironmentItem>)), + this, SLOT(userEnvironmentChangesChanged())); +} + +void CustomExecutableConfigurationWidget::userChangesUpdated() +{ + m_runConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges()); +} + +void CustomExecutableConfigurationWidget::baseEnvironmentChanged() +{ + m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment()); +} + +void CustomExecutableConfigurationWidget::userEnvironmentChangesChanged() +{ + m_environmentWidget->setUserChanges(m_runConfiguration->userEnvironmentChanges()); } + void CustomExecutableConfigurationWidget::setExecutable() { m_ignoreChange = true; @@ -158,6 +187,13 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro) { m_workingDirectory = "$BUILDDIR"; setName(tr("Custom Executable")); + + connect(pro, SIGNAL(activeBuildConfigurationChanged()), + this, SIGNAL(baseEnvironmentChanged())); + + connect(pro, SIGNAL(environmentChanged(QString)), + this, SIGNAL(baseEnvironmentChanged())); + } CustomExecutableRunConfiguration::~CustomExecutableRunConfiguration() @@ -241,11 +277,37 @@ QStringList CustomExecutableRunConfiguration::commandLineArguments() const return m_cmdArguments; } -Environment CustomExecutableRunConfiguration::environment() const +ProjectExplorer::Environment CustomExecutableRunConfiguration::baseEnvironment() const +{ + // TODO use either System Environment + // build environment + // or empty + //Environment env = Environment(QProcess::systemEnvironment()); + + QString config = project()->activeBuildConfiguration(); + ProjectExplorer::Environment env = project()->environment(project()->activeBuildConfiguration()); + return env; +} + +ProjectExplorer::Environment CustomExecutableRunConfiguration::environment() const +{ + ProjectExplorer::Environment env = baseEnvironment(); + env.modify(userEnvironmentChanges()); + return env; +} + +QList<ProjectExplorer::EnvironmentItem> CustomExecutableRunConfiguration::userEnvironmentChanges() const { - return project()->environment(project()->activeBuildConfiguration()); + return m_userEnvironmentChanges; } +void CustomExecutableRunConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff) +{ + if (m_userEnvironmentChanges != diff) { + m_userEnvironmentChanges = diff; + emit userEnvironmentChangesChanged(diff); + } +} void CustomExecutableRunConfiguration::save(PersistentSettingsWriter &writer) const { @@ -255,6 +317,7 @@ void CustomExecutableRunConfiguration::save(PersistentSettingsWriter &writer) co writer.saveValue("UseTerminal", m_runMode == Console); writer.saveValue("UserSetName", m_userSetName); writer.saveValue("UserName", m_userName); + writer.saveValue("UserEnvironmentChanges", ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges)); ApplicationRunConfiguration::save(writer); } @@ -266,6 +329,7 @@ void CustomExecutableRunConfiguration::restore(const PersistentSettingsReader &r m_runMode = reader.restoreValue("UseTerminal").toBool() ? Console : Gui; m_userSetName = reader.restoreValue("UserSetName").toBool(); m_userName = reader.restoreValue("UserName").toString(); + m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(reader.restoreValue("UserEnvironmentChanges").toStringList()); ApplicationRunConfiguration::restore(reader); } diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.h b/src/plugins/projectexplorer/customexecutablerunconfiguration.h index 107c889f954c4e9e72128612af856ababa7f03ca..7487770538a35ec1312b1ea8c4e15f58fc781c6c 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.h +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.h @@ -33,6 +33,7 @@ #include "applicationrunconfiguration.h" #include <utils/pathchooser.h> +#include <projectexplorer/environmenteditmodel.h> #include <QtGui/QToolButton> @@ -91,7 +92,15 @@ public: signals: void changed(); + void baseEnvironmentChanged(); + void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff); + + private: + ProjectExplorer::Environment baseEnvironment() const; + void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff); + QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const; + void setExecutable(const QString &executable); void setCommandLineArguments(const QString &commandLineArguments); void setWorkingDirectory(const QString &workingDirectory); @@ -103,6 +112,7 @@ private: RunMode m_runMode; bool m_userSetName; QString m_userName; + QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges; }; class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory @@ -137,6 +147,10 @@ private slots: void setWorkingDirectory(); void termToggled(bool); + void userChangesUpdated(); + void baseEnvironmentChanged(); + void userEnvironmentChangesChanged(); + private: bool m_ignoreChange; CustomExecutableRunConfiguration *m_runConfiguration; @@ -145,6 +159,7 @@ private: QLineEdit *m_commandLineArgumentsLineEdit; Core::Utils::PathChooser *m_workingDirectory; QCheckBox *m_useTerminalCheck; + ProjectExplorer::EnvironmentWidget *m_environmentWidget; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index ef87bc6ec03fed06aeef6229a90fb65136d7622f..aa794d49664e1fb26d4486d02b7a9191891c900a 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -65,6 +65,7 @@ QtVersionManager *QtVersionManager::m_self = 0; QtVersionManager::QtVersionManager() : m_emptyVersion(new QtVersion) { + m_self = this; QSettings *s = Core::ICore::instance()->settings(); m_defaultVersion = s->value(defaultQtVersionKey, 0).toInt();