Commit dcd1876d authored by Kai Koehne's avatar Kai Koehne

QmlProject: Restrict UI to using the System Environment

There are probably very little use cases where you want to start
from a clean environment, and there is no such thing as a Build
Environment (although we magically add some toolchain settings to
the environment).
parent e398225c
......@@ -40,7 +40,6 @@ const char * const QML_VIEWER_TARGET_ID = "QmlProjectManager.QmlTarget";
const char * const QML_VIEWER_TARGET_DISPLAY_NAME = "QML Viewer";
const char * const QML_MAINSCRIPT_KEY = "QmlProjectManager.QmlRunConfiguration.MainScript";
const char * const USER_ENVIRONMENT_CHANGES_KEY("QmlProjectManager.QmlRunConfiguration.UserEnvironmentChanges");
const char * const BASE_ENVIRONMENT_BASE_KEY("QmlProjectManager.QmlRunConfiguration.BaseEnvironmentBase");
} // namespace Constants
......
......@@ -57,8 +57,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(QmlProjectTarget *parent)
m_qtVersionId(-1),
m_projectTarget(parent),
m_usingCurrentFile(true),
m_isEnabled(false),
m_baseEnvironmentBase(BuildEnvironmentBase)
m_isEnabled(false)
{
ctor();
updateQtVersions();
......@@ -70,8 +69,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(QmlProjectTarget *parent,
m_qtVersionId(source->m_qtVersionId),
m_qmlViewerArgs(source->m_qmlViewerArgs),
m_projectTarget(parent),
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
m_baseEnvironmentBase(source->m_baseEnvironmentBase)
m_userEnvironmentChanges(source->m_userEnvironmentChanges)
{
ctor();
setMainScript(source->m_scriptFile);
......@@ -234,8 +232,6 @@ QVariantMap QmlProjectRunConfiguration::toMap() const
map.insert(QLatin1String(Constants::QML_MAINSCRIPT_KEY), m_scriptFile);
map.insert(QLatin1String(Constants::USER_ENVIRONMENT_CHANGES_KEY),
Utils::EnvironmentItem::toStringList(m_userEnvironmentChanges));
map.insert(QLatin1String(Constants::BASE_ENVIRONMENT_BASE_KEY),
static_cast<int>(m_baseEnvironmentBase));
return map;
}
......@@ -246,11 +242,6 @@ bool QmlProjectRunConfiguration::fromMap(const QVariantMap &map)
m_scriptFile = map.value(QLatin1String(Constants::QML_MAINSCRIPT_KEY), M_CURRENT_FILE).toString();
m_userEnvironmentChanges = Utils::EnvironmentItem::fromStringList(
map.value(QLatin1String(Constants::USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
m_baseEnvironmentBase
= static_cast<BaseEnvironmentBase>(
map.value(QLatin1String(Constants::BASE_ENVIRONMENT_BASE_KEY),
static_cast<int>(BuildEnvironmentBase)).toInt());
updateQtVersions();
......@@ -342,32 +333,10 @@ bool QmlProjectRunConfiguration::isValidVersion(Qt4ProjectManager::QtVersion *ve
Utils::Environment QmlProjectRunConfiguration::baseEnvironment() const
{
Utils::Environment env;
if (m_baseEnvironmentBase == QmlProjectRunConfiguration::CleanEnvironmentBase) {
// Nothing
} else if (m_baseEnvironmentBase == QmlProjectRunConfiguration::SystemEnvironmentBase) {
env = Utils::Environment::systemEnvironment();
} else if (m_baseEnvironmentBase == QmlProjectRunConfiguration::BuildEnvironmentBase) {
env = qtVersion()->qmlToolsEnvironment();
}
env = qtVersion()->qmlToolsEnvironment();
return env;
}
void QmlProjectRunConfiguration::setBaseEnvironmentBase(BaseEnvironmentBase env)
{
if (m_baseEnvironmentBase == env)
return;
m_baseEnvironmentBase = env;
if (m_configurationWidget)
m_configurationWidget.data()->baseEnvironmentChanged();
}
QmlProjectRunConfiguration::BaseEnvironmentBase
QmlProjectRunConfiguration::baseEnvironmentBase() const
{
return m_baseEnvironmentBase;
}
void QmlProjectRunConfiguration::setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff)
{
if (m_userEnvironmentChanges != diff) {
......
......@@ -111,12 +111,6 @@ private:
void setQtVersionId(int id);
Utils::Environment baseEnvironment() const;
enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
SystemEnvironmentBase = 1,
BuildEnvironmentBase = 2};
void setBaseEnvironmentBase(BaseEnvironmentBase env);
BaseEnvironmentBase baseEnvironmentBase() const;
void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
......@@ -136,7 +130,6 @@ private:
bool m_isEnabled;
QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
BaseEnvironmentBase m_baseEnvironmentBase;
};
} // namespace QmlProjectManager
......
......@@ -153,22 +153,9 @@ QmlProjectRunConfigurationWidget::QmlProjectRunConfigurationWidget(QmlProjectRun
QWidget *baseEnvironmentWidget = new QWidget;
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
baseEnvironmentLayout->setMargin(0);
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
baseEnvironmentLayout->addWidget(label);
m_baseEnvironmentComboBox = new QComboBox(this);
m_baseEnvironmentComboBox->addItems(QStringList()
<< tr("Clean Environment")
<< tr("System Environment")
<< tr("Build Environment"));
m_baseEnvironmentComboBox->setCurrentIndex(rc->baseEnvironmentBase());
connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(baseEnvironmentSelected(int)));
baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
baseEnvironmentLayout->addStretch(10);
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(rc->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(baseEnvironmentText());
m_environmentWidget->setBaseEnvironmentText(tr("System Environment"));
m_environmentWidget->setUserChanges(rc->userEnvironmentChanges());
connect(m_environmentWidget, SIGNAL(userChangesChanged()),
......@@ -282,46 +269,11 @@ void QmlProjectRunConfigurationWidget::userChangesChanged()
m_runConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
}
void QmlProjectRunConfigurationWidget::baseEnvironmentChanged()
{
// if (m_ignoreChange)
// return;
int index = QmlProjectRunConfiguration::BaseEnvironmentBase(
m_runConfiguration->baseEnvironmentBase());
m_baseEnvironmentComboBox->setCurrentIndex(index);
m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(baseEnvironmentText());
}
void QmlProjectRunConfigurationWidget::userEnvironmentChangesChanged()
{
m_environmentWidget->setUserChanges(m_runConfiguration->userEnvironmentChanges());
}
void QmlProjectRunConfigurationWidget::baseEnvironmentSelected(int index)
{
// m_ignoreChange = true;
m_runConfiguration->setBaseEnvironmentBase(
QmlProjectRunConfiguration::BaseEnvironmentBase(index));
m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(baseEnvironmentText());
// m_ignoreChange = false;
}
QString QmlProjectRunConfigurationWidget::baseEnvironmentText() const
{
if (m_runConfiguration->m_baseEnvironmentBase
== QmlProjectRunConfiguration::CleanEnvironmentBase) {
return tr("Clean Environment");
} else if (m_runConfiguration->m_baseEnvironmentBase
== QmlProjectRunConfiguration::SystemEnvironmentBase) {
return tr("System Environment");
} else {
return tr("Build Environment");
}
}
} // namespace Internal
} // namespace QmlProjectManager
......@@ -57,7 +57,6 @@ public:
public slots:
void updateQtVersionComboBox();
void baseEnvironmentChanged();
void userEnvironmentChangesChanged();
private slots:
......@@ -71,14 +70,10 @@ private slots:
void qmlDebugServerPortChanged(uint port);
void userChangesChanged();
void baseEnvironmentSelected(int index);
void manageQtVersions();
private:
QString baseEnvironmentText() const;
QmlProjectRunConfiguration *m_runConfiguration;
QComboBox *m_qtVersionComboBox;
......@@ -86,7 +81,6 @@ private:
QStringListModel *m_fileListModel;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
QComboBox *m_baseEnvironmentComboBox;
};
} // 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