Commit 345ee7df authored by dt's avatar dt
Browse files

Basic stuff for setting the environment of qt4runconfigurations

Missing is options to base the environment on either:
- the last build buildconfiguration (current implementation)
- the project environment
- a clean environment

signals which indicate that the baseEnvironment changed
some layout stuff is wrong
parent 9f65fb80
......@@ -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);
};
......
......@@ -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);
......
......@@ -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== "") {
......
......@@ -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;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment