diff --git a/src/plugins/projectexplorer/environment.h b/src/plugins/projectexplorer/environment.h index e76ccc0cb99ae806cde64a5b2fd84aaadb374801..1bd145caffd096e1c8b7fae11416165217e09f85 100644 --- a/src/plugins/projectexplorer/environment.h +++ b/src/plugins/projectexplorer/environment.h @@ -49,6 +49,11 @@ struct PROJECTEXPLORER_EXPORT EnvironmentItem QString value; bool unset; + bool operator==(const EnvironmentItem &other) + { + return (unset == other.unset) && (name == other.name) && (value == other.value); + } + static QList<EnvironmentItem> fromStringList(QStringList list); static QStringList toStringList(QList<EnvironmentItem> list); }; diff --git a/src/plugins/projectexplorer/environmenteditmodel.h b/src/plugins/projectexplorer/environmenteditmodel.h index 3d8475bc1725621ece0d5ec54e9c229988f48668..25d190694d713f8daa091bcc829ca033cf282934 100644 --- a/src/plugins/projectexplorer/environmenteditmodel.h +++ b/src/plugins/projectexplorer/environmenteditmodel.h @@ -96,9 +96,10 @@ public: ~EnvironmentWidget(); void setBaseEnvironment(const ProjectExplorer::Environment &env); - void setMergedEnvironments(bool b); + void setMergedEnvironments(bool b); bool mergedEnvironments(); + QList<EnvironmentItem> userChanges() const; void setUserChanges(QList<EnvironmentItem> list); diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp index 4f339e0519e1e17ef0aac6ef9e1e65508d96b6e6..c51f67fc5f2a7c0438bc7f3870ddd7cf654663a4 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp @@ -39,6 +39,7 @@ #include <coreplugin/variablemanager.h> #include <coreplugin/ifile.h> #include <projectexplorer/buildstep.h> +#include <projectexplorer/environmenteditmodel.h> #include <utils/qtcassert.h> #include <QtGui/QFormLayout> @@ -135,6 +136,11 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run this, SLOT(usingDyldImageSuffixToggled(bool))); #endif + m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this); + m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment()); + m_environmentWidget->setUserChanges(m_qt4RunConfiguration->userEnvironmentChanges()); + toplayout->addRow(m_environmentWidget); + connect(m_workingDirectoryEdit, SIGNAL(changed()), this, SLOT(setWorkingDirectory())); @@ -148,6 +154,9 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run connect(m_useTerminalCheck, SIGNAL(toggled(bool)), this, SLOT(termToggled(bool))); + connect(m_environmentWidget, SIGNAL(userChangesUpdated()), + this, SLOT(userChangesUpdated())); + connect(qt4RunConfiguration, SIGNAL(workingDirectoryChanged(QString)), this, SLOT(workingDirectoryChanged(QString))); @@ -159,9 +168,26 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run this, SLOT(runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode))); connect(qt4RunConfiguration, SIGNAL(usingDyldImageSuffixChanged(bool)), this, SLOT(usingDyldImageSuffixChanged(bool))); - connect(qt4RunConfiguration, SIGNAL(effectiveTargetInformationChanged()), this, SLOT(effectiveTargetInformationChanged()), Qt::QueuedConnection); + + connect(qt4RunConfiguration, SIGNAL(userEnvironmentChangesChanged(QList<ProjectExplorer::EnvironmentItem>)), + this, SLOT(userEnvironmentChangesChanged(QList<ProjectExplorer::EnvironmentItem>))); + +} + +void Qt4RunConfigurationWidget::userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges) +{ + if (m_ignoreChange) + return; + m_environmentWidget->setUserChanges(userChanges); +} + +void Qt4RunConfigurationWidget::userChangesUpdated() +{ + m_ignoreChange = true; + m_qt4RunConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges()); + m_ignoreChange = false; } void Qt4RunConfigurationWidget::setWorkingDirectory() @@ -276,6 +302,7 @@ void Qt4RunConfiguration::save(PersistentSettingsWriter &writer) const writer.saveValue("UserSetName", m_userSetName); writer.saveValue("UseTerminal", m_runMode == Console); writer.saveValue("UseDyldImageSuffix", m_isUsingDyldImageSuffix); + writer.saveValue("UserEnvironmentChanges", ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges)); ApplicationRunConfiguration::save(writer); } @@ -293,6 +320,7 @@ void Qt4RunConfiguration::restore(const PersistentSettingsReader &reader) if (!m_userSetName) setName(QFileInfo(m_proFilePath).completeBaseName()); } + m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(reader.restoreValue("UserEnvironmentChanges").toStringList()); } QString Qt4RunConfiguration::executable() const @@ -333,8 +361,13 @@ QStringList Qt4RunConfiguration::commandLineArguments() const return m_commandLineArguments; } -ProjectExplorer::Environment Qt4RunConfiguration::environment() const +ProjectExplorer::Environment Qt4RunConfiguration::baseEnvironment() const { + // TODO use either System Environment + // build environment + // or empty + //Environment env = Environment(QProcess::systemEnvironment()); + Qt4Project *pro = qobject_cast<Qt4Project *>(project()); Q_ASSERT(pro); QString config = pro->activeBuildConfiguration(); @@ -345,6 +378,26 @@ ProjectExplorer::Environment Qt4RunConfiguration::environment() const return env; } +ProjectExplorer::Environment Qt4RunConfiguration::environment() const +{ + ProjectExplorer::Environment env = baseEnvironment(); + env.modify(userEnvironmentChanges()); + return env; +} + +QList<ProjectExplorer::EnvironmentItem> Qt4RunConfiguration::userEnvironmentChanges() const +{ + return m_userEnvironmentChanges; +} + +void Qt4RunConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff) +{ + if (m_userEnvironmentChanges != diff) { + m_userEnvironmentChanges = diff; + emit userEnvironmentChangesChanged(diff); + } +} + void Qt4RunConfiguration::setWorkingDirectory(const QString &wd) { if (wd== "") { diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.h b/src/plugins/qt4projectmanager/qt4runconfiguration.h index 6f6e480700aceaeafe5d56aca9be1b275859ff42..8572607c9b5291e0c1a8f777e3e734835c879bfa 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.h +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.h @@ -32,6 +32,8 @@ #include <utils/pathchooser.h> #include <projectexplorer/applicationrunconfiguration.h> +#include <projectexplorer/environment.h> +#include <projectexplorer/environmenteditmodel.h> #include <QtCore/QStringList> #include <QtGui/QWidget> @@ -53,7 +55,7 @@ class Qt4PriFileNode; class Qt4RunConfiguration : public ProjectExplorer::ApplicationRunConfiguration { Q_OBJECT - // to change the name and arguments + // to change the name and arguments and set the userenvironmentchanges friend class Qt4RunConfigurationWidget; public: Qt4RunConfiguration(Qt4Project *pro, const QString &proFilePath); @@ -91,6 +93,7 @@ signals: void workingDirectoryChanged(const QString&); void runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode runMode); void usingDyldImageSuffixChanged(bool); + void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff); // note those signals might not emited for every change void effectiveTargetInformationChanged(); @@ -102,6 +105,10 @@ private slots: void setRunMode(RunMode runMode); private: + ProjectExplorer::Environment baseEnvironment() const; + void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff); + QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const; + void updateTarget(); QStringList m_commandLineArguments; QString m_proFilePath; // Full path to the Application Pro File @@ -117,6 +124,7 @@ private: bool m_isUsingDyldImageSuffix; bool m_userSetWokingDirectory; QString m_userWorkingDirectory; + QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges; }; class Qt4RunConfigurationWidget : public QWidget @@ -132,11 +140,13 @@ private slots: void resetWorkingDirectory(); void setCommandLineArguments(const QString &arguments); void nameEdited(const QString &name); + void userChangesUpdated(); void workingDirectoryChanged(const QString &workingDirectory); void commandLineArgumentsChanged(const QString &args); void nameChanged(const QString &name); void runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode runMode); + void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges); void effectiveTargetInformationChanged(); void termToggled(bool); @@ -151,6 +161,7 @@ private: QLineEdit *m_argumentsLineEdit; QCheckBox *m_useTerminalCheck; QCheckBox *m_usingDyldImageSuffix; + ProjectExplorer::EnvironmentWidget *m_environmentWidget; bool m_isShown; };