Add a few options to the runconfigurations base environment

Note: This code should be shared between Qt4RunConfiguration,
CMakeRunConfiguration and CustomRunExecutable. Also we are approaching
other IDEs like configuraion options for setting the environment.
Without having a good GUI for that. I'll probably be redesigning this
for 1.3 or 1.4.
This commit is contained in:
dt
2009-05-28 16:34:31 +02:00
parent fb58a9ed39
commit 48167ee5f1
3 changed files with 100 additions and 14 deletions

View File

@@ -710,7 +710,7 @@ QString Qt4Project::buildDirectory(const QString &buildConfiguration) const
ProjectExplorer::Environment Qt4Project::baseEnvironment(const QString &buildConfiguration) const ProjectExplorer::Environment Qt4Project::baseEnvironment(const QString &buildConfiguration) const
{ {
Environment env = useSystemEnvironment(buildConfiguration) ? Environment(QProcess::systemEnvironment()) : Environment(); Environment env = useSystemEnvironment(buildConfiguration) ? Environment::systemEnvironment() : Environment();
qtVersion(buildConfiguration)->addToEnvironment(env); qtVersion(buildConfiguration)->addToEnvironment(env);
return env; return env;
} }

View File

@@ -47,6 +47,8 @@
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QCheckBox> #include <QtGui/QCheckBox>
#include <QtGui/QToolButton> #include <QtGui/QToolButton>
#include <QtGui/QGroupBox>
#include <QtGui/QRadioButton>
using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager::Internal;
using namespace Qt4ProjectManager; using namespace Qt4ProjectManager;
@@ -62,7 +64,8 @@ Qt4RunConfiguration::Qt4RunConfiguration(Qt4Project *pro, const QString &proFile
m_configWidget(0), m_configWidget(0),
m_cachedTargetInformationValid(false), m_cachedTargetInformationValid(false),
m_isUsingDyldImageSuffix(false), m_isUsingDyldImageSuffix(false),
m_userSetWokingDirectory(false) m_userSetWokingDirectory(false),
m_baseEnvironmentBase(Qt4RunConfiguration::BuildEnvironmentBase)
{ {
if (!m_proFilePath.isEmpty()) if (!m_proFilePath.isEmpty())
setName(QFileInfo(m_proFilePath).completeBaseName()); setName(QFileInfo(m_proFilePath).completeBaseName());
@@ -142,14 +145,46 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
this, SLOT(usingDyldImageSuffixToggled(bool))); this, SLOT(usingDyldImageSuffixToggled(bool)));
#endif #endif
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->addLayout(toplayout);
QGroupBox *box = new QGroupBox(tr("Environment"),this);
QVBoxLayout *boxLayout = new QVBoxLayout();
box->setLayout(boxLayout);
box->setFlat(true);
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
boxLayout->addWidget(label);
m_cleanEnvironmentRadioButton = new QRadioButton("Clean Environment", box);
m_systemEnvironmentRadioButton = new QRadioButton("System Environment", box);
m_buildEnvironmentRadioButton = new QRadioButton("Build Environment", box);
boxLayout->addWidget(m_cleanEnvironmentRadioButton);
boxLayout->addWidget(m_systemEnvironmentRadioButton);
boxLayout->addWidget(m_buildEnvironmentRadioButton);
if (qt4RunConfiguration->baseEnvironmentBase() == Qt4RunConfiguration::CleanEnvironmentBase)
m_cleanEnvironmentRadioButton->setChecked(true);
else if (qt4RunConfiguration->baseEnvironmentBase() == Qt4RunConfiguration::SystemEnvironmentBase)
m_systemEnvironmentRadioButton->setChecked(true);
else if (qt4RunConfiguration->baseEnvironmentBase() == Qt4RunConfiguration::BuildEnvironmentBase)
m_buildEnvironmentRadioButton->setChecked(true);
connect(m_cleanEnvironmentRadioButton, SIGNAL(toggled(bool)),
this, SLOT(baseEnvironmentRadioButtonChanged()));
connect(m_systemEnvironmentRadioButton, SIGNAL(toggled(bool)),
this, SLOT(baseEnvironmentRadioButtonChanged()));
connect(m_buildEnvironmentRadioButton, SIGNAL(toggled(bool)),
this, SLOT(baseEnvironmentRadioButtonChanged()));
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this); m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this);
m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment()); m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment());
m_environmentWidget->setUserChanges(m_qt4RunConfiguration->userEnvironmentChanges()); m_environmentWidget->setUserChanges(m_qt4RunConfiguration->userEnvironmentChanges());
m_environmentWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_environmentWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
vbox->addWidget(m_environmentWidget); boxLayout->addWidget(m_environmentWidget);
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->addLayout(toplayout);
vbox->addWidget(box);
connect(m_workingDirectoryEdit, SIGNAL(changed()), connect(m_workingDirectoryEdit, SIGNAL(changed()),
this, SLOT(setWorkingDirectory())); this, SLOT(setWorkingDirectory()));
@@ -188,8 +223,32 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
this, SLOT(baseEnvironmentChanged())); this, SLOT(baseEnvironmentChanged()));
} }
void Qt4RunConfigurationWidget::baseEnvironmentRadioButtonChanged()
{
m_ignoreChange = true;
if (m_cleanEnvironmentRadioButton->isChecked())
m_qt4RunConfiguration->setBaseEnvironmentBase(Qt4RunConfiguration::CleanEnvironmentBase);
else if (m_systemEnvironmentRadioButton->isChecked())
m_qt4RunConfiguration->setBaseEnvironmentBase(Qt4RunConfiguration::SystemEnvironmentBase);
else if (m_buildEnvironmentRadioButton->isChecked())
m_qt4RunConfiguration->setBaseEnvironmentBase(Qt4RunConfiguration::BuildEnvironmentBase);
m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment());
m_ignoreChange = false;
}
void Qt4RunConfigurationWidget::baseEnvironmentChanged() void Qt4RunConfigurationWidget::baseEnvironmentChanged()
{ {
if (m_ignoreChange)
return;
if (m_qt4RunConfiguration->baseEnvironmentBase() == Qt4RunConfiguration::CleanEnvironmentBase)
m_cleanEnvironmentRadioButton->setChecked(true);
else if (m_qt4RunConfiguration->baseEnvironmentBase() == Qt4RunConfiguration::SystemEnvironmentBase)
m_systemEnvironmentRadioButton->setChecked(true);
else if (m_qt4RunConfiguration->baseEnvironmentBase() == Qt4RunConfiguration::BuildEnvironmentBase)
m_buildEnvironmentRadioButton->setChecked(true);
m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment()); m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment());
} }
@@ -320,6 +379,7 @@ void Qt4RunConfiguration::save(PersistentSettingsWriter &writer) const
writer.saveValue("UseTerminal", m_runMode == Console); writer.saveValue("UseTerminal", m_runMode == Console);
writer.saveValue("UseDyldImageSuffix", m_isUsingDyldImageSuffix); writer.saveValue("UseDyldImageSuffix", m_isUsingDyldImageSuffix);
writer.saveValue("UserEnvironmentChanges", ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges)); writer.saveValue("UserEnvironmentChanges", ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
writer.saveValue("BaseEnvironmentBase", m_baseEnvironmentBase);
ApplicationRunConfiguration::save(writer); ApplicationRunConfiguration::save(writer);
} }
@@ -338,6 +398,8 @@ void Qt4RunConfiguration::restore(const PersistentSettingsReader &reader)
setName(QFileInfo(m_proFilePath).completeBaseName()); setName(QFileInfo(m_proFilePath).completeBaseName());
} }
m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(reader.restoreValue("UserEnvironmentChanges").toStringList()); m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(reader.restoreValue("UserEnvironmentChanges").toStringList());
QVariant tmp = reader.restoreValue("BaseEnvironmentBase");
m_baseEnvironmentBase = tmp.isValid() ? BaseEnvironmentBase(tmp.toInt()) : Qt4RunConfiguration::BuildEnvironmentBase;
} }
QString Qt4RunConfiguration::executable() const QString Qt4RunConfiguration::executable() const
@@ -380,15 +442,15 @@ QStringList Qt4RunConfiguration::commandLineArguments() const
ProjectExplorer::Environment Qt4RunConfiguration::baseEnvironment() const ProjectExplorer::Environment Qt4RunConfiguration::baseEnvironment() const
{ {
// TODO use either System Environment ProjectExplorer::Environment env;
// build environment if (m_baseEnvironmentBase == Qt4RunConfiguration::CleanEnvironmentBase) {
// or empty // Nothing
//Environment env = Environment(QProcess::systemEnvironment()); } else if (m_baseEnvironmentBase == Qt4RunConfiguration::SystemEnvironmentBase) {
env = ProjectExplorer::Environment::systemEnvironment();
Qt4Project *pro = qobject_cast<Qt4Project *>(project()); } else if (m_baseEnvironmentBase == Qt4RunConfiguration::BuildEnvironmentBase) {
Q_ASSERT(pro); QString config = project()->activeBuildConfiguration();
QString config = pro->activeBuildConfiguration(); env = project()->environment(project()->activeBuildConfiguration());
ProjectExplorer::Environment env = pro->environment(pro->activeBuildConfiguration()); }
if (m_isUsingDyldImageSuffix) { if (m_isUsingDyldImageSuffix) {
env.set("DYLD_IMAGE_SUFFIX", "_debug"); env.set("DYLD_IMAGE_SUFFIX", "_debug");
} }
@@ -564,6 +626,18 @@ QString Qt4RunConfiguration::dumperLibrary() const
return version->debuggingHelperLibrary(); return version->debuggingHelperLibrary();
} }
void Qt4RunConfiguration::setBaseEnvironmentBase(BaseEnvironmentBase env)
{
if (m_baseEnvironmentBase == env)
return;
m_baseEnvironmentBase = env;
emit baseEnvironmentChanged();
}
Qt4RunConfiguration::BaseEnvironmentBase Qt4RunConfiguration::baseEnvironmentBase() const
{
return m_baseEnvironmentBase;
}
/// ///
/// Qt4RunConfigurationFactory /// Qt4RunConfigurationFactory

View File

@@ -42,6 +42,7 @@ class QWidget;
class QCheckBox; class QCheckBox;
class QLabel; class QLabel;
class QLineEdit; class QLineEdit;
class QRadioButton;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
@@ -106,6 +107,10 @@ private slots:
void setRunMode(RunMode runMode); void setRunMode(RunMode runMode);
private: private:
enum BaseEnvironmentBase { CleanEnvironmentBase, SystemEnvironmentBase, BuildEnvironmentBase };
void setBaseEnvironmentBase(BaseEnvironmentBase env);
BaseEnvironmentBase baseEnvironmentBase() const;
ProjectExplorer::Environment baseEnvironment() const; ProjectExplorer::Environment baseEnvironment() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff); void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const; QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
@@ -126,6 +131,7 @@ private:
bool m_userSetWokingDirectory; bool m_userSetWokingDirectory;
QString m_userWorkingDirectory; QString m_userWorkingDirectory;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges; QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
BaseEnvironmentBase m_baseEnvironmentBase;
}; };
class Qt4RunConfigurationWidget : public QWidget class Qt4RunConfigurationWidget : public QWidget
@@ -154,6 +160,7 @@ private slots:
void termToggled(bool); void termToggled(bool);
void usingDyldImageSuffixToggled(bool); void usingDyldImageSuffixToggled(bool);
void usingDyldImageSuffixChanged(bool); void usingDyldImageSuffixChanged(bool);
void baseEnvironmentRadioButtonChanged();
private: private:
Qt4RunConfiguration *m_qt4RunConfiguration; Qt4RunConfiguration *m_qt4RunConfiguration;
bool m_ignoreChange; bool m_ignoreChange;
@@ -163,6 +170,11 @@ private:
QLineEdit *m_argumentsLineEdit; QLineEdit *m_argumentsLineEdit;
QCheckBox *m_useTerminalCheck; QCheckBox *m_useTerminalCheck;
QCheckBox *m_usingDyldImageSuffix; QCheckBox *m_usingDyldImageSuffix;
QRadioButton *m_cleanEnvironmentRadioButton;
QRadioButton *m_systemEnvironmentRadioButton;
QRadioButton *m_buildEnvironmentRadioButton;
ProjectExplorer::EnvironmentWidget *m_environmentWidget; ProjectExplorer::EnvironmentWidget *m_environmentWidget;
bool m_isShown; bool m_isShown;
}; };