Commit 6d18c530 authored by dt's avatar dt
Browse files

Add options also to CMake and CustomExecutable RunConfiguration

Well this enough environment settings for 1.2.
parent 48167ee5
......@@ -37,6 +37,9 @@
#include <utils/qtcassert.h>
#include <QtGui/QFormLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QGroupBox>
#include <QtGui/QLabel>
#include <QtGui/QRadioButton>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
......@@ -47,6 +50,7 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &t
, m_target(target)
, m_workingDirectory(workingDirectory)
, m_title(title)
, m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase)
{
setName(title);
......@@ -110,6 +114,7 @@ void CMakeRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writ
writer.saveValue("CMakeRunConfiguation.Title", m_title);
writer.saveValue("CMakeRunConfiguration.Arguments", m_arguments);
writer.saveValue("CMakeRunConfiguration.UserEnvironmentChanges", ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
writer.saveValue("BaseEnvironmentBase", m_baseEnvironmentBase);
}
void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader)
......@@ -121,6 +126,8 @@ void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsRea
m_title = reader.restoreValue("CMakeRunConfiguation.Title").toString();
m_arguments = reader.restoreValue("CMakeRunConfiguration.Arguments").toString();
m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(reader.restoreValue("CMakeRunConfiguration.UserEnvironmentChanges").toStringList());
QVariant tmp = reader.restoreValue("BaseEnvironmentBase");
m_baseEnvironmentBase = tmp.isValid() ? BaseEnvironmentBase(tmp.toInt()) : CMakeRunConfiguration::BuildEnvironmentBase;
}
QWidget *CMakeRunConfiguration::configurationWidget()
......@@ -142,16 +149,31 @@ QString CMakeRunConfiguration::dumperLibrary() const
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());
ProjectExplorer::Environment env;
if (m_baseEnvironmentBase == CMakeRunConfiguration::CleanEnvironmentBase) {
// Nothing
} else if (m_baseEnvironmentBase == CMakeRunConfiguration::SystemEnvironmentBase) {
env = ProjectExplorer::Environment::systemEnvironment();
} else if (m_baseEnvironmentBase == CMakeRunConfiguration::BuildEnvironmentBase) {
QString config = project()->activeBuildConfiguration();
env = project()->environment(project()->activeBuildConfiguration());
}
return env;
}
void CMakeRunConfiguration::setBaseEnvironmentBase(BaseEnvironmentBase env)
{
if (m_baseEnvironmentBase == env)
return;
m_baseEnvironmentBase = env;
emit baseEnvironmentChanged();
}
CMakeRunConfiguration::BaseEnvironmentBase CMakeRunConfiguration::baseEnvironmentBase() const
{
return m_baseEnvironmentBase;
}
ProjectExplorer::Environment CMakeRunConfiguration::environment() const
{
ProjectExplorer::Environment env = baseEnvironment();
......@@ -176,7 +198,7 @@ void CMakeRunConfiguration::setUserEnvironmentChanges(const QList<ProjectExplore
CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent)
: QWidget(parent), m_cmakeRunConfiguration(cmakeRunConfiguration)
: QWidget(parent), m_ignoreChange(false), m_cmakeRunConfiguration(cmakeRunConfiguration)
{
QFormLayout *fl = new QFormLayout();
......@@ -186,13 +208,45 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
this, SLOT(setArguments(QString)));
fl->addRow(tr("Arguments:"), argumentsLineEdit);
QVBoxLayout *vbx = new QVBoxLayout(this);
vbx->addLayout(fl);
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 (cmakeRunConfiguration->baseEnvironmentBase() == CMakeRunConfiguration::CleanEnvironmentBase)
m_cleanEnvironmentRadioButton->setChecked(true);
else if (cmakeRunConfiguration->baseEnvironmentBase() == CMakeRunConfiguration::SystemEnvironmentBase)
m_systemEnvironmentRadioButton->setChecked(true);
else if (cmakeRunConfiguration->baseEnvironmentBase() == CMakeRunConfiguration::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);
vbx->addWidget(m_environmentWidget);
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
boxLayout->addWidget(m_environmentWidget);
QVBoxLayout *vbx = new QVBoxLayout(this);
vbx->addLayout(fl);
vbx->addWidget(box);
connect(m_environmentWidget, SIGNAL(userChangesUpdated()),
this, SLOT(userChangesUpdated()));
......@@ -207,8 +261,32 @@ void CMakeRunConfigurationWidget::userChangesUpdated()
m_cmakeRunConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
}
void CMakeRunConfigurationWidget::baseEnvironmentRadioButtonChanged()
{
m_ignoreChange = true;
if (m_cleanEnvironmentRadioButton->isChecked())
m_cmakeRunConfiguration->setBaseEnvironmentBase(CMakeRunConfiguration::CleanEnvironmentBase);
else if (m_systemEnvironmentRadioButton->isChecked())
m_cmakeRunConfiguration->setBaseEnvironmentBase(CMakeRunConfiguration::SystemEnvironmentBase);
else if (m_buildEnvironmentRadioButton->isChecked())
m_cmakeRunConfiguration->setBaseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase);
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
m_ignoreChange = false;
}
void CMakeRunConfigurationWidget::baseEnvironmentChanged()
{
if (m_ignoreChange)
return;
if (m_cmakeRunConfiguration->baseEnvironmentBase() == CMakeRunConfiguration::CleanEnvironmentBase)
m_cleanEnvironmentRadioButton->setChecked(true);
else if (m_cmakeRunConfiguration->baseEnvironmentBase() == CMakeRunConfiguration::SystemEnvironmentBase)
m_systemEnvironmentRadioButton->setChecked(true);
else if (m_cmakeRunConfiguration->baseEnvironmentBase() == CMakeRunConfiguration::BuildEnvironmentBase)
m_buildEnvironmentRadioButton->setChecked(true);
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
}
......
......@@ -35,6 +35,10 @@
#include <projectexplorer/persistentsettings.h>
#include <projectexplorer/environmenteditmodel.h>
QT_BEGIN_NAMESPACE
class QRadioButton;
QT_END_INCLUDE_NAMESPACE
namespace CMakeProjectManager {
namespace Internal {
......@@ -71,6 +75,9 @@ signals:
private slots:
void setArguments(const QString &newText);
private:
enum BaseEnvironmentBase { CleanEnvironmentBase, SystemEnvironmentBase, BuildEnvironmentBase };
void setBaseEnvironmentBase(BaseEnvironmentBase env);
BaseEnvironmentBase baseEnvironmentBase() const;
ProjectExplorer::Environment baseEnvironment() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
......@@ -81,6 +88,7 @@ private:
QString m_title;
QString m_arguments;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
BaseEnvironmentBase m_baseEnvironmentBase;
};
class CMakeRunConfigurationWidget : public QWidget
......@@ -93,9 +101,15 @@ private slots:
void baseEnvironmentChanged();
void userEnvironmentChangesChanged();
void userChangesUpdated();
private slots:
void baseEnvironmentRadioButtonChanged();
private:
bool m_ignoreChange;
CMakeRunConfiguration *m_cmakeRunConfiguration;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
QRadioButton *m_cleanEnvironmentRadioButton;
QRadioButton *m_systemEnvironmentRadioButton;
QRadioButton *m_buildEnvironmentRadioButton;
};
class CMakeRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
......
......@@ -42,6 +42,8 @@
#include <QtGui/QHBoxLayout>
#include <QtGui/QToolButton>
#include <QtGui/QFileDialog>
#include <QtGui/QGroupBox>
#include <QtGui/QRadioButton>
#include <QDialogButtonBox>
using namespace ProjectExplorer;
......@@ -86,13 +88,43 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
m_useTerminalCheck = new QCheckBox(tr("Run in &Terminal"), this);
layout->addRow(QString(), m_useTerminalCheck);
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 (rc->baseEnvironmentBase() == CustomExecutableRunConfiguration::CleanEnvironmentBase)
m_cleanEnvironmentRadioButton->setChecked(true);
else if (rc->baseEnvironmentBase() == CustomExecutableRunConfiguration::SystemEnvironmentBase)
m_systemEnvironmentRadioButton->setChecked(true);
else if (rc->baseEnvironmentBase() == CustomExecutableRunConfiguration::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 EnvironmentWidget(this);
m_environmentWidget->setBaseEnvironment(rc->baseEnvironment());
m_environmentWidget->setUserChanges(rc->userEnvironmentChanges());
boxLayout->addWidget(m_environmentWidget);
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->addLayout(layout);
vbox->addWidget(m_environmentWidget);
vbox->addWidget(box);
changed();
......@@ -123,8 +155,32 @@ void CustomExecutableConfigurationWidget::userChangesUpdated()
m_runConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
}
void CustomExecutableConfigurationWidget::baseEnvironmentRadioButtonChanged()
{
m_ignoreChange = true;
if (m_cleanEnvironmentRadioButton->isChecked())
m_runConfiguration->setBaseEnvironmentBase(CustomExecutableRunConfiguration::CleanEnvironmentBase);
else if (m_systemEnvironmentRadioButton->isChecked())
m_runConfiguration->setBaseEnvironmentBase(CustomExecutableRunConfiguration::SystemEnvironmentBase);
else if (m_buildEnvironmentRadioButton->isChecked())
m_runConfiguration->setBaseEnvironmentBase(CustomExecutableRunConfiguration::BuildEnvironmentBase);
m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
m_ignoreChange = false;
}
void CustomExecutableConfigurationWidget::baseEnvironmentChanged()
{
if (m_ignoreChange)
return;
if (m_runConfiguration->baseEnvironmentBase() == CustomExecutableRunConfiguration::CleanEnvironmentBase)
m_cleanEnvironmentRadioButton->setChecked(true);
else if (m_runConfiguration->baseEnvironmentBase() == CustomExecutableRunConfiguration::SystemEnvironmentBase)
m_systemEnvironmentRadioButton->setChecked(true);
else if (m_runConfiguration->baseEnvironmentBase() == CustomExecutableRunConfiguration::BuildEnvironmentBase)
m_buildEnvironmentRadioButton->setChecked(true);
m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
}
......@@ -183,7 +239,8 @@ void CustomExecutableConfigurationWidget::changed()
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro)
: ApplicationRunConfiguration(pro),
m_runMode(Gui),
m_userSetName(false)
m_userSetName(false),
m_baseEnvironmentBase(CustomExecutableRunConfiguration::BuildEnvironmentBase)
{
m_workingDirectory = "$BUILDDIR";
setName(tr("Custom Executable"));
......@@ -279,16 +336,31 @@ QStringList CustomExecutableRunConfiguration::commandLineArguments() 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());
ProjectExplorer::Environment env;
if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::CleanEnvironmentBase) {
// Nothing
} else if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::SystemEnvironmentBase) {
env = ProjectExplorer::Environment::systemEnvironment();
} else if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::BuildEnvironmentBase) {
QString config = project()->activeBuildConfiguration();
env = project()->environment(project()->activeBuildConfiguration());
}
return env;
}
void CustomExecutableRunConfiguration::setBaseEnvironmentBase(BaseEnvironmentBase env)
{
if (m_baseEnvironmentBase == env)
return;
m_baseEnvironmentBase = env;
emit baseEnvironmentChanged();
}
CustomExecutableRunConfiguration::BaseEnvironmentBase CustomExecutableRunConfiguration::baseEnvironmentBase() const
{
return m_baseEnvironmentBase;
}
ProjectExplorer::Environment CustomExecutableRunConfiguration::environment() const
{
ProjectExplorer::Environment env = baseEnvironment();
......@@ -318,6 +390,7 @@ void CustomExecutableRunConfiguration::save(PersistentSettingsWriter &writer) co
writer.saveValue("UserSetName", m_userSetName);
writer.saveValue("UserName", m_userName);
writer.saveValue("UserEnvironmentChanges", ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
writer.saveValue("BaseEnvironmentBase", m_baseEnvironmentBase);
ApplicationRunConfiguration::save(writer);
}
......@@ -331,6 +404,8 @@ void CustomExecutableRunConfiguration::restore(const PersistentSettingsReader &r
m_userName = reader.restoreValue("UserName").toString();
m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(reader.restoreValue("UserEnvironmentChanges").toStringList());
ApplicationRunConfiguration::restore(reader);
QVariant tmp = reader.restoreValue("BaseEnvironmentBase");
m_baseEnvironmentBase = tmp.isValid() ? BaseEnvironmentBase(tmp.toInt()) : CustomExecutableRunConfiguration::BuildEnvironmentBase;
}
void CustomExecutableRunConfiguration::setExecutable(const QString &executable)
......
......@@ -40,6 +40,7 @@
QT_BEGIN_NAMESPACE
class QCheckBox;
class QLineEdit;
class QRadioButton;
QT_END_NAMESPACE
namespace ProjectExplorer {
......@@ -97,6 +98,9 @@ signals:
private:
enum BaseEnvironmentBase { CleanEnvironmentBase, SystemEnvironmentBase, BuildEnvironmentBase };
void setBaseEnvironmentBase(BaseEnvironmentBase env);
BaseEnvironmentBase baseEnvironmentBase() const;
ProjectExplorer::Environment baseEnvironment() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
......@@ -113,6 +117,7 @@ private:
bool m_userSetName;
QString m_userName;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
BaseEnvironmentBase m_baseEnvironmentBase;
};
class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory
......@@ -150,7 +155,7 @@ private slots:
void userChangesUpdated();
void baseEnvironmentChanged();
void userEnvironmentChangesChanged();
void baseEnvironmentRadioButtonChanged();
private:
bool m_ignoreChange;
CustomExecutableRunConfiguration *m_runConfiguration;
......@@ -160,6 +165,9 @@ private:
Core::Utils::PathChooser *m_workingDirectory;
QCheckBox *m_useTerminalCheck;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
QRadioButton *m_cleanEnvironmentRadioButton;
QRadioButton *m_systemEnvironmentRadioButton;
QRadioButton *m_buildEnvironmentRadioButton;
};
} // namespace Internal
......
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