2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-06-17 00:01:27 +10:00
|
|
|
** contact the sales department at http://www.qtsoftware.com/contact.
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-09 14:53:06 +01:00
|
|
|
|
|
|
|
|
#include "cmakerunconfiguration.h"
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
#include "cmakeproject.h"
|
2008-12-09 15:25:01 +01:00
|
|
|
#include "cmakeprojectconstants.h"
|
2008-12-09 14:53:06 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/environment.h>
|
2009-04-28 12:43:04 +02:00
|
|
|
#include <projectexplorer/debugginghelper.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2009-03-25 18:29:42 +01:00
|
|
|
#include <QtGui/QFormLayout>
|
|
|
|
|
#include <QtGui/QLineEdit>
|
2009-05-28 18:52:06 +02:00
|
|
|
#include <QtGui/QGroupBox>
|
|
|
|
|
#include <QtGui/QLabel>
|
|
|
|
|
#include <QtGui/QRadioButton>
|
2009-06-16 18:37:16 +02:00
|
|
|
#include <QtGui/QToolButton>
|
2008-12-09 14:53:06 +01:00
|
|
|
|
|
|
|
|
using namespace CMakeProjectManager;
|
|
|
|
|
using namespace CMakeProjectManager::Internal;
|
|
|
|
|
|
2009-03-16 17:33:05 +01:00
|
|
|
CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory, const QString &title)
|
2009-03-18 17:43:55 +01:00
|
|
|
: ProjectExplorer::ApplicationRunConfiguration(pro)
|
|
|
|
|
, m_runMode(Gui)
|
|
|
|
|
, m_target(target)
|
|
|
|
|
, m_workingDirectory(workingDirectory)
|
|
|
|
|
, m_title(title)
|
2009-05-28 18:52:06 +02:00
|
|
|
, m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase)
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2009-03-16 17:33:05 +01:00
|
|
|
setName(title);
|
2009-05-27 17:28:50 +02:00
|
|
|
|
|
|
|
|
connect(pro, SIGNAL(activeBuildConfigurationChanged()),
|
|
|
|
|
this, SIGNAL(baseEnvironmentChanged()));
|
|
|
|
|
|
|
|
|
|
connect(pro, SIGNAL(environmentChanged(QString)),
|
|
|
|
|
this, SIGNAL(baseEnvironmentChanged()));
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
CMakeRunConfiguration::~CMakeRunConfiguration()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CMakeRunConfiguration::type() const
|
|
|
|
|
{
|
|
|
|
|
return Constants::CMAKERUNCONFIGURATION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CMakeRunConfiguration::executable() const
|
|
|
|
|
{
|
|
|
|
|
return m_target;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::ApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const
|
|
|
|
|
{
|
2009-02-18 17:04:04 +01:00
|
|
|
return m_runMode;
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CMakeRunConfiguration::workingDirectory() const
|
|
|
|
|
{
|
2009-06-16 18:37:16 +02:00
|
|
|
if (!m_userWorkingDirectory.isEmpty())
|
|
|
|
|
return m_userWorkingDirectory;
|
2008-12-09 14:53:06 +01:00
|
|
|
return m_workingDirectory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList CMakeRunConfiguration::commandLineArguments() const
|
|
|
|
|
{
|
2009-03-25 18:29:42 +01:00
|
|
|
return ProjectExplorer::Environment::parseCombinedArgString(m_arguments);
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-16 17:33:05 +01:00
|
|
|
QString CMakeRunConfiguration::title() const
|
|
|
|
|
{
|
|
|
|
|
return m_title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfiguration::setExecutable(const QString &executable)
|
|
|
|
|
{
|
|
|
|
|
m_target = executable;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-16 18:37:16 +02:00
|
|
|
void CMakeRunConfiguration::setWorkingDirectory(const QString &wd)
|
2009-03-16 17:33:05 +01:00
|
|
|
{
|
2009-06-16 18:37:16 +02:00
|
|
|
const QString & oldWorkingDirectory = workingDirectory();
|
|
|
|
|
|
|
|
|
|
m_workingDirectory = wd;
|
|
|
|
|
|
|
|
|
|
const QString &newWorkingDirectory = workingDirectory();
|
|
|
|
|
if (oldWorkingDirectory != newWorkingDirectory)
|
|
|
|
|
emit workingDirectoryChanged(newWorkingDirectory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfiguration::setUserWorkingDirectory(const QString &wd)
|
|
|
|
|
{
|
|
|
|
|
const QString & oldWorkingDirectory = workingDirectory();
|
|
|
|
|
|
|
|
|
|
m_userWorkingDirectory = wd;
|
|
|
|
|
|
|
|
|
|
const QString &newWorkingDirectory = workingDirectory();
|
|
|
|
|
if (oldWorkingDirectory != newWorkingDirectory)
|
|
|
|
|
emit workingDirectoryChanged(newWorkingDirectory);
|
2009-03-16 17:33:05 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
void CMakeRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writer) const
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::ApplicationRunConfiguration::save(writer);
|
2008-12-17 13:56:44 +01:00
|
|
|
writer.saveValue("CMakeRunConfiguration.Target", m_target);
|
|
|
|
|
writer.saveValue("CMakeRunConfiguration.WorkingDirectory", m_workingDirectory);
|
2009-06-16 18:37:16 +02:00
|
|
|
writer.saveValue("CMakeRunConfiguration.UserWorkingDirectory", m_userWorkingDirectory);
|
2009-02-18 17:04:04 +01:00
|
|
|
writer.saveValue("CMakeRunConfiguration.UseTerminal", m_runMode == Console);
|
2009-03-16 17:33:05 +01:00
|
|
|
writer.saveValue("CMakeRunConfiguation.Title", m_title);
|
2009-03-25 18:29:42 +01:00
|
|
|
writer.saveValue("CMakeRunConfiguration.Arguments", m_arguments);
|
2009-05-27 17:28:50 +02:00
|
|
|
writer.saveValue("CMakeRunConfiguration.UserEnvironmentChanges", ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
|
2009-05-28 18:52:06 +02:00
|
|
|
writer.saveValue("BaseEnvironmentBase", m_baseEnvironmentBase);
|
2009-06-16 18:37:16 +02:00
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader)
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::ApplicationRunConfiguration::restore(reader);
|
2008-12-17 13:56:44 +01:00
|
|
|
m_target = reader.restoreValue("CMakeRunConfiguration.Target").toString();
|
|
|
|
|
m_workingDirectory = reader.restoreValue("CMakeRunConfiguration.WorkingDirectory").toString();
|
2009-06-16 18:37:16 +02:00
|
|
|
m_userWorkingDirectory = reader.restoreValue("CMakeRunConfiguration.UserWorkingDirectory").toString();
|
2009-02-18 17:04:04 +01:00
|
|
|
m_runMode = reader.restoreValue("CMakeRunConfiguration.UseTerminal").toBool() ? Console : Gui;
|
2009-03-16 17:33:05 +01:00
|
|
|
m_title = reader.restoreValue("CMakeRunConfiguation.Title").toString();
|
2009-03-25 18:29:42 +01:00
|
|
|
m_arguments = reader.restoreValue("CMakeRunConfiguration.Arguments").toString();
|
2009-05-27 17:28:50 +02:00
|
|
|
m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(reader.restoreValue("CMakeRunConfiguration.UserEnvironmentChanges").toStringList());
|
2009-05-28 18:52:06 +02:00
|
|
|
QVariant tmp = reader.restoreValue("BaseEnvironmentBase");
|
|
|
|
|
m_baseEnvironmentBase = tmp.isValid() ? BaseEnvironmentBase(tmp.toInt()) : CMakeRunConfiguration::BuildEnvironmentBase;
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *CMakeRunConfiguration::configurationWidget()
|
|
|
|
|
{
|
2009-05-27 17:28:50 +02:00
|
|
|
return new CMakeRunConfigurationWidget(this);
|
2009-03-25 18:29:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfiguration::setArguments(const QString &newText)
|
|
|
|
|
{
|
|
|
|
|
m_arguments = newText;
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-25 15:18:37 +01:00
|
|
|
QString CMakeRunConfiguration::dumperLibrary() const
|
|
|
|
|
{
|
2009-04-24 16:21:51 +02:00
|
|
|
QString qmakePath = ProjectExplorer::DebuggingHelperLibrary::findSystemQt(environment());
|
|
|
|
|
QString dhl = ProjectExplorer::DebuggingHelperLibrary::debuggingHelperLibrary(qmakePath);
|
2009-04-24 14:59:47 +02:00
|
|
|
return dhl;
|
2009-03-25 15:18:37 +01:00
|
|
|
}
|
|
|
|
|
|
2009-05-27 17:28:50 +02:00
|
|
|
ProjectExplorer::Environment CMakeRunConfiguration::baseEnvironment() const
|
|
|
|
|
{
|
2009-05-28 18:52:06 +02:00
|
|
|
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());
|
|
|
|
|
}
|
2009-05-27 17:28:50 +02:00
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 18:52:06 +02:00
|
|
|
void CMakeRunConfiguration::setBaseEnvironmentBase(BaseEnvironmentBase env)
|
|
|
|
|
{
|
|
|
|
|
if (m_baseEnvironmentBase == env)
|
|
|
|
|
return;
|
|
|
|
|
m_baseEnvironmentBase = env;
|
|
|
|
|
emit baseEnvironmentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeRunConfiguration::BaseEnvironmentBase CMakeRunConfiguration::baseEnvironmentBase() const
|
|
|
|
|
{
|
|
|
|
|
return m_baseEnvironmentBase;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-27 17:28:50 +02:00
|
|
|
ProjectExplorer::Environment CMakeRunConfiguration::environment() const
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::Environment env = baseEnvironment();
|
|
|
|
|
env.modify(userEnvironmentChanges());
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<ProjectExplorer::EnvironmentItem> CMakeRunConfiguration::userEnvironmentChanges() const
|
|
|
|
|
{
|
|
|
|
|
return m_userEnvironmentChanges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff)
|
|
|
|
|
{
|
|
|
|
|
if (m_userEnvironmentChanges != diff) {
|
|
|
|
|
m_userEnvironmentChanges = diff;
|
|
|
|
|
emit userEnvironmentChangesChanged(diff);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Configuration widget
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent)
|
2009-05-28 18:52:06 +02:00
|
|
|
: QWidget(parent), m_ignoreChange(false), m_cmakeRunConfiguration(cmakeRunConfiguration)
|
2009-05-27 17:28:50 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
QFormLayout *fl = new QFormLayout();
|
|
|
|
|
QLineEdit *argumentsLineEdit = new QLineEdit();
|
|
|
|
|
argumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(cmakeRunConfiguration->commandLineArguments()));
|
|
|
|
|
connect(argumentsLineEdit, SIGNAL(textChanged(QString)),
|
|
|
|
|
this, SLOT(setArguments(QString)));
|
|
|
|
|
fl->addRow(tr("Arguments:"), argumentsLineEdit);
|
|
|
|
|
|
2009-06-16 18:37:16 +02:00
|
|
|
m_workingDirectoryEdit = new Core::Utils::PathChooser();
|
|
|
|
|
m_workingDirectoryEdit->setPath(m_cmakeRunConfiguration->workingDirectory());
|
|
|
|
|
m_workingDirectoryEdit->setExpectedKind(Core::Utils::PathChooser::Directory);
|
|
|
|
|
m_workingDirectoryEdit->setPromptDialogTitle(tr("Select the working directory"));
|
|
|
|
|
|
|
|
|
|
QToolButton *resetButton = new QToolButton();
|
|
|
|
|
resetButton->setToolTip(tr("Reset to default"));
|
|
|
|
|
resetButton->setIcon(QIcon(":/core/images/reset.png"));
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *boxlayout = new QHBoxLayout();
|
|
|
|
|
boxlayout->addWidget(m_workingDirectoryEdit);
|
|
|
|
|
boxlayout->addWidget(resetButton);
|
|
|
|
|
|
|
|
|
|
fl->addRow(tr("Working Directory:"), boxlayout);
|
|
|
|
|
|
2009-05-28 18:52:06 +02:00
|
|
|
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);
|
|
|
|
|
|
2009-06-16 18:37:16 +02:00
|
|
|
connect(m_workingDirectoryEdit, SIGNAL(changed()),
|
|
|
|
|
this, SLOT(setWorkingDirectory()));
|
|
|
|
|
|
|
|
|
|
connect(resetButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(resetWorkingDirectory()));
|
|
|
|
|
|
|
|
|
|
|
2009-05-28 18:52:06 +02:00
|
|
|
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()));
|
|
|
|
|
|
2009-05-27 17:28:50 +02:00
|
|
|
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this);
|
|
|
|
|
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
|
|
|
|
|
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
|
|
|
|
|
|
2009-05-28 18:52:06 +02:00
|
|
|
boxLayout->addWidget(m_environmentWidget);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *vbx = new QVBoxLayout(this);
|
|
|
|
|
vbx->addLayout(fl);
|
|
|
|
|
vbx->addWidget(box);
|
|
|
|
|
|
2009-05-27 17:28:50 +02:00
|
|
|
connect(m_environmentWidget, SIGNAL(userChangesUpdated()),
|
|
|
|
|
this, SLOT(userChangesUpdated()));
|
|
|
|
|
|
2009-06-16 18:37:16 +02:00
|
|
|
connect(m_cmakeRunConfiguration, SIGNAL(workingDirectoryChanged(QString)),
|
|
|
|
|
this, SLOT(workingDirectoryChanged(QString)));
|
2009-05-27 17:28:50 +02:00
|
|
|
connect(m_cmakeRunConfiguration, SIGNAL(baseEnvironmentChanged()),
|
|
|
|
|
this, SLOT(baseEnvironmentChanged()));
|
|
|
|
|
connect(m_cmakeRunConfiguration, SIGNAL(userEnvironmentChangesChanged(QList<ProjectExplorer::EnvironmentItem>)),
|
|
|
|
|
this, SLOT(userEnvironmentChangesChanged()));
|
2009-06-16 18:37:16 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::setWorkingDirectory()
|
|
|
|
|
{
|
|
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
m_ignoreChange = true;
|
|
|
|
|
m_cmakeRunConfiguration->setUserWorkingDirectory(m_workingDirectoryEdit->path());
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::workingDirectoryChanged(const QString &workingDirectory)
|
|
|
|
|
{
|
|
|
|
|
if (!m_ignoreChange)
|
|
|
|
|
m_workingDirectoryEdit->setPath(workingDirectory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::resetWorkingDirectory()
|
|
|
|
|
{
|
|
|
|
|
// This emits a signal connected to workingDirectoryChanged()
|
|
|
|
|
// that sets the m_workingDirectoryEdit
|
|
|
|
|
m_cmakeRunConfiguration->setUserWorkingDirectory("");
|
2009-05-27 17:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::userChangesUpdated()
|
|
|
|
|
{
|
|
|
|
|
m_cmakeRunConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 18:52:06 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-27 17:28:50 +02:00
|
|
|
void CMakeRunConfigurationWidget::baseEnvironmentChanged()
|
|
|
|
|
{
|
2009-05-28 18:52:06 +02:00
|
|
|
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);
|
|
|
|
|
|
2009-05-27 17:28:50 +02:00
|
|
|
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::userEnvironmentChangesChanged()
|
|
|
|
|
{
|
|
|
|
|
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::setArguments(const QString &args)
|
|
|
|
|
{
|
|
|
|
|
m_cmakeRunConfiguration->setArguments(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
// Factory
|
|
|
|
|
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeRunConfigurationFactory::~CMakeRunConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// used to recreate the runConfigurations when restoring settings
|
2009-06-12 17:57:03 +02:00
|
|
|
bool CMakeRunConfigurationFactory::canRestore(const QString &type) const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
|
|
|
|
if (type.startsWith(Constants::CMAKERUNCONFIGURATION))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// used to show the list of possible additons to a project, returns a list of types
|
2009-06-12 17:57:03 +02:00
|
|
|
QStringList CMakeRunConfigurationFactory::availableCreationTypes(ProjectExplorer::Project *project) const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
|
|
|
|
CMakeProject *pro = qobject_cast<CMakeProject *>(project);
|
|
|
|
|
if (!pro)
|
|
|
|
|
return QStringList();
|
2009-04-06 17:01:26 +02:00
|
|
|
QStringList allTargets = pro->targets();
|
|
|
|
|
for (int i=0; i<allTargets.size(); ++i) {
|
|
|
|
|
allTargets[i] = Constants::CMAKERUNCONFIGURATION + allTargets[i];
|
|
|
|
|
}
|
|
|
|
|
return allTargets;
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// used to translate the types to names to display to the user
|
2009-06-12 17:57:03 +02:00
|
|
|
QString CMakeRunConfigurationFactory::displayNameForType(const QString &type) const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2008-12-17 15:51:48 +01:00
|
|
|
Q_ASSERT(type.startsWith(Constants::CMAKERUNCONFIGURATION));
|
2008-12-09 14:53:06 +01:00
|
|
|
|
|
|
|
|
if (type == Constants::CMAKERUNCONFIGURATION)
|
|
|
|
|
return "CMake"; // Doesn't happen
|
|
|
|
|
else
|
|
|
|
|
return type.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSharedPointer<ProjectExplorer::RunConfiguration> CMakeRunConfigurationFactory::create(ProjectExplorer::Project *project, const QString &type)
|
|
|
|
|
{
|
|
|
|
|
CMakeProject *pro = qobject_cast<CMakeProject *>(project);
|
2008-12-17 15:51:48 +01:00
|
|
|
Q_ASSERT(pro);
|
2008-12-09 14:53:06 +01:00
|
|
|
if (type == Constants::CMAKERUNCONFIGURATION) {
|
|
|
|
|
// Restoring, filename will be added by restoreSettings
|
2009-03-16 17:33:05 +01:00
|
|
|
QSharedPointer<ProjectExplorer::RunConfiguration> rc(new CMakeRunConfiguration(pro, QString::null, QString::null, QString::null));
|
2008-12-09 14:53:06 +01:00
|
|
|
return rc;
|
|
|
|
|
} else {
|
|
|
|
|
// Adding new
|
2009-04-06 17:01:26 +02:00
|
|
|
const QString title = type.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
|
|
|
|
|
const CMakeTarget &ct = pro->targetForTitle(title);
|
|
|
|
|
QSharedPointer<ProjectExplorer::RunConfiguration> rc(new CMakeRunConfiguration(pro, ct.executable, ct.workingDirectory, ct.title));
|
2008-12-09 14:53:06 +01:00
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
}
|