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-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.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-09-17 13:59:10 +02:00
|
|
|
#include <utils/detailsbutton.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>
|
2009-07-20 15:46:11 +02:00
|
|
|
#include <QtGui/QComboBox>
|
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-09-25 11:35:44 +02:00
|
|
|
: ProjectExplorer::LocalApplicationRunConfiguration(pro)
|
2009-03-18 17:43:55 +01:00
|
|
|
, 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;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-25 11:35:44 +02:00
|
|
|
ProjectExplorer::LocalApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
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
|
|
|
|
|
{
|
2009-09-25 11:35:44 +02:00
|
|
|
ProjectExplorer::LocalApplicationRunConfiguration::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)
|
|
|
|
|
{
|
2009-09-25 11:35:44 +02:00
|
|
|
ProjectExplorer::LocalApplicationRunConfiguration::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());
|
2009-09-17 15:45:22 +02:00
|
|
|
QString qtInstallData = ProjectExplorer::DebuggingHelperLibrary::qtInstallDataDir(qmakePath);
|
|
|
|
|
QString dhl = ProjectExplorer::DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData);
|
2009-04-24 14:59:47 +02:00
|
|
|
return dhl;
|
2009-03-25 15:18:37 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-15 17:41:45 +02:00
|
|
|
QStringList CMakeRunConfiguration::dumperLibraryLocations() const
|
|
|
|
|
{
|
|
|
|
|
QString qmakePath = ProjectExplorer::DebuggingHelperLibrary::findSystemQt(environment());
|
2009-09-17 15:45:22 +02:00
|
|
|
QString qtInstallData = ProjectExplorer::DebuggingHelperLibrary::qtInstallDataDir(qmakePath);
|
|
|
|
|
return ProjectExplorer::DebuggingHelperLibrary::debuggingHelperLibraryLocationsByInstallData(qtInstallData);
|
2009-07-15 17:41:45 +02: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) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-17 17:56:40 +02:00
|
|
|
ProjectExplorer::ToolChain::ToolChainType CMakeRunConfiguration::toolChainType() const
|
|
|
|
|
{
|
|
|
|
|
CMakeProject *pro = static_cast<CMakeProject *>(project());
|
|
|
|
|
return pro->toolChainType();
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-27 17:28:50 +02:00
|
|
|
// 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();
|
2009-07-23 17:00:38 +02:00
|
|
|
fl->setMargin(0);
|
|
|
|
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
2009-05-27 17:28:50 +02:00
|
|
|
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-09-17 13:59:10 +02:00
|
|
|
m_detailsWidget = new QWidget(this);
|
|
|
|
|
m_detailsWidget->setLayout(fl);
|
|
|
|
|
m_detailsWidget->setVisible(false);
|
|
|
|
|
|
|
|
|
|
m_summaryLabel = new QLabel(this);
|
|
|
|
|
m_detailsButton = new Utils::DetailsButton(this);
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *hbox = new QHBoxLayout();
|
|
|
|
|
hbox->addWidget(m_summaryLabel);
|
|
|
|
|
hbox->addWidget(m_detailsButton);
|
|
|
|
|
|
2009-07-20 16:50:05 +02:00
|
|
|
QVBoxLayout *vbx = new QVBoxLayout(this);
|
2009-07-23 17:00:38 +02:00
|
|
|
vbx->setContentsMargins(0, -1, 0, -1);
|
2009-09-17 13:59:10 +02:00
|
|
|
vbx->addLayout(hbox);
|
|
|
|
|
vbx->addWidget(m_detailsWidget);
|
2009-07-20 16:50:05 +02:00
|
|
|
|
|
|
|
|
QLabel *environmentLabel = new QLabel(this);
|
|
|
|
|
environmentLabel->setText(tr("Run Environment"));
|
|
|
|
|
QFont f = environmentLabel->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() *1.2);
|
|
|
|
|
environmentLabel->setFont(f);
|
|
|
|
|
vbx->addWidget(environmentLabel);
|
2009-05-28 18:52:06 +02:00
|
|
|
|
2009-07-23 15:57:45 +02:00
|
|
|
QWidget *baseEnvironmentWidget = new QWidget;
|
|
|
|
|
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
|
|
|
|
|
baseEnvironmentLayout->setMargin(0);
|
2009-05-28 18:52:06 +02:00
|
|
|
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
|
2009-07-23 15:57:45 +02:00
|
|
|
baseEnvironmentLayout->addWidget(label);
|
2009-07-20 16:50:05 +02:00
|
|
|
m_baseEnvironmentComboBox = new QComboBox(this);
|
2009-07-20 15:46:11 +02:00
|
|
|
m_baseEnvironmentComboBox->addItems(QStringList()
|
|
|
|
|
<< tr("Clean Environment")
|
|
|
|
|
<< tr("System Environment")
|
|
|
|
|
<< tr("Build Environment"));
|
|
|
|
|
m_baseEnvironmentComboBox->setCurrentIndex(m_cmakeRunConfiguration->baseEnvironmentBase());
|
|
|
|
|
connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
|
|
|
|
|
this, SLOT(baseEnvironmentComboBoxChanged(int)));
|
2009-07-23 15:57:45 +02:00
|
|
|
baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
|
|
|
|
|
baseEnvironmentLayout->addStretch(10);
|
2009-05-28 18:52:06 +02:00
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
|
|
|
|
|
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
|
|
|
|
|
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
|
|
|
|
|
|
|
|
|
|
vbx->addWidget(m_environmentWidget);
|
|
|
|
|
|
|
|
|
|
updateSummary();
|
|
|
|
|
|
2009-06-19 17:55:47 +02:00
|
|
|
connect(m_workingDirectoryEdit, SIGNAL(changed(QString)),
|
2009-06-16 18:37:16 +02:00
|
|
|
this, SLOT(setWorkingDirectory()));
|
|
|
|
|
|
|
|
|
|
connect(resetButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(resetWorkingDirectory()));
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
connect(m_detailsButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(toggleDetails()));
|
2009-05-28 18:52:06 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
void CMakeRunConfigurationWidget::toggleDetails()
|
|
|
|
|
{
|
|
|
|
|
m_detailsWidget->setVisible(!m_detailsWidget->isVisible());
|
|
|
|
|
}
|
|
|
|
|
|
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-07-20 15:46:11 +02:00
|
|
|
void CMakeRunConfigurationWidget::baseEnvironmentComboBoxChanged(int index)
|
2009-05-28 18:52:06 +02:00
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2009-07-20 15:46:11 +02:00
|
|
|
m_cmakeRunConfiguration->setBaseEnvironmentBase(CMakeRunConfiguration::BaseEnvironmentBase(index));
|
2009-05-28 18:52:06 +02:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2009-07-20 15:46:11 +02:00
|
|
|
m_baseEnvironmentComboBox->setCurrentIndex(m_cmakeRunConfiguration->baseEnvironmentBase());
|
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);
|
2009-09-17 13:59:10 +02:00
|
|
|
updateSummary();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::updateSummary()
|
|
|
|
|
{
|
|
|
|
|
QString text = tr("Running executable: <b>%1</b> %2")
|
|
|
|
|
.arg(QFileInfo(m_cmakeRunConfiguration->executable()).fileName(),
|
|
|
|
|
ProjectExplorer::Environment::joinArgumentList(m_cmakeRunConfiguration->commandLineArguments()));
|
|
|
|
|
m_summaryLabel->setText(text);
|
2009-05-27 17:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|